Compare commits
3 Commits
60db9fd0c2
...
ae8c1b0c6a
| Author | SHA1 | Date | |
|---|---|---|---|
| ae8c1b0c6a | |||
| 8d3725f9be | |||
| 9f093425dd |
32
MainForm.Designer.cs
generated
32
MainForm.Designer.cs
generated
@ -33,6 +33,7 @@ namespace QuickLauncher
|
||||
rightPanel = new Panel();
|
||||
shortcutsPanel = new FlowLayoutPanel();
|
||||
toolPanel = new Panel();
|
||||
button1 = new Button();
|
||||
addButton = new Button();
|
||||
categoryLabel = new Label();
|
||||
menuStrip = new MenuStrip();
|
||||
@ -52,7 +53,7 @@ namespace QuickLauncher
|
||||
leftPanel.Location = new Point(0, 36);
|
||||
leftPanel.Margin = new Padding(6);
|
||||
leftPanel.Name = "leftPanel";
|
||||
leftPanel.Size = new Size(300, 1164);
|
||||
leftPanel.Size = new Size(297, 669);
|
||||
leftPanel.TabIndex = 0;
|
||||
//
|
||||
// rightPanel
|
||||
@ -61,10 +62,10 @@ namespace QuickLauncher
|
||||
rightPanel.Controls.Add(shortcutsPanel);
|
||||
rightPanel.Controls.Add(toolPanel);
|
||||
rightPanel.Dock = DockStyle.Fill;
|
||||
rightPanel.Location = new Point(300, 36);
|
||||
rightPanel.Location = new Point(297, 36);
|
||||
rightPanel.Margin = new Padding(6);
|
||||
rightPanel.Name = "rightPanel";
|
||||
rightPanel.Size = new Size(1167, 1164);
|
||||
rightPanel.Size = new Size(872, 669);
|
||||
rightPanel.TabIndex = 1;
|
||||
//
|
||||
// shortcutsPanel
|
||||
@ -77,12 +78,13 @@ namespace QuickLauncher
|
||||
shortcutsPanel.Margin = new Padding(6);
|
||||
shortcutsPanel.Name = "shortcutsPanel";
|
||||
shortcutsPanel.Padding = new Padding(20);
|
||||
shortcutsPanel.Size = new Size(1167, 1084);
|
||||
shortcutsPanel.Size = new Size(872, 589);
|
||||
shortcutsPanel.TabIndex = 1;
|
||||
//
|
||||
// toolPanel
|
||||
//
|
||||
toolPanel.BackColor = Color.FromArgb(230, 230, 230);
|
||||
toolPanel.Controls.Add(button1);
|
||||
toolPanel.Controls.Add(addButton);
|
||||
toolPanel.Controls.Add(categoryLabel);
|
||||
toolPanel.Dock = DockStyle.Top;
|
||||
@ -90,9 +92,24 @@ namespace QuickLauncher
|
||||
toolPanel.Margin = new Padding(6);
|
||||
toolPanel.Name = "toolPanel";
|
||||
toolPanel.Padding = new Padding(15, 10, 15, 10);
|
||||
toolPanel.Size = new Size(1167, 80);
|
||||
toolPanel.Size = new Size(872, 80);
|
||||
toolPanel.TabIndex = 0;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button1.BackColor = Color.FromArgb(0, 120, 212);
|
||||
button1.FlatStyle = FlatStyle.Flat;
|
||||
button1.ForeColor = Color.White;
|
||||
button1.Location = new Point(744, 16);
|
||||
button1.Margin = new Padding(6);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(107, 39);
|
||||
button1.TabIndex = 2;
|
||||
button1.Text = "切换主题";
|
||||
button1.UseVisualStyleBackColor = false;
|
||||
button1.Click += button1_Click;
|
||||
//
|
||||
// addButton
|
||||
//
|
||||
addButton.BackColor = Color.FromArgb(0, 120, 212);
|
||||
@ -125,7 +142,7 @@ namespace QuickLauncher
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Padding = new Padding(11, 4, 0, 4);
|
||||
menuStrip.Size = new Size(1467, 36);
|
||||
menuStrip.Size = new Size(1169, 36);
|
||||
menuStrip.TabIndex = 2;
|
||||
//
|
||||
// fileMenu
|
||||
@ -153,7 +170,7 @@ namespace QuickLauncher
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(11F, 24F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1467, 1200);
|
||||
ClientSize = new Size(1169, 705);
|
||||
Controls.Add(rightPanel);
|
||||
Controls.Add(leftPanel);
|
||||
Controls.Add(menuStrip);
|
||||
@ -184,5 +201,6 @@ namespace QuickLauncher
|
||||
private System.Windows.Forms.ToolStripMenuItem fileMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem addCategoryItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem deleteCategoryItem;
|
||||
private Button button1;
|
||||
}
|
||||
}
|
||||
46
MainForm.cs
46
MainForm.cs
@ -1176,21 +1176,39 @@ namespace QuickLauncher
|
||||
Cursor = Cursors.Hand
|
||||
};
|
||||
|
||||
var label = new Label
|
||||
{
|
||||
Text = item.Name,
|
||||
AutoSize = false,
|
||||
TextAlign = ContentAlignment.MiddleCenter,
|
||||
Width = panel.Width,
|
||||
Height = 30,
|
||||
Location = new Point(0, iconSize + 10),
|
||||
Tag = item,
|
||||
Cursor = Cursors.Hand,
|
||||
ForeColor = isDarkMode ? Color.FromArgb(240, 240, 240) : Color.FromArgb(20, 20, 20)
|
||||
};
|
||||
// 创建一个新的文本框控件实例
|
||||
var label = new TextBox();
|
||||
|
||||
panel.Controls.Add(icon);
|
||||
panel.Controls.Add(label);
|
||||
// 计算文本所需的高度
|
||||
// TextRenderer.MeasureText: 测量指定文本在给定条件下需要的尺寸
|
||||
// item.Name: 要显示的文本内容
|
||||
// new Font(): 创建微软雅黑8号字体
|
||||
// new Size(panel.Width, 0): 指定宽度限制,高度不限
|
||||
// TextFormatFlags.WordBreak: 允许在单词间换行
|
||||
// TextFormatFlags.TextBoxControl: 使用文本框的文本渲染规则
|
||||
// .Height + 10: 获取计算出的高度并额外添加10像素的边距
|
||||
var textHeight = TextRenderer.MeasureText(item.Name, new Font("Microsoft YaHei", 8), new Size(panel.Width, 0), TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl).Height+10;
|
||||
|
||||
label.Text = item.Name; // 设置显示的文本内容
|
||||
label.AutoSize = false; // 禁用自动尺寸调整
|
||||
label.TextAlign = HorizontalAlignment.Center; // 文本水平居中对齐
|
||||
label.MinimumSize = new Size(panel.Width, 30); // 设置最小尺寸
|
||||
label.MaximumSize = new Size(panelWidth, 0); // 设置最大宽度,高度不限
|
||||
label.Location = new Point(0, iconSize + 20); // 设置位置(在图标下方10像素)
|
||||
label.Tag = item; // 存储关联的数据项
|
||||
label.Cursor = Cursors.Hand; // 鼠标悬停时显示手型光标
|
||||
label.ForeColor = isDarkMode ? Color.FromArgb(240, 240, 240) : Color.FromArgb(20, 20, 20); // 根据暗/亮模式设置文字颜色
|
||||
label.Padding = new Padding(0); // 设置内边距为2像素
|
||||
label.Font = new Font("Microsoft YaHei", 8); // 设置字体为微软雅黑8号
|
||||
label.Multiline = true; // 启用多行显示
|
||||
label.ReadOnly = true; // 设置为只读,防止编辑
|
||||
label.BorderStyle = BorderStyle.None; // 移除边框
|
||||
label.BackColor = panel.BackColor; // 背景色与面板一致
|
||||
label.Height = textHeight; // 应用计算出的高度
|
||||
|
||||
// 将图标和文本框添加到面板中
|
||||
panel.Controls.Add(icon); // 添加图标控件
|
||||
panel.Controls.Add(label); // 添加文本框控件
|
||||
|
||||
// 设置右键菜单
|
||||
panel.ContextMenuStrip = shortcutItemContextMenu;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user