优化UI界面
This commit is contained in:
parent
dfabe611ba
commit
a5adde8807
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,6 +2,14 @@
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "I:\\Desktop\\CusserCore\\ToolBox\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{8E5D0C31-935F-4C3B-8A56-8E8C1F9D9F5A}|QuickLauncher.csproj|i:\\desktop\\cussercore\\toolbox\\mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{8E5D0C31-935F-4C3B-8A56-8E8C1F9D9F5A}|QuickLauncher.csproj|solutionrelative:mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{8E5D0C31-935F-4C3B-8A56-8E8C1F9D9F5A}|QuickLauncher.csproj|i:\\desktop\\cussercore\\toolbox\\mainform.designer.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{8E5D0C31-935F-4C3B-8A56-8E8C1F9D9F5A}|QuickLauncher.csproj|solutionrelative:mainform.designer.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{8E5D0C31-935F-4C3B-8A56-8E8C1F9D9F5A}|QuickLauncher.csproj|i:\\desktop\\cussercore\\toolbox\\mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form",
|
||||
"RelativeMoniker": "D:0:0:{8E5D0C31-935F-4C3B-8A56-8E8C1F9D9F5A}|QuickLauncher.csproj|solutionrelative:mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form"
|
||||
@ -27,11 +35,37 @@
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "MainForm.cs",
|
||||
"DocumentMoniker": "I:\\Desktop\\CusserCore\\ToolBox\\MainForm.cs",
|
||||
"RelativeDocumentMoniker": "MainForm.cs",
|
||||
"ToolTip": "I:\\Desktop\\CusserCore\\ToolBox\\MainForm.cs",
|
||||
"RelativeToolTip": "MainForm.cs",
|
||||
"ViewState": "AgIAAKkDAAAAAAAAAAAkwLcDAABQAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T06:19:31.16Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "MainForm.Designer.cs",
|
||||
"DocumentMoniker": "I:\\Desktop\\CusserCore\\ToolBox\\MainForm.Designer.cs",
|
||||
"RelativeDocumentMoniker": "MainForm.Designer.cs",
|
||||
"ToolTip": "I:\\Desktop\\CusserCore\\ToolBox\\MainForm.Designer.cs",
|
||||
"RelativeToolTip": "MainForm.Designer.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAA0AAAA3AAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T06:57:18.744Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"Title": "MainForm.cs [\u8BBE\u8BA1]",
|
||||
"DocumentMoniker": "I:\\Desktop\\CusserCore\\ToolBox\\MainForm.cs",
|
||||
"RelativeDocumentMoniker": "MainForm.cs",
|
||||
"ToolTip": "I:\\Desktop\\CusserCore\\ToolBox\\MainForm.cs [\u8BBE\u8BA1]*",
|
||||
"RelativeToolTip": "MainForm.cs [\u8BBE\u8BA1]*",
|
||||
"ToolTip": "I:\\Desktop\\CusserCore\\ToolBox\\MainForm.cs [\u8BBE\u8BA1]",
|
||||
"RelativeToolTip": "MainForm.cs [\u8BBE\u8BA1]",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T06:05:42.834Z",
|
||||
"EditorCaption": " [\u8BBE\u8BA1]"
|
||||
|
||||
@ -3,7 +3,15 @@
|
||||
"WorkspaceRootPath": "I:\\Desktop\\CusserCore\\ToolBox\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{8E5D0C31-935F-4C3B-8A56-8E8C1F9D9F5A}|QuickLauncher.csproj|i:\\desktop\\cussercore\\toolbox\\mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form",
|
||||
"AbsoluteMoniker": "D:0:0:{8E5D0C31-935F-4C3B-8A56-8E8C1F9D9F5A}|QuickLauncher.csproj|i:\\desktop\\cussercore\\toolbox\\mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{8E5D0C31-935F-4C3B-8A56-8E8C1F9D9F5A}|QuickLauncher.csproj|solutionrelative:mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{8E5D0C31-935F-4C3B-8A56-8E8C1F9D9F5A}|QuickLauncher.csproj|i:\\desktop\\cussercore\\toolbox\\mainform.designer.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{8E5D0C31-935F-4C3B-8A56-8E8C1F9D9F5A}|QuickLauncher.csproj|solutionrelative:mainform.designer.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{8E5D0C31-935F-4C3B-8A56-8E8C1F9D9F5A}|QuickLauncher.csproj|I:\\Desktop\\CusserCore\\ToolBox\\mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form",
|
||||
"RelativeMoniker": "D:0:0:{8E5D0C31-935F-4C3B-8A56-8E8C1F9D9F5A}|QuickLauncher.csproj|solutionrelative:mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form"
|
||||
}
|
||||
],
|
||||
@ -27,14 +35,38 @@
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "MainForm.cs",
|
||||
"DocumentMoniker": "I:\\Desktop\\CusserCore\\ToolBox\\MainForm.cs",
|
||||
"RelativeDocumentMoniker": "MainForm.cs",
|
||||
"ToolTip": "I:\\Desktop\\CusserCore\\ToolBox\\MainForm.cs",
|
||||
"RelativeToolTip": "MainForm.cs",
|
||||
"ViewState": "AgIAAKkDAAAAAAAAAAAkwLcDAABQAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T06:19:31.16Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "MainForm.Designer.cs",
|
||||
"DocumentMoniker": "I:\\Desktop\\CusserCore\\ToolBox\\MainForm.Designer.cs",
|
||||
"RelativeDocumentMoniker": "MainForm.Designer.cs",
|
||||
"ToolTip": "I:\\Desktop\\CusserCore\\ToolBox\\MainForm.Designer.cs",
|
||||
"RelativeToolTip": "MainForm.Designer.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAA0AAAA3AAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T06:57:18.744Z"
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"Title": "MainForm.cs [\u8BBE\u8BA1]",
|
||||
"DocumentMoniker": "I:\\Desktop\\CusserCore\\ToolBox\\MainForm.cs",
|
||||
"RelativeDocumentMoniker": "MainForm.cs",
|
||||
"ToolTip": "I:\\Desktop\\CusserCore\\ToolBox\\MainForm.cs [\u8BBE\u8BA1]",
|
||||
"RelativeToolTip": "MainForm.cs [\u8BBE\u8BA1]",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T06:05:42.834Z",
|
||||
"EditorCaption": " [\u8BBE\u8BA1]"
|
||||
"WhenOpened": "2025-03-12T06:05:42.834Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
46
MainForm.Designer.cs
generated
46
MainForm.Designer.cs
generated
@ -47,58 +47,59 @@ namespace QuickLauncher
|
||||
// leftPanel
|
||||
//
|
||||
leftPanel.AutoScroll = true;
|
||||
leftPanel.BackColor = Color.FromArgb(230, 255, 230);
|
||||
leftPanel.BackColor = Color.FromArgb(243, 243, 243);
|
||||
leftPanel.Dock = DockStyle.Left;
|
||||
leftPanel.Location = new Point(0, 36);
|
||||
leftPanel.Margin = new Padding(6, 6, 6, 6);
|
||||
leftPanel.Margin = new Padding(6);
|
||||
leftPanel.Name = "leftPanel";
|
||||
leftPanel.Size = new Size(275, 1164);
|
||||
leftPanel.Size = new Size(300, 1164);
|
||||
leftPanel.TabIndex = 0;
|
||||
//
|
||||
// rightPanel
|
||||
//
|
||||
rightPanel.BackColor = Color.White;
|
||||
rightPanel.BackColor = Color.FromArgb(250, 250, 250);
|
||||
rightPanel.Controls.Add(shortcutsPanel);
|
||||
rightPanel.Controls.Add(toolPanel);
|
||||
rightPanel.Dock = DockStyle.Fill;
|
||||
rightPanel.Location = new Point(275, 36);
|
||||
rightPanel.Margin = new Padding(6, 6, 6, 6);
|
||||
rightPanel.Location = new Point(300, 36);
|
||||
rightPanel.Margin = new Padding(6);
|
||||
rightPanel.Name = "rightPanel";
|
||||
rightPanel.Size = new Size(1192, 1164);
|
||||
rightPanel.Size = new Size(1167, 1164);
|
||||
rightPanel.TabIndex = 1;
|
||||
//
|
||||
// shortcutsPanel
|
||||
//
|
||||
shortcutsPanel.AllowDrop = true;
|
||||
shortcutsPanel.AutoScroll = true;
|
||||
shortcutsPanel.BackColor = Color.White;
|
||||
shortcutsPanel.BackColor = Color.FromArgb(250, 250, 250);
|
||||
shortcutsPanel.Dock = DockStyle.Fill;
|
||||
shortcutsPanel.Location = new Point(0, 80);
|
||||
shortcutsPanel.Margin = new Padding(6, 6, 6, 6);
|
||||
shortcutsPanel.Margin = new Padding(6);
|
||||
shortcutsPanel.Name = "shortcutsPanel";
|
||||
shortcutsPanel.Padding = new Padding(18, 20, 18, 20);
|
||||
shortcutsPanel.Size = new Size(1192, 1084);
|
||||
shortcutsPanel.Padding = new Padding(20);
|
||||
shortcutsPanel.Size = new Size(1167, 1084);
|
||||
shortcutsPanel.TabIndex = 1;
|
||||
//
|
||||
// toolPanel
|
||||
//
|
||||
toolPanel.BackColor = Color.FromArgb(240, 240, 240);
|
||||
toolPanel.BackColor = Color.FromArgb(230, 230, 230);
|
||||
toolPanel.Controls.Add(addButton);
|
||||
toolPanel.Controls.Add(categoryLabel);
|
||||
toolPanel.Dock = DockStyle.Top;
|
||||
toolPanel.Location = new Point(0, 0);
|
||||
toolPanel.Margin = new Padding(6, 6, 6, 6);
|
||||
toolPanel.Margin = new Padding(6);
|
||||
toolPanel.Name = "toolPanel";
|
||||
toolPanel.Padding = new Padding(9, 10, 9, 10);
|
||||
toolPanel.Size = new Size(1192, 80);
|
||||
toolPanel.Padding = new Padding(15, 10, 15, 10);
|
||||
toolPanel.Size = new Size(1167, 80);
|
||||
toolPanel.TabIndex = 0;
|
||||
//
|
||||
// addButton
|
||||
//
|
||||
addButton.BackColor = Color.FromArgb(200, 255, 200);
|
||||
addButton.BackColor = Color.FromArgb(0, 120, 212);
|
||||
addButton.FlatStyle = FlatStyle.Flat;
|
||||
addButton.Location = new Point(18, 10);
|
||||
addButton.Margin = new Padding(6, 6, 6, 6);
|
||||
addButton.ForeColor = Color.White;
|
||||
addButton.Location = new Point(20, 10);
|
||||
addButton.Margin = new Padding(6);
|
||||
addButton.Name = "addButton";
|
||||
addButton.Size = new Size(183, 60);
|
||||
addButton.TabIndex = 0;
|
||||
@ -109,15 +110,16 @@ namespace QuickLauncher
|
||||
// categoryLabel
|
||||
//
|
||||
categoryLabel.AutoSize = true;
|
||||
categoryLabel.Font = new Font("Microsoft YaHei UI", 10F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
categoryLabel.Location = new Point(220, 20);
|
||||
categoryLabel.Font = new Font("Microsoft YaHei UI", 11F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
categoryLabel.Location = new Point(220, 25);
|
||||
categoryLabel.Margin = new Padding(6, 0, 6, 0);
|
||||
categoryLabel.Name = "categoryLabel";
|
||||
categoryLabel.Size = new Size(0, 27);
|
||||
categoryLabel.Size = new Size(0, 30);
|
||||
categoryLabel.TabIndex = 1;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.BackColor = Color.FromArgb(230, 230, 230);
|
||||
menuStrip.ImageScalingSize = new Size(24, 24);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { fileMenu });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
@ -157,7 +159,7 @@ namespace QuickLauncher
|
||||
Controls.Add(menuStrip);
|
||||
Icon = (Icon)resources.GetObject("$this.Icon");
|
||||
MainMenuStrip = menuStrip;
|
||||
Margin = new Padding(6, 6, 6, 6);
|
||||
Margin = new Padding(6);
|
||||
Name = "MainForm";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "快捷启动工具箱";
|
||||
|
||||
756
MainForm.cs
756
MainForm.cs
@ -5,11 +5,90 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices; // 添加P/Invoke支持
|
||||
using System.Drawing.Drawing2D; // 添加GDI+支持
|
||||
using Microsoft.Win32; // 添加Registry访问支持
|
||||
|
||||
namespace QuickLauncher
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
// Windows 11 UI相关
|
||||
private bool isDarkMode = false;
|
||||
private Color accentColor = Color.FromArgb(0, 120, 212); // Windows默认蓝色
|
||||
private readonly Color lightBackColor = Color.FromArgb(243, 243, 243);
|
||||
private readonly Color darkBackColor = Color.FromArgb(32, 32, 32);
|
||||
private readonly Color lightTextColor = Color.FromArgb(0, 0, 0);
|
||||
private readonly Color darkTextColor = Color.FromArgb(255, 255, 255);
|
||||
private readonly int cornerRadius = 8; // Windows 11圆角半径
|
||||
|
||||
// P/Invoke用于实现Windows 11 Mica效果
|
||||
[DllImport("dwmapi.dll")]
|
||||
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
|
||||
|
||||
// DWM属性常量
|
||||
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
|
||||
private const int DWMWA_MICA_EFFECT = 1029;
|
||||
|
||||
// 添加圆角支持的类
|
||||
private class RoundedPanel : Panel
|
||||
{
|
||||
private int _cornerRadius = 8;
|
||||
|
||||
public int CornerRadius
|
||||
{
|
||||
get { return _cornerRadius; }
|
||||
set { _cornerRadius = value; Invalidate(); }
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
|
||||
// 创建圆角路径
|
||||
using (GraphicsPath path = new GraphicsPath())
|
||||
{
|
||||
path.AddArc(0, 0, CornerRadius, CornerRadius, 180, 90);
|
||||
path.AddArc(Width - CornerRadius, 0, CornerRadius, CornerRadius, 270, 90);
|
||||
path.AddArc(Width - CornerRadius, Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
|
||||
path.AddArc(0, Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
this.Region = new Region(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加圆角按钮支持的类
|
||||
private class RoundedButton : Button
|
||||
{
|
||||
private int _cornerRadius = 8;
|
||||
|
||||
public int CornerRadius
|
||||
{
|
||||
get { return _cornerRadius; }
|
||||
set { _cornerRadius = value; Invalidate(); }
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
|
||||
// 创建圆角路径
|
||||
using (GraphicsPath path = new GraphicsPath())
|
||||
{
|
||||
path.AddArc(0, 0, CornerRadius, CornerRadius, 180, 90);
|
||||
path.AddArc(Width - CornerRadius, 0, CornerRadius, CornerRadius, 270, 90);
|
||||
path.AddArc(Width - CornerRadius, Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
|
||||
path.AddArc(0, Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
this.Region = new Region(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 原有的字段
|
||||
private Dictionary<string, List<ShortcutItem>> categories;
|
||||
private string dataFilePath = "shortcuts.json";
|
||||
private string settingsFilePath = "settings.json";
|
||||
@ -23,12 +102,21 @@ namespace QuickLauncher
|
||||
private const int MAX_ICON_SIZE = 256; // 增加最大图标大小到256
|
||||
private const int ICON_SIZE_STEP = 16; // 增加每次缩放的步长
|
||||
|
||||
// 左侧面板调整相关
|
||||
private bool isResizing = false;
|
||||
private int resizingStartX = 0;
|
||||
private int initialPanelWidth = 0;
|
||||
private const int MIN_PANEL_WIDTH = 200;
|
||||
private const int MAX_PANEL_WIDTH = 500;
|
||||
private Panel resizeHandle;
|
||||
|
||||
// 用于保存设置的类
|
||||
private class AppSettings
|
||||
{
|
||||
public string LastSelectedCategory { get; set; } = "";
|
||||
public string SortMode { get; set; } = "Name"; // Name, DateAdded
|
||||
public int IconSize { get; set; } = 48; // 保存图标大小
|
||||
public int LeftPanelWidth { get; set; } = 300; // 左侧面板宽度
|
||||
}
|
||||
|
||||
private AppSettings settings = new AppSettings();
|
||||
@ -46,12 +134,158 @@ namespace QuickLauncher
|
||||
toolTip1.UseFading = true;
|
||||
toolTip1.IsBalloon = false; // 使用标准样式
|
||||
|
||||
// 初始化数据和UI
|
||||
InitializeUI();
|
||||
|
||||
// 应用Windows 11风格
|
||||
ApplyWin11Style();
|
||||
|
||||
SetupContextMenus();
|
||||
SetupEventHandlers();
|
||||
InitializeUI();
|
||||
LoadSettings();
|
||||
LoadData();
|
||||
SelectDefaultCategory();
|
||||
|
||||
// 监听系统主题变化
|
||||
SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
|
||||
}
|
||||
|
||||
private void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
|
||||
{
|
||||
if (e.Category == UserPreferenceCategory.General)
|
||||
{
|
||||
// 在UI线程中更新主题
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new Action(() => UpdateTheme()));
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateTheme();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTheme()
|
||||
{
|
||||
// 更新深色模式状态
|
||||
isDarkMode = IsSystemUsingSysemDarkTheme();
|
||||
|
||||
// 重新应用Windows 11风格
|
||||
ApplyWin11Style();
|
||||
}
|
||||
|
||||
// 应用Windows 11风格
|
||||
private void ApplyWin11Style()
|
||||
{
|
||||
// 检测系统主题
|
||||
isDarkMode = IsSystemUsingSysemDarkTheme();
|
||||
|
||||
// 应用Mica效果
|
||||
if (Environment.OSVersion.Version.Build >= 22000) // Windows 11
|
||||
{
|
||||
try
|
||||
{
|
||||
// 应用深色/浅色模式
|
||||
int darkMode = isDarkMode ? 1 : 0;
|
||||
DwmSetWindowAttribute(this.Handle, DWMWA_USE_IMMERSIVE_DARK_MODE, ref darkMode, sizeof(int));
|
||||
|
||||
// 应用Mica效果
|
||||
int micaEffect = 1;
|
||||
DwmSetWindowAttribute(this.Handle, DWMWA_MICA_EFFECT, ref micaEffect, sizeof(int));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// 如果不支持,则使用备用方案
|
||||
this.BackColor = isDarkMode ? darkBackColor : lightBackColor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 在Windows 10上使用备用方案
|
||||
this.BackColor = isDarkMode ? darkBackColor : lightBackColor;
|
||||
}
|
||||
|
||||
// 应用主题颜色
|
||||
ApplyThemeColors();
|
||||
}
|
||||
|
||||
// 检测系统是否使用深色主题
|
||||
private bool IsSystemUsingSysemDarkTheme()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
var value = key.GetValue("AppsUseLightTheme");
|
||||
if (value != null && value is int)
|
||||
{
|
||||
return (int)value == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// 应用主题颜色
|
||||
private void ApplyThemeColors()
|
||||
{
|
||||
// 设置主窗体颜色
|
||||
this.ForeColor = isDarkMode ? darkTextColor : lightTextColor;
|
||||
|
||||
// 设置左侧面板颜色
|
||||
leftPanel.BackColor = isDarkMode ? Color.FromArgb(40, 40, 40) : Color.FromArgb(243, 243, 243);
|
||||
|
||||
// 设置右侧面板颜色
|
||||
rightPanel.BackColor = isDarkMode ? Color.FromArgb(32, 32, 32) : Color.FromArgb(250, 250, 250);
|
||||
|
||||
// 设置工具面板颜色
|
||||
toolPanel.BackColor = isDarkMode ? Color.FromArgb(45, 45, 45) : Color.FromArgb(230, 230, 230);
|
||||
|
||||
// 设置快捷方式面板颜色
|
||||
shortcutsPanel.BackColor = isDarkMode ? Color.FromArgb(32, 32, 32) : Color.FromArgb(250, 250, 250);
|
||||
|
||||
// 设置添加按钮颜色
|
||||
addButton.BackColor = accentColor;
|
||||
addButton.ForeColor = Color.White;
|
||||
addButton.FlatAppearance.BorderSize = 0;
|
||||
|
||||
// 设置菜单颜色
|
||||
menuStrip.BackColor = isDarkMode ? Color.FromArgb(45, 45, 45) : Color.FromArgb(230, 230, 230);
|
||||
menuStrip.ForeColor = isDarkMode ? darkTextColor : lightTextColor;
|
||||
|
||||
// 设置菜单项颜色
|
||||
foreach (ToolStripMenuItem item in menuStrip.Items)
|
||||
{
|
||||
item.ForeColor = isDarkMode ? Color.White : Color.Black;
|
||||
|
||||
// 设置下拉菜单项颜色
|
||||
foreach (ToolStripItem dropItem in item.DropDownItems)
|
||||
{
|
||||
if (dropItem is ToolStripMenuItem menuItem)
|
||||
{
|
||||
menuItem.ForeColor = isDarkMode ? Color.White : Color.Black;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 设置菜单渲染器
|
||||
menuStrip.Renderer = new ModernMenuRenderer(isDarkMode);
|
||||
|
||||
// 刷新分类列表和当前分类的快捷方式(仅当categories已初始化时)
|
||||
if (categories != null)
|
||||
{
|
||||
RefreshCategoryList();
|
||||
if (!string.IsNullOrEmpty(currentCategory))
|
||||
{
|
||||
ShowCategoryItems(currentCategory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 设置上下文菜单
|
||||
@ -63,6 +297,9 @@ namespace QuickLauncher
|
||||
categoryContextMenu.Items.Add("删除当前分类", null, (s, e) => DeleteCategory_Click(s, e));
|
||||
categoryContextMenu.Items.Add("重命名分类", null, (s, e) => RenameCategory_Click(s, e));
|
||||
|
||||
// 应用主题颜色
|
||||
categoryContextMenu.Renderer = new ModernMenuRenderer(isDarkMode);
|
||||
|
||||
// 右侧面板右键菜单
|
||||
shortcutsPanelContextMenu = new ContextMenuStrip();
|
||||
shortcutsPanelContextMenu.Items.Add("添加程序", null, (s, e) => AddButton_Click(s, e));
|
||||
@ -83,6 +320,17 @@ namespace QuickLauncher
|
||||
sizeMenu.DropDownItems.Add("巨大图标 (256px)", null, (s, e) => { ResizeIcons(256); });
|
||||
shortcutsPanelContextMenu.Items.Add(sizeMenu);
|
||||
|
||||
// 添加主题切换选项
|
||||
shortcutsPanelContextMenu.Items.Add("-"); // 分隔线
|
||||
var themeMenu = new ToolStripMenuItem("主题设置");
|
||||
themeMenu.DropDownItems.Add("浅色主题", null, (s, e) => { ChangeTheme(false); });
|
||||
themeMenu.DropDownItems.Add("深色主题", null, (s, e) => { ChangeTheme(true); });
|
||||
themeMenu.DropDownItems.Add("跟随系统", null, (s, e) => { FollowSystemTheme(); });
|
||||
shortcutsPanelContextMenu.Items.Add(themeMenu);
|
||||
|
||||
// 应用主题颜色
|
||||
shortcutsPanelContextMenu.Renderer = new ModernMenuRenderer(isDarkMode);
|
||||
|
||||
// 快捷方式项目右键菜单
|
||||
shortcutItemContextMenu = new ContextMenuStrip();
|
||||
shortcutItemContextMenu.Items.Add("启动", null, (s, e) =>
|
||||
@ -113,6 +361,123 @@ namespace QuickLauncher
|
||||
ShowShortcutProperties(item);
|
||||
}
|
||||
});
|
||||
|
||||
// 应用主题颜色
|
||||
shortcutItemContextMenu.Renderer = new ModernMenuRenderer(isDarkMode);
|
||||
}
|
||||
|
||||
// 切换主题
|
||||
private void ChangeTheme(bool darkMode)
|
||||
{
|
||||
isDarkMode = darkMode;
|
||||
ApplyThemeColors();
|
||||
|
||||
// 更新上下文菜单渲染器
|
||||
categoryContextMenu.Renderer = new ModernMenuRenderer(isDarkMode);
|
||||
shortcutsPanelContextMenu.Renderer = new ModernMenuRenderer(isDarkMode);
|
||||
shortcutItemContextMenu.Renderer = new ModernMenuRenderer(isDarkMode);
|
||||
}
|
||||
|
||||
// 跟随系统主题
|
||||
private void FollowSystemTheme()
|
||||
{
|
||||
isDarkMode = IsSystemUsingSysemDarkTheme();
|
||||
ApplyThemeColors();
|
||||
|
||||
// 更新上下文菜单渲染器
|
||||
categoryContextMenu.Renderer = new ModernMenuRenderer(isDarkMode);
|
||||
shortcutsPanelContextMenu.Renderer = new ModernMenuRenderer(isDarkMode);
|
||||
shortcutItemContextMenu.Renderer = new ModernMenuRenderer(isDarkMode);
|
||||
}
|
||||
|
||||
// 现代菜单渲染器
|
||||
private class ModernMenuRenderer : ToolStripProfessionalRenderer
|
||||
{
|
||||
private bool _isDarkMode;
|
||||
|
||||
public ModernMenuRenderer(bool isDarkMode) : base(new ModernColorTable(isDarkMode))
|
||||
{
|
||||
_isDarkMode = isDarkMode;
|
||||
}
|
||||
|
||||
protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
|
||||
{
|
||||
if (e.Item.Selected)
|
||||
{
|
||||
// 选中项背景
|
||||
Rectangle rect = new Rectangle(2, 0, e.Item.Width - 4, e.Item.Height);
|
||||
Color highlightColor = _isDarkMode ? Color.FromArgb(70, 70, 70) : Color.FromArgb(210, 230, 250);
|
||||
using (SolidBrush brush = new SolidBrush(highlightColor))
|
||||
{
|
||||
e.Graphics.FillRoundedRectangle(brush, rect, 4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 普通项背景
|
||||
Color backColor = _isDarkMode ? Color.FromArgb(45, 45, 45) : Color.FromArgb(250, 250, 250);
|
||||
using (SolidBrush brush = new SolidBrush(backColor))
|
||||
{
|
||||
e.Graphics.FillRectangle(brush, e.Item.ContentRectangle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
|
||||
{
|
||||
// 菜单背景
|
||||
Color backColor = _isDarkMode ? Color.FromArgb(45, 45, 45) : Color.FromArgb(250, 250, 250);
|
||||
using (SolidBrush brush = new SolidBrush(backColor))
|
||||
{
|
||||
e.Graphics.FillRectangle(brush, e.AffectedBounds);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
|
||||
{
|
||||
// 菜单文本颜色
|
||||
e.TextColor = _isDarkMode ? Color.FromArgb(240, 240, 240) : Color.FromArgb(20, 20, 20);
|
||||
base.OnRenderItemText(e);
|
||||
}
|
||||
|
||||
protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
|
||||
{
|
||||
// 分隔线颜色
|
||||
Color lineColor = _isDarkMode ? Color.FromArgb(80, 80, 80) : Color.FromArgb(200, 200, 200);
|
||||
int y = e.Item.Height / 2;
|
||||
using (Pen pen = new Pen(lineColor))
|
||||
{
|
||||
e.Graphics.DrawLine(pen, 4, y, e.Item.Width - 4, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 现代菜单颜色表
|
||||
private class ModernColorTable : ProfessionalColorTable
|
||||
{
|
||||
private bool _isDarkMode;
|
||||
|
||||
public ModernColorTable(bool isDarkMode)
|
||||
{
|
||||
_isDarkMode = isDarkMode;
|
||||
}
|
||||
|
||||
// 菜单项
|
||||
public override Color MenuItemSelected => _isDarkMode ? Color.FromArgb(70, 70, 70) : Color.FromArgb(210, 230, 250);
|
||||
public override Color MenuItemBorder => Color.Transparent;
|
||||
|
||||
// 菜单栏
|
||||
public override Color MenuBorder => Color.Transparent;
|
||||
public override Color MenuItemSelectedGradientBegin => _isDarkMode ? Color.FromArgb(70, 70, 70) : Color.FromArgb(210, 230, 250);
|
||||
public override Color MenuItemSelectedGradientEnd => _isDarkMode ? Color.FromArgb(70, 70, 70) : Color.FromArgb(210, 230, 250);
|
||||
public override Color MenuItemPressedGradientBegin => _isDarkMode ? Color.FromArgb(80, 80, 80) : Color.FromArgb(190, 210, 240);
|
||||
public override Color MenuItemPressedGradientEnd => _isDarkMode ? Color.FromArgb(80, 80, 80) : Color.FromArgb(190, 210, 240);
|
||||
|
||||
// 工具栏
|
||||
public override Color ToolStripDropDownBackground => _isDarkMode ? Color.FromArgb(45, 45, 45) : Color.FromArgb(250, 250, 250);
|
||||
public override Color ImageMarginGradientBegin => _isDarkMode ? Color.FromArgb(45, 45, 45) : Color.FromArgb(250, 250, 250);
|
||||
public override Color ImageMarginGradientMiddle => _isDarkMode ? Color.FromArgb(45, 45, 45) : Color.FromArgb(250, 250, 250);
|
||||
public override Color ImageMarginGradientEnd => _isDarkMode ? Color.FromArgb(45, 45, 45) : Color.FromArgb(250, 250, 250);
|
||||
}
|
||||
|
||||
// 调整图标大小
|
||||
@ -339,6 +704,7 @@ namespace QuickLauncher
|
||||
{
|
||||
settings.LastSelectedCategory = currentCategory;
|
||||
settings.IconSize = iconSize;
|
||||
settings.LeftPanelWidth = leftPanel.Width;
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
WriteIndented = true
|
||||
@ -362,6 +728,7 @@ namespace QuickLauncher
|
||||
var json = File.ReadAllText(settingsFilePath);
|
||||
settings = JsonSerializer.Deserialize<AppSettings>(json) ?? new AppSettings();
|
||||
iconSize = settings.IconSize; // 加载保存的图标大小
|
||||
leftPanel.Width = settings.LeftPanelWidth;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -448,10 +815,108 @@ namespace QuickLauncher
|
||||
|
||||
private void InitializeUI()
|
||||
{
|
||||
// 初始化数据
|
||||
categories = new Dictionary<string, List<ShortcutItem>>();
|
||||
|
||||
// 设置窗体样式
|
||||
this.FormBorderStyle = FormBorderStyle.Sizable;
|
||||
this.MinimumSize = new Size(800, 600);
|
||||
|
||||
// 设置控件样式
|
||||
addButton.FlatStyle = FlatStyle.Flat;
|
||||
addButton.FlatAppearance.BorderSize = 0;
|
||||
addButton.BackColor = accentColor;
|
||||
addButton.ForeColor = Color.White;
|
||||
addButton.Font = new Font("Microsoft YaHei UI", 10, FontStyle.Regular);
|
||||
|
||||
// 设置分类标签样式
|
||||
categoryLabel.Font = new Font("Microsoft YaHei UI", 11);
|
||||
categoryLabel.ForeColor = isDarkMode ? Color.Black : Color.White;
|
||||
|
||||
// 创建左侧面板调整手柄
|
||||
CreateResizeHandle();
|
||||
|
||||
// 刷新分类列表
|
||||
RefreshCategoryList();
|
||||
}
|
||||
|
||||
// 创建左侧面板调整手柄
|
||||
private void CreateResizeHandle()
|
||||
{
|
||||
// 创建调整手柄
|
||||
resizeHandle = new Panel
|
||||
{
|
||||
Width = 5,
|
||||
Dock = DockStyle.Right,
|
||||
Cursor = Cursors.SizeWE,
|
||||
BackColor = Color.Transparent
|
||||
};
|
||||
|
||||
// 添加鼠标事件
|
||||
resizeHandle.MouseDown += ResizeHandle_MouseDown;
|
||||
resizeHandle.MouseMove += ResizeHandle_MouseMove;
|
||||
resizeHandle.MouseUp += ResizeHandle_MouseUp;
|
||||
|
||||
// 添加到左侧面板
|
||||
leftPanel.Controls.Add(resizeHandle);
|
||||
resizeHandle.BringToFront();
|
||||
}
|
||||
|
||||
// 调整手柄鼠标按下事件
|
||||
private void ResizeHandle_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
isResizing = true;
|
||||
resizingStartX = e.X;
|
||||
initialPanelWidth = leftPanel.Width;
|
||||
|
||||
// 捕获鼠标
|
||||
resizeHandle.Capture = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 调整手柄鼠标移动事件
|
||||
private void ResizeHandle_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (isResizing)
|
||||
{
|
||||
// 计算新宽度
|
||||
int newWidth = initialPanelWidth + (e.X - resizingStartX);
|
||||
|
||||
// 限制宽度范围
|
||||
if (newWidth < MIN_PANEL_WIDTH)
|
||||
newWidth = MIN_PANEL_WIDTH;
|
||||
else if (newWidth > MAX_PANEL_WIDTH)
|
||||
newWidth = MAX_PANEL_WIDTH;
|
||||
|
||||
// 设置新宽度
|
||||
leftPanel.Width = newWidth;
|
||||
|
||||
// 刷新布局
|
||||
this.PerformLayout();
|
||||
|
||||
// 刷新分类列表,以适应新宽度
|
||||
RefreshCategoryList();
|
||||
}
|
||||
}
|
||||
|
||||
// 调整手柄鼠标释放事件
|
||||
private void ResizeHandle_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (isResizing)
|
||||
{
|
||||
isResizing = false;
|
||||
|
||||
// 释放鼠标捕获
|
||||
resizeHandle.Capture = false;
|
||||
|
||||
// 保存设置
|
||||
settings.LeftPanelWidth = leftPanel.Width;
|
||||
SaveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
private void AddCategory_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var dialog = new Form())
|
||||
@ -462,10 +927,32 @@ namespace QuickLauncher
|
||||
dialog.FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||
dialog.MaximizeBox = false;
|
||||
dialog.MinimizeBox = false;
|
||||
dialog.BackColor = isDarkMode ? Color.FromArgb(32, 32, 32) : Color.FromArgb(243, 243, 243);
|
||||
dialog.ForeColor = isDarkMode ? Color.White : Color.Black;
|
||||
|
||||
var label = new Label() { Text = "分类名称:", Location = new Point(10, 20) };
|
||||
var textBox = new TextBox() { Location = new Point(120, 17), Width = 180 };
|
||||
var button = new Button() { Text = "确定", DialogResult = DialogResult.OK, Location = new Point(110, 60) };
|
||||
var label = new Label() {
|
||||
Text = "分类名称:",
|
||||
Location = new Point(10, 20),
|
||||
ForeColor = isDarkMode ? Color.White : Color.Black
|
||||
};
|
||||
|
||||
var textBox = new TextBox() {
|
||||
Location = new Point(120, 17),
|
||||
Width = 180,
|
||||
BackColor = isDarkMode ? Color.FromArgb(45, 45, 45) : Color.White,
|
||||
ForeColor = isDarkMode ? Color.White : Color.Black
|
||||
};
|
||||
|
||||
var button = new RoundedButton() {
|
||||
Text = "确定",
|
||||
DialogResult = DialogResult.OK,
|
||||
Location = new Point(110, 60),
|
||||
Width = 100,
|
||||
Height = 30,
|
||||
BackColor = Color.FromArgb(210, 210, 210, 200), // 自定义RGB颜色
|
||||
ForeColor = Color.FromArgb(40, 40, 40),
|
||||
CornerRadius = cornerRadius
|
||||
};
|
||||
|
||||
dialog.Controls.AddRange(new Control[] { label, textBox, button });
|
||||
dialog.AcceptButton = button;
|
||||
@ -510,38 +997,44 @@ namespace QuickLauncher
|
||||
currentCategory = categories.Keys.First();
|
||||
ShowCategoryItems(currentCategory);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果没有分类了,清空右侧面板和标签
|
||||
shortcutsPanel.Controls.Clear();
|
||||
categoryLabel.Text = "当前分类: 无";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshCategoryList()
|
||||
{
|
||||
// 如果categories为空,直接返回
|
||||
if (categories == null)
|
||||
return;
|
||||
|
||||
leftPanel.Controls.Clear();
|
||||
int buttonY = 10;
|
||||
|
||||
foreach (var category in categories.Keys)
|
||||
{
|
||||
var categoryPanel = new Panel
|
||||
var categoryPanel = new RoundedPanel
|
||||
{
|
||||
Width = leftPanel.Width - 5,
|
||||
Height = CATEGORY_BUTTON_HEIGHT,
|
||||
Location = new Point(0, buttonY)
|
||||
Location = new Point(0, buttonY),
|
||||
CornerRadius = cornerRadius
|
||||
};
|
||||
|
||||
var btn = new Button
|
||||
var btn = new RoundedButton
|
||||
{
|
||||
Text = category,
|
||||
Width = leftPanel.Width - 20,
|
||||
Height = CATEGORY_BUTTON_HEIGHT,
|
||||
Location = new Point(10, 0),
|
||||
FlatStyle = FlatStyle.Flat,
|
||||
BackColor = Color.FromArgb(200, 255, 200),
|
||||
Tag = category
|
||||
BackColor = category == currentCategory ?
|
||||
accentColor :
|
||||
(isDarkMode ? Color.FromArgb(60, 60, 60) : Color.FromArgb(230, 230, 230)),
|
||||
ForeColor = category == currentCategory ?
|
||||
Color.White :
|
||||
(isDarkMode ? Color.FromArgb(240, 240, 240) : Color.FromArgb(20, 20, 20)),
|
||||
Tag = category,
|
||||
CornerRadius = cornerRadius,
|
||||
FlatAppearance = { BorderSize = 0 }
|
||||
};
|
||||
|
||||
// 移除旧的事件处理器
|
||||
@ -622,13 +1115,14 @@ namespace QuickLauncher
|
||||
int panelWidth = Math.Max(80, iconSize + 10);
|
||||
int panelHeight = iconSize + 60;
|
||||
|
||||
var panel = new Panel
|
||||
var panel = new RoundedPanel
|
||||
{
|
||||
Width = panelWidth,
|
||||
Height = panelHeight,
|
||||
Margin = new Padding(5),
|
||||
Tag = item,
|
||||
BackColor = Color.Transparent // 初始背景色为透明
|
||||
BackColor = isDarkMode ? Color.FromArgb(50, 50, 50) : Color.FromArgb(245, 245, 245),
|
||||
CornerRadius = cornerRadius
|
||||
};
|
||||
|
||||
var icon = new PictureBox
|
||||
@ -650,7 +1144,8 @@ namespace QuickLauncher
|
||||
Height = 30,
|
||||
Location = new Point(0, iconSize + 10),
|
||||
Tag = item,
|
||||
Cursor = Cursors.Hand // 鼠标悬停时显示手型光标
|
||||
Cursor = Cursors.Hand, // 鼠标悬停时显示手型光标
|
||||
ForeColor = isDarkMode ? Color.FromArgb(240, 240, 240) : Color.FromArgb(20, 20, 20)
|
||||
};
|
||||
|
||||
panel.Controls.Add(icon);
|
||||
@ -688,11 +1183,6 @@ namespace QuickLauncher
|
||||
label.MouseEnter += Panel_MouseEnter;
|
||||
label.MouseLeave += Panel_MouseLeave;
|
||||
|
||||
// 移除鼠标移动事件,避免频繁触发
|
||||
// panel.MouseMove += (s, e) => Panel_MouseEnter(s, e);
|
||||
// icon.MouseMove += (s, e) => Panel_MouseEnter(s, e);
|
||||
// label.MouseMove += (s, e) => Panel_MouseEnter(s, e);
|
||||
|
||||
// 添加鼠标点击效果
|
||||
panel.MouseDown += Panel_MouseDown;
|
||||
panel.MouseUp += Panel_MouseUp;
|
||||
@ -713,104 +1203,68 @@ namespace QuickLauncher
|
||||
// 鼠标进入面板时的效果
|
||||
private void Panel_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is Control control)
|
||||
if (sender is Control control && control.Parent is RoundedPanel panel)
|
||||
{
|
||||
// 获取父面板
|
||||
Panel panel = control as Panel;
|
||||
if (panel == null && control.Parent is Panel)
|
||||
{
|
||||
panel = control.Parent as Panel;
|
||||
}
|
||||
|
||||
if (panel != null)
|
||||
{
|
||||
// 高亮显示
|
||||
panel.BackColor = Color.FromArgb(230, 230, 255); // 浅蓝色背景
|
||||
panel.BorderStyle = BorderStyle.FixedSingle; // 显示边框
|
||||
// 应用悬停效果
|
||||
panel.BackColor = isDarkMode ? Color.FromArgb(70, 70, 70) : Color.FromArgb(230, 230, 230);
|
||||
|
||||
// 显示工具提示
|
||||
if (panel.Tag is ShortcutItem item)
|
||||
{
|
||||
string tipText = $"名称: {item.Name}\n路径: {item.Path}\n双击启动";
|
||||
|
||||
// 为当前控件设置工具提示
|
||||
if (control is PictureBox || control is Label)
|
||||
toolTip1.SetToolTip(panel, $"名称: {item.Name}\n路径: {item.Path}\n添加时间: {item.DateAdded.ToString("yyyy-MM-dd")}\n使用次数: {item.UsageCount}");
|
||||
toolTip1.SetToolTip(control, $"名称: {item.Name}\n路径: {item.Path}\n添加时间: {item.DateAdded.ToString("yyyy-MM-dd")}\n使用次数: {item.UsageCount}");
|
||||
}
|
||||
}
|
||||
else if (sender is RoundedPanel directPanel && directPanel.Tag is ShortcutItem directItem)
|
||||
{
|
||||
toolTip1.SetToolTip(control, tipText);
|
||||
}
|
||||
else
|
||||
{
|
||||
toolTip1.SetToolTip(panel, tipText);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 直接是面板的情况
|
||||
directPanel.BackColor = isDarkMode ? Color.FromArgb(70, 70, 70) : Color.FromArgb(230, 230, 230);
|
||||
toolTip1.SetToolTip(directPanel, $"名称: {directItem.Name}\n路径: {directItem.Path}\n添加时间: {directItem.DateAdded.ToString("yyyy-MM-dd")}\n使用次数: {directItem.UsageCount}");
|
||||
}
|
||||
}
|
||||
|
||||
// 鼠标离开面板时的效果
|
||||
private void Panel_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is Control control)
|
||||
if (sender is Control control && control.Parent is RoundedPanel panel)
|
||||
{
|
||||
// 获取父面板
|
||||
Panel panel = control as Panel;
|
||||
if (panel == null && control.Parent is Panel)
|
||||
{
|
||||
panel = control.Parent as Panel;
|
||||
// 恢复正常颜色
|
||||
panel.BackColor = isDarkMode ? Color.FromArgb(50, 50, 50) : Color.FromArgb(245, 245, 245);
|
||||
}
|
||||
|
||||
if (panel != null)
|
||||
else if (sender is RoundedPanel directPanel)
|
||||
{
|
||||
// 恢复正常显示
|
||||
panel.BackColor = Color.Transparent;
|
||||
panel.BorderStyle = BorderStyle.None;
|
||||
}
|
||||
// 直接是面板的情况
|
||||
directPanel.BackColor = isDarkMode ? Color.FromArgb(50, 50, 50) : Color.FromArgb(245, 245, 245);
|
||||
}
|
||||
}
|
||||
|
||||
// 鼠标按下时的效果
|
||||
private void Panel_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left) // 只对左键点击响应
|
||||
if (sender is Control control && control.Parent is RoundedPanel panel)
|
||||
{
|
||||
if (sender is Control control)
|
||||
{
|
||||
// 获取父面板
|
||||
Panel panel = control as Panel;
|
||||
if (panel == null && control.Parent is Panel)
|
||||
{
|
||||
panel = control.Parent as Panel;
|
||||
// 应用按下效果
|
||||
panel.BackColor = isDarkMode ? Color.FromArgb(90, 90, 90) : Color.FromArgb(210, 210, 210);
|
||||
}
|
||||
|
||||
if (panel != null)
|
||||
else if (sender is RoundedPanel directPanel)
|
||||
{
|
||||
// 点击效果 - 深色背景
|
||||
panel.BackColor = Color.FromArgb(180, 180, 240); // 更深的蓝色
|
||||
}
|
||||
}
|
||||
// 直接是面板的情况
|
||||
directPanel.BackColor = isDarkMode ? Color.FromArgb(90, 90, 90) : Color.FromArgb(210, 210, 210);
|
||||
}
|
||||
}
|
||||
|
||||
// 鼠标释放时的效果
|
||||
private void Panel_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left) // 只对左键点击响应
|
||||
if (sender is Control control && control.Parent is RoundedPanel panel)
|
||||
{
|
||||
if (sender is Control control)
|
||||
{
|
||||
// 获取父面板
|
||||
Panel panel = control as Panel;
|
||||
if (panel == null && control.Parent is Panel)
|
||||
{
|
||||
panel = control.Parent as Panel;
|
||||
// 恢复悬停颜色
|
||||
panel.BackColor = isDarkMode ? Color.FromArgb(70, 70, 70) : Color.FromArgb(230, 230, 230);
|
||||
}
|
||||
|
||||
if (panel != null)
|
||||
else if (sender is RoundedPanel directPanel)
|
||||
{
|
||||
// 恢复悬停效果
|
||||
panel.BackColor = Color.FromArgb(230, 230, 255);
|
||||
}
|
||||
}
|
||||
// 直接是面板的情况
|
||||
directPanel.BackColor = isDarkMode ? Color.FromArgb(70, 70, 70) : Color.FromArgb(230, 230, 230);
|
||||
}
|
||||
}
|
||||
|
||||
@ -960,6 +1414,13 @@ namespace QuickLauncher
|
||||
public DateTime DateAdded { get; set; } = DateTime.Now;
|
||||
public DateTime LastUsed { get; set; } = DateTime.MinValue;
|
||||
public int UsageCount { get; set; } = 0;
|
||||
public string Description { get; set; } = ""; // 添加描述属性
|
||||
public string Arguments { get; set; } = ""; // 添加启动参数
|
||||
public bool RunAsAdmin { get; set; } = false; // 是否以管理员身份运行
|
||||
public string Category { get; set; } = ""; // 所属分类
|
||||
public string CustomIconPath { get; set; } = ""; // 自定义图标路径
|
||||
public string BackgroundColor { get; set; } = ""; // 自定义背景色
|
||||
public int SortOrder { get; set; } = 0; // 排序顺序
|
||||
|
||||
// 用于序列化的构造函数
|
||||
public ShortcutItem()
|
||||
@ -971,6 +1432,25 @@ namespace QuickLauncher
|
||||
{
|
||||
try
|
||||
{
|
||||
// 如果有自定义图标,优先使用自定义图标
|
||||
if (!string.IsNullOrEmpty(CustomIconPath) && File.Exists(CustomIconPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
// 尝试加载自定义图标
|
||||
using (System.Drawing.Icon customIcon = new System.Drawing.Icon(CustomIconPath))
|
||||
{
|
||||
Icon = customIcon.ToBitmap();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 如果自定义图标加载失败,继续使用默认图标
|
||||
}
|
||||
}
|
||||
|
||||
// 使用关联图标
|
||||
if (File.Exists(Path))
|
||||
{
|
||||
using (System.Drawing.Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(Path))
|
||||
@ -995,5 +1475,105 @@ namespace QuickLauncher
|
||||
Icon = SystemIcons.Application.ToBitmap();
|
||||
}
|
||||
}
|
||||
|
||||
// 获取格式化的最后使用时间
|
||||
public string GetFormattedLastUsed()
|
||||
{
|
||||
if (LastUsed == DateTime.MinValue)
|
||||
return "从未使用";
|
||||
|
||||
TimeSpan span = DateTime.Now - LastUsed;
|
||||
|
||||
if (span.TotalDays > 365)
|
||||
return $"{Math.Floor(span.TotalDays / 365)}年前";
|
||||
if (span.TotalDays > 30)
|
||||
return $"{Math.Floor(span.TotalDays / 30)}个月前";
|
||||
if (span.TotalDays > 1)
|
||||
return $"{Math.Floor(span.TotalDays)}天前";
|
||||
if (span.TotalHours > 1)
|
||||
return $"{Math.Floor(span.TotalHours)}小时前";
|
||||
if (span.TotalMinutes > 1)
|
||||
return $"{Math.Floor(span.TotalMinutes)}分钟前";
|
||||
|
||||
return "刚刚";
|
||||
}
|
||||
|
||||
// 获取背景颜色
|
||||
public Color GetBackgroundColor(bool isDarkMode)
|
||||
{
|
||||
// 如果有自定义背景色,尝试解析
|
||||
if (!string.IsNullOrEmpty(BackgroundColor))
|
||||
{
|
||||
try
|
||||
{
|
||||
// 尝试解析颜色字符串,格式为 R,G,B
|
||||
string[] parts = BackgroundColor.Split(',');
|
||||
if (parts.Length == 3 &&
|
||||
int.TryParse(parts[0], out int r) &&
|
||||
int.TryParse(parts[1], out int g) &&
|
||||
int.TryParse(parts[2], out int b))
|
||||
{
|
||||
return Color.FromArgb(r, g, b);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 解析失败,使用默认颜色
|
||||
}
|
||||
}
|
||||
|
||||
// 返回默认颜色
|
||||
return isDarkMode ? Color.FromArgb(50, 50, 50) : Color.FromArgb(245, 245, 245);
|
||||
}
|
||||
}
|
||||
|
||||
// 添加GDI+扩展方法
|
||||
public static class GraphicsExtensions
|
||||
{
|
||||
public static void FillRoundedRectangle(this Graphics graphics, Brush brush, Rectangle bounds, int cornerRadius)
|
||||
{
|
||||
if (graphics == null)
|
||||
throw new ArgumentNullException("graphics");
|
||||
if (brush == null)
|
||||
throw new ArgumentNullException("brush");
|
||||
|
||||
using (GraphicsPath path = CreateRoundedRectangle(bounds, cornerRadius))
|
||||
{
|
||||
graphics.FillPath(brush, path);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawRoundedRectangle(this Graphics graphics, Pen pen, Rectangle bounds, int cornerRadius)
|
||||
{
|
||||
if (graphics == null)
|
||||
throw new ArgumentNullException("graphics");
|
||||
if (pen == null)
|
||||
throw new ArgumentNullException("pen");
|
||||
|
||||
using (GraphicsPath path = CreateRoundedRectangle(bounds, cornerRadius))
|
||||
{
|
||||
graphics.DrawPath(pen, path);
|
||||
}
|
||||
}
|
||||
|
||||
private static GraphicsPath CreateRoundedRectangle(Rectangle bounds, int cornerRadius)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
if (cornerRadius > 0)
|
||||
{
|
||||
path.AddArc(bounds.X, bounds.Y, cornerRadius * 2, cornerRadius * 2, 180, 90);
|
||||
path.AddArc(bounds.Right - cornerRadius * 2, bounds.Y, cornerRadius * 2, cornerRadius * 2, 270, 90);
|
||||
path.AddArc(bounds.Right - cornerRadius * 2, bounds.Bottom - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 0, 90);
|
||||
path.AddArc(bounds.X, bounds.Bottom - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 90, 90);
|
||||
path.CloseFigure();
|
||||
}
|
||||
else
|
||||
{
|
||||
path.AddRectangle(bounds);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -120,6 +120,9 @@
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>25</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace QuickLauncher
|
||||
{
|
||||
internal static class Program
|
||||
@ -5,6 +8,11 @@ namespace QuickLauncher
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// 启用高DPI支持
|
||||
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new MainForm());
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,5 +1,6 @@
|
||||
{
|
||||
"LastSelectedCategory": "\u65B0AZ",
|
||||
"LastSelectedCategory": "\u52A0\u5DE5\u5382\u4E8C\u7EF4\u7801",
|
||||
"SortMode": "UsageCount",
|
||||
"IconSize": 256
|
||||
"IconSize": 192,
|
||||
"LeftPanelWidth": 300
|
||||
}
|
||||
@ -5,28 +5,72 @@
|
||||
"Path": "I:\\Desktop\\Gitea\\4\u3001Game_wow335.lnk",
|
||||
"DateAdded": "2025-03-12T13:58:03.3149744+08:00",
|
||||
"LastUsed": "2025-03-12T13:58:39.6693652+08:00",
|
||||
"UsageCount": 1
|
||||
"UsageCount": 1,
|
||||
"Description": "",
|
||||
"Arguments": "",
|
||||
"RunAsAdmin": false,
|
||||
"Category": "",
|
||||
"CustomIconPath": "",
|
||||
"BackgroundColor": "",
|
||||
"SortOrder": 0
|
||||
},
|
||||
{
|
||||
"Name": "1\u3001AzerothCore.sln",
|
||||
"Path": "I:\\Desktop\\Gitea\\1\u3001AzerothCore.sln.lnk",
|
||||
"DateAdded": "2025-03-12T13:58:03.3249607+08:00",
|
||||
"LastUsed": "0001-01-01T00:00:00",
|
||||
"UsageCount": 0
|
||||
"UsageCount": 0,
|
||||
"Description": "",
|
||||
"Arguments": "",
|
||||
"RunAsAdmin": false,
|
||||
"Category": "",
|
||||
"CustomIconPath": "",
|
||||
"BackgroundColor": "",
|
||||
"SortOrder": 0
|
||||
},
|
||||
{
|
||||
"Name": "2\u3001\u542F\u52A8MYSQL.bat",
|
||||
"Path": "I:\\Desktop\\Gitea\\2\u3001\u542F\u52A8MYSQL.bat.lnk",
|
||||
"DateAdded": "2025-03-12T13:58:03.2453763+08:00",
|
||||
"LastUsed": "0001-01-01T00:00:00",
|
||||
"UsageCount": 0
|
||||
"UsageCount": 0,
|
||||
"Description": "",
|
||||
"Arguments": "",
|
||||
"RunAsAdmin": false,
|
||||
"Category": "",
|
||||
"CustomIconPath": "",
|
||||
"BackgroundColor": "",
|
||||
"SortOrder": 0
|
||||
},
|
||||
{
|
||||
"Name": "3\u3001navicat.exe",
|
||||
"Path": "I:\\Desktop\\Gitea\\3\u3001navicat.exe.lnk",
|
||||
"DateAdded": "2025-03-12T13:58:03.3022567+08:00",
|
||||
"LastUsed": "0001-01-01T00:00:00",
|
||||
"UsageCount": 0
|
||||
"UsageCount": 0,
|
||||
"Description": "",
|
||||
"Arguments": "",
|
||||
"RunAsAdmin": false,
|
||||
"Category": "",
|
||||
"CustomIconPath": "",
|
||||
"BackgroundColor": "",
|
||||
"SortOrder": 0
|
||||
}
|
||||
],
|
||||
"\u52A0\u5DE5\u5382\u4E8C\u7EF4\u7801": [
|
||||
{
|
||||
"Name": "\u4FE1\u8FBE2-\u53EF\u4FE1\u7528\u5361",
|
||||
"Path": "I:\\Desktop\\\u4FE1\u8FBE2-\u53EF\u4FE1\u7528\u5361.png",
|
||||
"DateAdded": "2025-03-12T15:17:11.1548557+08:00",
|
||||
"LastUsed": "2025-03-12T15:17:11.792405+08:00",
|
||||
"UsageCount": 1,
|
||||
"Description": "",
|
||||
"Arguments": "",
|
||||
"RunAsAdmin": false,
|
||||
"Category": "",
|
||||
"CustomIconPath": "",
|
||||
"BackgroundColor": "",
|
||||
"SortOrder": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("QuickLauncher")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+dfabe611babba8844f162e98c8792e2a13520af3")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("QuickLauncher")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("QuickLauncher")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@ -1 +1 @@
|
||||
c6eb8c2f43ebdcdca383a66315f5396dd3847e53f909e5e7ec32d85eac2a583a
|
||||
9cb870a752e15f8ff483883e472772a888ce5f82b77ac18b8bc3f6d8ad6869c1
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user