* UITrackBar:增加垂直显示方式
This commit is contained in:
parent
f77ba7c2d5
commit
e7ca29925e
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
135
SunnyUI.Demo/Controls/FProcess.designer.cs
generated
135
SunnyUI.Demo/Controls/FProcess.designer.cs
generated
@ -45,11 +45,25 @@ namespace Sunny.UI.Demo
|
||||
this.uiProcessBar1 = new Sunny.UI.UIProcessBar();
|
||||
this.uiLine2 = new Sunny.UI.UILine();
|
||||
this.timer1 = new System.Windows.Forms.Timer(this.components);
|
||||
this.uiTrackBar2 = new Sunny.UI.UITrackBar();
|
||||
this.uiTrackBar3 = new Sunny.UI.UITrackBar();
|
||||
this.uiTrackBar4 = new Sunny.UI.UITrackBar();
|
||||
this.uiTrackBar5 = new Sunny.UI.UITrackBar();
|
||||
this.uiTrackBar6 = new Sunny.UI.UITrackBar();
|
||||
this.uiTrackBar7 = new Sunny.UI.UITrackBar();
|
||||
this.uiTrackBar8 = new Sunny.UI.UITrackBar();
|
||||
this.PagePanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// PagePanel
|
||||
//
|
||||
this.PagePanel.Controls.Add(this.uiTrackBar8);
|
||||
this.PagePanel.Controls.Add(this.uiTrackBar7);
|
||||
this.PagePanel.Controls.Add(this.uiTrackBar6);
|
||||
this.PagePanel.Controls.Add(this.uiTrackBar5);
|
||||
this.PagePanel.Controls.Add(this.uiTrackBar4);
|
||||
this.PagePanel.Controls.Add(this.uiTrackBar3);
|
||||
this.PagePanel.Controls.Add(this.uiTrackBar2);
|
||||
this.PagePanel.Controls.Add(this.uiLine2);
|
||||
this.PagePanel.Controls.Add(this.uiBreadcrumb1);
|
||||
this.PagePanel.Controls.Add(this.uiRoundProcess2);
|
||||
@ -77,10 +91,10 @@ namespace Sunny.UI.Demo
|
||||
"步骤四",
|
||||
"步骤五"});
|
||||
this.uiBreadcrumb1.ItemWidth = 100;
|
||||
this.uiBreadcrumb1.Location = new System.Drawing.Point(30, 372);
|
||||
this.uiBreadcrumb1.Location = new System.Drawing.Point(29, 290);
|
||||
this.uiBreadcrumb1.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiBreadcrumb1.Name = "uiBreadcrumb1";
|
||||
this.uiBreadcrumb1.Size = new System.Drawing.Size(588, 29);
|
||||
this.uiBreadcrumb1.Size = new System.Drawing.Size(440, 25);
|
||||
this.uiBreadcrumb1.TabIndex = 73;
|
||||
this.uiBreadcrumb1.Text = "uiBreadcrumb1";
|
||||
//
|
||||
@ -90,7 +104,7 @@ namespace Sunny.UI.Demo
|
||||
this.uiRoundProcess2.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiRoundProcess2.ForeColor = System.Drawing.Color.White;
|
||||
this.uiRoundProcess2.Inner = 0;
|
||||
this.uiRoundProcess2.Location = new System.Drawing.Point(155, 138);
|
||||
this.uiRoundProcess2.Location = new System.Drawing.Point(155, 132);
|
||||
this.uiRoundProcess2.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiRoundProcess2.Name = "uiRoundProcess2";
|
||||
this.uiRoundProcess2.ShowProcess = true;
|
||||
@ -115,7 +129,7 @@ namespace Sunny.UI.Demo
|
||||
//
|
||||
this.uiRoundProcess1.BackColor = System.Drawing.Color.Transparent;
|
||||
this.uiRoundProcess1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiRoundProcess1.Location = new System.Drawing.Point(28, 138);
|
||||
this.uiRoundProcess1.Location = new System.Drawing.Point(28, 132);
|
||||
this.uiRoundProcess1.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiRoundProcess1.Name = "uiRoundProcess1";
|
||||
this.uiRoundProcess1.ShowProcess = true;
|
||||
@ -158,25 +172,25 @@ namespace Sunny.UI.Demo
|
||||
// uiLine5
|
||||
//
|
||||
this.uiLine5.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiLine5.Location = new System.Drawing.Point(30, 264);
|
||||
this.uiLine5.Location = new System.Drawing.Point(28, 334);
|
||||
this.uiLine5.MinimumSize = new System.Drawing.Size(16, 16);
|
||||
this.uiLine5.Name = "uiLine5";
|
||||
this.uiLine5.Size = new System.Drawing.Size(319, 20);
|
||||
this.uiLine5.Size = new System.Drawing.Size(672, 20);
|
||||
this.uiLine5.TabIndex = 66;
|
||||
this.uiLine5.Text = "UITrackBar";
|
||||
this.uiLine5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// uiTrackBar1
|
||||
//
|
||||
this.uiTrackBar1.BarSize = 20;
|
||||
this.uiTrackBar1.DisableColor = System.Drawing.Color.Silver;
|
||||
this.uiTrackBar1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiTrackBar1.Location = new System.Drawing.Point(30, 290);
|
||||
this.uiTrackBar1.Location = new System.Drawing.Point(28, 360);
|
||||
this.uiTrackBar1.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiTrackBar1.Name = "uiTrackBar1";
|
||||
this.uiTrackBar1.Size = new System.Drawing.Size(158, 29);
|
||||
this.uiTrackBar1.TabIndex = 65;
|
||||
this.uiTrackBar1.Text = "uiTrackBar1";
|
||||
this.uiTrackBar1.Value = 50;
|
||||
//
|
||||
// uiLine4
|
||||
//
|
||||
@ -192,7 +206,7 @@ namespace Sunny.UI.Demo
|
||||
// uiProgressIndicator1
|
||||
//
|
||||
this.uiProgressIndicator1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiProgressIndicator1.Location = new System.Drawing.Point(381, 138);
|
||||
this.uiProgressIndicator1.Location = new System.Drawing.Point(381, 132);
|
||||
this.uiProgressIndicator1.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiProgressIndicator1.Name = "uiProgressIndicator1";
|
||||
this.uiProgressIndicator1.Size = new System.Drawing.Size(120, 120);
|
||||
@ -224,7 +238,7 @@ namespace Sunny.UI.Demo
|
||||
// uiLine2
|
||||
//
|
||||
this.uiLine2.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiLine2.Location = new System.Drawing.Point(30, 334);
|
||||
this.uiLine2.Location = new System.Drawing.Point(29, 252);
|
||||
this.uiLine2.MinimumSize = new System.Drawing.Size(16, 16);
|
||||
this.uiLine2.Name = "uiLine2";
|
||||
this.uiLine2.Size = new System.Drawing.Size(319, 20);
|
||||
@ -236,6 +250,100 @@ namespace Sunny.UI.Demo
|
||||
//
|
||||
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
|
||||
//
|
||||
// uiTrackBar2
|
||||
//
|
||||
this.uiTrackBar2.BarSize = 20;
|
||||
this.uiTrackBar2.Direction = Sunny.UI.UITrackBar.BarDirection.Vertical;
|
||||
this.uiTrackBar2.DisableColor = System.Drawing.Color.Silver;
|
||||
this.uiTrackBar2.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiTrackBar2.Location = new System.Drawing.Point(264, 360);
|
||||
this.uiTrackBar2.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiTrackBar2.Name = "uiTrackBar2";
|
||||
this.uiTrackBar2.Size = new System.Drawing.Size(35, 99);
|
||||
this.uiTrackBar2.TabIndex = 75;
|
||||
this.uiTrackBar2.Text = "uiTrackBar2";
|
||||
this.uiTrackBar2.Value = 50;
|
||||
//
|
||||
// uiTrackBar3
|
||||
//
|
||||
this.uiTrackBar3.BarSize = 20;
|
||||
this.uiTrackBar3.DisableColor = System.Drawing.Color.Silver;
|
||||
this.uiTrackBar3.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiTrackBar3.Location = new System.Drawing.Point(28, 395);
|
||||
this.uiTrackBar3.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiTrackBar3.Name = "uiTrackBar3";
|
||||
this.uiTrackBar3.Size = new System.Drawing.Size(158, 29);
|
||||
this.uiTrackBar3.TabIndex = 76;
|
||||
this.uiTrackBar3.Text = "uiTrackBar3";
|
||||
//
|
||||
// uiTrackBar4
|
||||
//
|
||||
this.uiTrackBar4.BarSize = 20;
|
||||
this.uiTrackBar4.DisableColor = System.Drawing.Color.Silver;
|
||||
this.uiTrackBar4.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiTrackBar4.Location = new System.Drawing.Point(28, 430);
|
||||
this.uiTrackBar4.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiTrackBar4.Name = "uiTrackBar4";
|
||||
this.uiTrackBar4.Size = new System.Drawing.Size(158, 29);
|
||||
this.uiTrackBar4.TabIndex = 77;
|
||||
this.uiTrackBar4.Text = "uiTrackBar4";
|
||||
//
|
||||
// uiTrackBar5
|
||||
//
|
||||
this.uiTrackBar5.BarSize = 20;
|
||||
this.uiTrackBar5.Direction = Sunny.UI.UITrackBar.BarDirection.Vertical;
|
||||
this.uiTrackBar5.DisableColor = System.Drawing.Color.Silver;
|
||||
this.uiTrackBar5.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiTrackBar5.Location = new System.Drawing.Point(305, 360);
|
||||
this.uiTrackBar5.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiTrackBar5.Name = "uiTrackBar5";
|
||||
this.uiTrackBar5.Size = new System.Drawing.Size(35, 99);
|
||||
this.uiTrackBar5.TabIndex = 78;
|
||||
this.uiTrackBar5.Text = "uiTrackBar5";
|
||||
this.uiTrackBar5.Value = 50;
|
||||
//
|
||||
// uiTrackBar6
|
||||
//
|
||||
this.uiTrackBar6.BarSize = 20;
|
||||
this.uiTrackBar6.Direction = Sunny.UI.UITrackBar.BarDirection.Vertical;
|
||||
this.uiTrackBar6.DisableColor = System.Drawing.Color.Silver;
|
||||
this.uiTrackBar6.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiTrackBar6.Location = new System.Drawing.Point(346, 360);
|
||||
this.uiTrackBar6.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiTrackBar6.Name = "uiTrackBar6";
|
||||
this.uiTrackBar6.Size = new System.Drawing.Size(35, 99);
|
||||
this.uiTrackBar6.TabIndex = 79;
|
||||
this.uiTrackBar6.Text = "uiTrackBar6";
|
||||
this.uiTrackBar6.Value = 50;
|
||||
//
|
||||
// uiTrackBar7
|
||||
//
|
||||
this.uiTrackBar7.BarSize = 20;
|
||||
this.uiTrackBar7.Direction = Sunny.UI.UITrackBar.BarDirection.Vertical;
|
||||
this.uiTrackBar7.DisableColor = System.Drawing.Color.Silver;
|
||||
this.uiTrackBar7.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiTrackBar7.Location = new System.Drawing.Point(387, 360);
|
||||
this.uiTrackBar7.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiTrackBar7.Name = "uiTrackBar7";
|
||||
this.uiTrackBar7.Size = new System.Drawing.Size(35, 99);
|
||||
this.uiTrackBar7.TabIndex = 80;
|
||||
this.uiTrackBar7.Text = "uiTrackBar7";
|
||||
this.uiTrackBar7.Value = 50;
|
||||
//
|
||||
// uiTrackBar8
|
||||
//
|
||||
this.uiTrackBar8.BarSize = 20;
|
||||
this.uiTrackBar8.Direction = Sunny.UI.UITrackBar.BarDirection.Vertical;
|
||||
this.uiTrackBar8.DisableColor = System.Drawing.Color.Silver;
|
||||
this.uiTrackBar8.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiTrackBar8.Location = new System.Drawing.Point(428, 360);
|
||||
this.uiTrackBar8.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiTrackBar8.Name = "uiTrackBar8";
|
||||
this.uiTrackBar8.Size = new System.Drawing.Size(35, 99);
|
||||
this.uiTrackBar8.TabIndex = 81;
|
||||
this.uiTrackBar8.Text = "uiTrackBar8";
|
||||
this.uiTrackBar8.Value = 50;
|
||||
//
|
||||
// FProcess
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
|
||||
@ -266,5 +374,12 @@ namespace Sunny.UI.Demo
|
||||
private UIProcessBar uiProcessBar1;
|
||||
private UILine uiLine2;
|
||||
private System.Windows.Forms.Timer timer1;
|
||||
private UITrackBar uiTrackBar2;
|
||||
private UITrackBar uiTrackBar8;
|
||||
private UITrackBar uiTrackBar7;
|
||||
private UITrackBar uiTrackBar6;
|
||||
private UITrackBar uiTrackBar5;
|
||||
private UITrackBar uiTrackBar4;
|
||||
private UITrackBar uiTrackBar3;
|
||||
}
|
||||
}
|
@ -47,6 +47,34 @@ namespace Sunny.UI
|
||||
rectColor = UIColor.Blue;
|
||||
}
|
||||
|
||||
public enum BarDirection
|
||||
{
|
||||
/// <summary>
|
||||
/// 水平的
|
||||
/// </summary>
|
||||
Horizontal,
|
||||
|
||||
/// <summary>
|
||||
/// 竖直的
|
||||
/// </summary>
|
||||
Vertical
|
||||
}
|
||||
|
||||
private BarDirection direction = BarDirection.Horizontal;
|
||||
|
||||
[DefaultValue(BarDirection.Horizontal)]
|
||||
[Description("线条方向"), Category("SunnyUI")]
|
||||
public BarDirection Direction
|
||||
{
|
||||
get => direction;
|
||||
set
|
||||
{
|
||||
direction = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int _maximum = 100;
|
||||
private int _minimum;
|
||||
private int trackBarValue;
|
||||
@ -118,21 +146,65 @@ namespace Sunny.UI
|
||||
protected override void OnPaintFill(Graphics g, GraphicsPath path)
|
||||
{
|
||||
g.Clear(fillColor);
|
||||
g.FillRoundRectangle(rectDisableColor, new Rectangle(5, Height / 2 - 3, Width - 1 - 10, 6), 6);
|
||||
|
||||
int len = (int)((Value - Minimum) * 1.0 * (Width - 1 - 10) / (Maximum - Minimum));
|
||||
if (len > 0)
|
||||
if (Direction == BarDirection.Horizontal)
|
||||
{
|
||||
g.FillRoundRectangle(foreColor, new Rectangle(5, Height / 2 - 3, len, 6), 6);
|
||||
g.FillRoundRectangle(rectDisableColor,
|
||||
new Rectangle(5, Height / 2 - 3, Width - 1 - 10, 6), 6);
|
||||
|
||||
int len = (int)((Value - Minimum) * 1.0 * (Width - 1 - 10) / (Maximum - Minimum));
|
||||
if (len > 0)
|
||||
{
|
||||
g.FillRoundRectangle(foreColor, new Rectangle(5, Height / 2 - 3, len, 6), 6);
|
||||
}
|
||||
|
||||
g.FillRoundRectangle(fillColor.IsValid() ? fillColor : Color.White,
|
||||
new Rectangle(len, (Height - BarSize) / 2, 10, BarSize), 5);
|
||||
|
||||
using (Pen pen = new Pen(rectColor, 2))
|
||||
{
|
||||
g.SetHighQuality();
|
||||
g.DrawRoundRectangle(pen,
|
||||
new Rectangle(len + 1, (Height - BarSize) / 2 + 1, 8, BarSize - 2), 5);
|
||||
g.SetDefaultQuality();
|
||||
}
|
||||
}
|
||||
|
||||
g.FillRoundRectangle(fillColor.IsValid() ? fillColor : Color.White, new Rectangle(len, Height / 2 - 10, 10, 20), 5);
|
||||
|
||||
using (Pen pen = new Pen(rectColor, 2))
|
||||
if (Direction == BarDirection.Vertical)
|
||||
{
|
||||
g.SetHighQuality();
|
||||
g.DrawRoundRectangle(pen, new Rectangle(len + 1, Height / 2 - 9, 8, 18), 5);
|
||||
g.SetDefaultQuality();
|
||||
g.FillRoundRectangle(rectDisableColor,
|
||||
new Rectangle(Width / 2 - 3, 5, 6, Height - 1 - 10), 6);
|
||||
|
||||
int len = (int)((Value - Minimum) * 1.0 * (Height - 1 - 10) / (Maximum - Minimum));
|
||||
if (len > 0)
|
||||
{
|
||||
g.FillRoundRectangle(foreColor, new Rectangle(Width / 2 - 3, Height - len - 5, 6, len), 6);
|
||||
}
|
||||
|
||||
g.FillRoundRectangle(fillColor.IsValid() ? fillColor : Color.White,
|
||||
new Rectangle((Width - BarSize) / 2, Height - len - 10 - 1, BarSize, 10), 5);
|
||||
|
||||
using (Pen pen = new Pen(rectColor, 2))
|
||||
{
|
||||
g.SetHighQuality();
|
||||
g.DrawRoundRectangle(pen,
|
||||
new Rectangle((Width - BarSize) / 2 + 1, Height - len - 10, BarSize - 2, 8), 5);
|
||||
g.SetDefaultQuality();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int trackBarSize = 20;
|
||||
|
||||
[DefaultValue(20)]
|
||||
[Description("按钮大小"), Category("SunnyUI")]
|
||||
public int BarSize
|
||||
{
|
||||
get => trackBarSize;
|
||||
set
|
||||
{
|
||||
trackBarSize = Math.Max(12, value);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,9 +213,19 @@ namespace Sunny.UI
|
||||
base.OnMouseClick(e);
|
||||
if (!ReadOnly)
|
||||
{
|
||||
int len = e.X - 5;
|
||||
int value = (len * 1.0 * (Maximum - Minimum) / (Width - 1 - 10)).RoundEx() + Minimum;
|
||||
Value = Math.Min(Math.Max(Minimum, value), Maximum);
|
||||
if (Direction == BarDirection.Horizontal)
|
||||
{
|
||||
int len = e.X - 5;
|
||||
int value = (len * 1.0 * (Maximum - Minimum) / (Width - 10)).RoundEx() + Minimum;
|
||||
Value = Math.Min(Math.Max(Minimum, value), Maximum);
|
||||
}
|
||||
|
||||
if (Direction == BarDirection.Vertical)
|
||||
{
|
||||
int len = Height - 10 - e.Y;
|
||||
int value = (len * 1.0 * (Maximum - Minimum) / (Height - 10)).RoundEx() + Minimum;
|
||||
Value = Math.Min(Math.Max(Minimum, value), Maximum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,9 +234,19 @@ namespace Sunny.UI
|
||||
base.OnMouseMove(e);
|
||||
if (IsPress && !ReadOnly)
|
||||
{
|
||||
int len = e.X - 5;
|
||||
int value = (len * 1.0 * (Maximum - Minimum) / (Width - 1 - 10)).RoundEx() + Minimum;
|
||||
Value = Math.Min(Math.Max(Minimum, value), Maximum);
|
||||
if (Direction == BarDirection.Horizontal)
|
||||
{
|
||||
int len = e.X - 5;
|
||||
int value = (len * 1.0 * (Maximum - Minimum) / (Width - 10)).RoundEx() + Minimum;
|
||||
Value = Math.Min(Math.Max(Minimum, value), Maximum);
|
||||
}
|
||||
|
||||
if (Direction == BarDirection.Vertical)
|
||||
{
|
||||
int len = Height - 10 - e.Y;
|
||||
int value = (len * 1.0 * (Maximum - Minimum) / (Height - 10)).RoundEx() + Minimum;
|
||||
Value = Math.Min(Math.Max(Minimum, value), Maximum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user