* UITabControl:Tab页标题选中高亮颜色增加可调整高度

This commit is contained in:
Sunny 2021-06-08 21:47:53 +08:00
parent 67a8f176c0
commit 1d37a896e9
9 changed files with 31 additions and 12 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -52,12 +52,12 @@ namespace Sunny.UI.Demo
private void uiComboTreeView1_NodeSelected(object sender, System.Windows.Forms.TreeNode node) private void uiComboTreeView1_NodeSelected(object sender, System.Windows.Forms.TreeNode node)
{ {
ShowInfoTip(node.Text); //ShowInfoTip(node.Text);
} }
private void uiComboTreeView2_NodesSelected(object sender, System.Windows.Forms.TreeNodeCollection node) private void uiComboTreeView2_NodesSelected(object sender, System.Windows.Forms.TreeNodeCollection node)
{ {
ShowInfoTip(uiComboTreeView2.Text); //ShowInfoTip(uiComboTreeView2.Text);
} }
public class Info public class Info
@ -68,7 +68,7 @@ namespace Sunny.UI.Demo
private void uiComboBox2_SelectedIndexChanged(object sender, EventArgs e) private void uiComboBox2_SelectedIndexChanged(object sender, EventArgs e)
{ {
ShowInfoTip(uiComboBox2.SelectedValue.ToString()); //ShowInfoTip(uiComboBox2.SelectedValue.ToString());
} }
private void uiColorPicker1_Click(object sender, EventArgs e) private void uiColorPicker1_Click(object sender, EventArgs e)

View File

@ -96,7 +96,7 @@
this.tabPage2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); this.tabPage2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
this.tabPage2.Location = new System.Drawing.Point(0, 40); this.tabPage2.Location = new System.Drawing.Point(0, 40);
this.tabPage2.Name = "tabPage2"; this.tabPage2.Name = "tabPage2";
this.tabPage2.Size = new System.Drawing.Size(670, 143); this.tabPage2.Size = new System.Drawing.Size(450, 230);
this.tabPage2.TabIndex = 1; this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "tabPage2"; this.tabPage2.Text = "tabPage2";
// //
@ -105,7 +105,7 @@
this.tabPage3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192))))); this.tabPage3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.tabPage3.Location = new System.Drawing.Point(0, 40); this.tabPage3.Location = new System.Drawing.Point(0, 40);
this.tabPage3.Name = "tabPage3"; this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(670, 143); this.tabPage3.Size = new System.Drawing.Size(450, 230);
this.tabPage3.TabIndex = 2; this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "tabPage3"; this.tabPage3.Text = "tabPage3";
// //
@ -113,7 +113,7 @@
// //
this.tabPage9.Location = new System.Drawing.Point(0, 40); this.tabPage9.Location = new System.Drawing.Point(0, 40);
this.tabPage9.Name = "tabPage9"; this.tabPage9.Name = "tabPage9";
this.tabPage9.Size = new System.Drawing.Size(670, 143); this.tabPage9.Size = new System.Drawing.Size(450, 230);
this.tabPage9.TabIndex = 4; this.tabPage9.TabIndex = 4;
this.tabPage9.Text = "tabPage9"; this.tabPage9.Text = "tabPage9";
this.tabPage9.UseVisualStyleBackColor = true; this.tabPage9.UseVisualStyleBackColor = true;
@ -122,7 +122,7 @@
// //
this.tabPage10.Location = new System.Drawing.Point(0, 40); this.tabPage10.Location = new System.Drawing.Point(0, 40);
this.tabPage10.Name = "tabPage10"; this.tabPage10.Name = "tabPage10";
this.tabPage10.Size = new System.Drawing.Size(670, 143); this.tabPage10.Size = new System.Drawing.Size(450, 230);
this.tabPage10.TabIndex = 5; this.tabPage10.TabIndex = 5;
this.tabPage10.Text = "tabPage10"; this.tabPage10.Text = "tabPage10";
this.tabPage10.UseVisualStyleBackColor = true; this.tabPage10.UseVisualStyleBackColor = true;
@ -131,7 +131,7 @@
// //
this.tabPage11.Location = new System.Drawing.Point(0, 40); this.tabPage11.Location = new System.Drawing.Point(0, 40);
this.tabPage11.Name = "tabPage11"; this.tabPage11.Name = "tabPage11";
this.tabPage11.Size = new System.Drawing.Size(670, 143); this.tabPage11.Size = new System.Drawing.Size(450, 230);
this.tabPage11.TabIndex = 6; this.tabPage11.TabIndex = 6;
this.tabPage11.Text = "tabPage11"; this.tabPage11.Text = "tabPage11";
this.tabPage11.UseVisualStyleBackColor = true; this.tabPage11.UseVisualStyleBackColor = true;
@ -140,7 +140,7 @@
// //
this.tabPage12.Location = new System.Drawing.Point(0, 40); this.tabPage12.Location = new System.Drawing.Point(0, 40);
this.tabPage12.Name = "tabPage12"; this.tabPage12.Name = "tabPage12";
this.tabPage12.Size = new System.Drawing.Size(670, 143); this.tabPage12.Size = new System.Drawing.Size(450, 230);
this.tabPage12.TabIndex = 7; this.tabPage12.TabIndex = 7;
this.tabPage12.Text = "tabPage12"; this.tabPage12.Text = "tabPage12";
this.tabPage12.UseVisualStyleBackColor = true; this.tabPage12.UseVisualStyleBackColor = true;
@ -149,7 +149,7 @@
// //
this.tabPage13.Location = new System.Drawing.Point(0, 40); this.tabPage13.Location = new System.Drawing.Point(0, 40);
this.tabPage13.Name = "tabPage13"; this.tabPage13.Name = "tabPage13";
this.tabPage13.Size = new System.Drawing.Size(670, 143); this.tabPage13.Size = new System.Drawing.Size(450, 230);
this.tabPage13.TabIndex = 8; this.tabPage13.TabIndex = 8;
this.tabPage13.Text = "tabPage13"; this.tabPage13.Text = "tabPage13";
this.tabPage13.UseVisualStyleBackColor = true; this.tabPage13.UseVisualStyleBackColor = true;
@ -241,7 +241,6 @@
// //
// FTabControl // FTabControl
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(800, 654); this.ClientSize = new System.Drawing.Size(800, 654);
this.Name = "FTabControl"; this.Name = "FTabControl";

View File

@ -292,6 +292,24 @@ namespace Sunny.UI
} }
} }
private int tabSelectedHighColorSize = 4;
/// <summary>
/// 边框颜色
/// </summary>
[Description("选中Tab页高亮高度"), Category("SunnyUI")]
[DefaultValue(4)]
public int TabSelectedHighColorSize
{
get => tabSelectedHighColorSize;
set
{
tabSelectedHighColorSize = Math.Max(value, 0);
Invalidate();
}
}
private UIStyle _style = UIStyle.Blue; private UIStyle _style = UIStyle.Blue;
/// <summary> /// <summary>
@ -439,7 +457,9 @@ namespace Sunny.UI
if (index == SelectedIndex) if (index == SelectedIndex)
{ {
g.Clear(TabSelectedColor); g.Clear(TabSelectedColor);
g.FillRectangle(TabSelectedHighColor, 0, bmp.Height - 4, bmp.Width, 4);
if (TabSelectedHighColorSize > 0)
g.FillRectangle(TabSelectedHighColor, 0, bmp.Height - TabSelectedHighColorSize, bmp.Width, TabSelectedHighColorSize);
} }
g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, TabRect.Top + 2 + (TabRect.Height - sf.Height - 4) / 2.0f); g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, TabRect.Top + 2 + (TabRect.Height - sf.Height - 4) / 2.0f);