+ UIRoundProcess:圆形滚动条
This commit is contained in:
parent
74fcc672f2
commit
b7e4eb6a44
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6
SunnyUI.Demo/Controls/FLabel.Designer.cs
generated
6
SunnyUI.Demo/Controls/FLabel.Designer.cs
generated
@ -57,6 +57,7 @@
|
||||
this.PagePanel.Controls.Add(this.uiLine1);
|
||||
this.PagePanel.Controls.Add(this.uiLinkLabel1);
|
||||
this.PagePanel.Controls.Add(this.uiLabel1);
|
||||
this.PagePanel.Size = new System.Drawing.Size(800, 415);
|
||||
//
|
||||
// uiLabel1
|
||||
//
|
||||
@ -154,6 +155,7 @@
|
||||
this.uiMarkLabel1.Size = new System.Drawing.Size(118, 21);
|
||||
this.uiMarkLabel1.TabIndex = 24;
|
||||
this.uiMarkLabel1.Text = "uiMarkLabel1";
|
||||
this.uiMarkLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// uiLine4
|
||||
//
|
||||
@ -177,6 +179,7 @@
|
||||
this.uiMarkLabel2.Size = new System.Drawing.Size(113, 26);
|
||||
this.uiMarkLabel2.TabIndex = 26;
|
||||
this.uiMarkLabel2.Text = "uiMarkLabel2";
|
||||
this.uiMarkLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// uiMarkLabel3
|
||||
//
|
||||
@ -189,6 +192,7 @@
|
||||
this.uiMarkLabel3.Size = new System.Drawing.Size(118, 21);
|
||||
this.uiMarkLabel3.TabIndex = 27;
|
||||
this.uiMarkLabel3.Text = "uiMarkLabel3";
|
||||
this.uiMarkLabel3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// uiMarkLabel4
|
||||
//
|
||||
@ -201,10 +205,10 @@
|
||||
this.uiMarkLabel4.Size = new System.Drawing.Size(113, 26);
|
||||
this.uiMarkLabel4.TabIndex = 28;
|
||||
this.uiMarkLabel4.Text = "uiMarkLabel4";
|
||||
this.uiMarkLabel4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// FLabel
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Name = "FLabel";
|
||||
|
60
SunnyUI.Demo/Controls/FOther.Designer.cs
generated
60
SunnyUI.Demo/Controls/FOther.Designer.cs
generated
@ -58,11 +58,15 @@
|
||||
this.uiToolTip1 = new Sunny.UI.UIToolTip(this.components);
|
||||
this.uiProcessBar2 = new Sunny.UI.UIProcessBar();
|
||||
this.uiRoundProcess1 = new Sunny.UI.UIRoundProcess();
|
||||
this.uiLine9 = new Sunny.UI.UILine();
|
||||
this.uiRoundProcess2 = new Sunny.UI.UIRoundProcess();
|
||||
this.PagePanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// PagePanel
|
||||
//
|
||||
this.PagePanel.Controls.Add(this.uiRoundProcess2);
|
||||
this.PagePanel.Controls.Add(this.uiLine9);
|
||||
this.PagePanel.Controls.Add(this.uiRoundProcess1);
|
||||
this.PagePanel.Controls.Add(this.uiProcessBar2);
|
||||
this.PagePanel.Controls.Add(this.uiLabel3);
|
||||
@ -90,7 +94,7 @@
|
||||
this.PagePanel.Controls.Add(this.uiLight2);
|
||||
this.PagePanel.Controls.Add(this.uiLine2);
|
||||
this.PagePanel.Controls.Add(this.uiLight1);
|
||||
this.PagePanel.Size = new System.Drawing.Size(800, 472);
|
||||
this.PagePanel.Size = new System.Drawing.Size(800, 578);
|
||||
//
|
||||
// uiLight1
|
||||
//
|
||||
@ -166,7 +170,7 @@
|
||||
// uiProgressIndicator1
|
||||
//
|
||||
this.uiProgressIndicator1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiProgressIndicator1.Location = new System.Drawing.Point(30, 298);
|
||||
this.uiProgressIndicator1.Location = new System.Drawing.Point(381, 339);
|
||||
this.uiProgressIndicator1.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiProgressIndicator1.Name = "uiProgressIndicator1";
|
||||
this.uiProgressIndicator1.Size = new System.Drawing.Size(120, 120);
|
||||
@ -176,7 +180,7 @@
|
||||
// uiLine4
|
||||
//
|
||||
this.uiLine4.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiLine4.Location = new System.Drawing.Point(30, 271);
|
||||
this.uiLine4.Location = new System.Drawing.Point(381, 313);
|
||||
this.uiLine4.MinimumSize = new System.Drawing.Size(16, 16);
|
||||
this.uiLine4.Name = "uiLine4";
|
||||
this.uiLine4.Size = new System.Drawing.Size(319, 20);
|
||||
@ -194,6 +198,7 @@
|
||||
this.uiTrackBar1.Size = new System.Drawing.Size(158, 29);
|
||||
this.uiTrackBar1.TabIndex = 30;
|
||||
this.uiTrackBar1.Text = "uiTrackBar1";
|
||||
this.uiTrackBar1.Value = 50;
|
||||
//
|
||||
// uiLine5
|
||||
//
|
||||
@ -333,7 +338,7 @@
|
||||
// uiLine7
|
||||
//
|
||||
this.uiLine7.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiLine7.Location = new System.Drawing.Point(381, 313);
|
||||
this.uiLine7.Location = new System.Drawing.Point(29, 256);
|
||||
this.uiLine7.MinimumSize = new System.Drawing.Size(16, 16);
|
||||
this.uiLine7.Name = "uiLine7";
|
||||
this.uiLine7.Size = new System.Drawing.Size(319, 20);
|
||||
@ -345,7 +350,7 @@
|
||||
//
|
||||
this.uiLabel1.AutoSize = true;
|
||||
this.uiLabel1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiLabel1.Location = new System.Drawing.Point(382, 350);
|
||||
this.uiLabel1.Location = new System.Drawing.Point(30, 293);
|
||||
this.uiLabel1.Name = "uiLabel1";
|
||||
this.uiLabel1.Size = new System.Drawing.Size(138, 21);
|
||||
this.uiLabel1.TabIndex = 53;
|
||||
@ -357,7 +362,7 @@
|
||||
//
|
||||
this.uiLabel2.AutoSize = true;
|
||||
this.uiLabel2.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiLabel2.Location = new System.Drawing.Point(562, 350);
|
||||
this.uiLabel2.Location = new System.Drawing.Point(210, 293);
|
||||
this.uiLabel2.Name = "uiLabel2";
|
||||
this.uiLabel2.Size = new System.Drawing.Size(138, 21);
|
||||
this.uiLabel2.TabIndex = 54;
|
||||
@ -368,7 +373,7 @@
|
||||
//
|
||||
this.uiLabel3.AutoSize = true;
|
||||
this.uiLabel3.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiLabel3.Location = new System.Drawing.Point(382, 388);
|
||||
this.uiLabel3.Location = new System.Drawing.Point(30, 331);
|
||||
this.uiLabel3.Name = "uiLabel3";
|
||||
this.uiLabel3.Size = new System.Drawing.Size(138, 21);
|
||||
this.uiLabel3.TabIndex = 55;
|
||||
@ -397,22 +402,45 @@
|
||||
//
|
||||
this.uiRoundProcess1.BackColor = System.Drawing.Color.Transparent;
|
||||
this.uiRoundProcess1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiRoundProcess1.Inner = 30;
|
||||
this.uiRoundProcess1.Location = new System.Drawing.Point(228, 298);
|
||||
this.uiRoundProcess1.Location = new System.Drawing.Point(29, 393);
|
||||
this.uiRoundProcess1.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiRoundProcess1.Name = "uiRoundProcess1";
|
||||
this.uiRoundProcess1.Outer = 50;
|
||||
this.uiRoundProcess1.ProcessBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(155)))), ((int)(((byte)(200)))), ((int)(((byte)(255)))));
|
||||
this.uiRoundProcess1.ProcessColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
|
||||
this.uiRoundProcess1.ShowProcess = true;
|
||||
this.uiRoundProcess1.Size = new System.Drawing.Size(120, 120);
|
||||
this.uiRoundProcess1.TabIndex = 57;
|
||||
this.uiRoundProcess1.Text = "uiRoundProcess1";
|
||||
this.uiRoundProcess1.Value = 80;
|
||||
this.uiRoundProcess1.Text = "0.0%";
|
||||
//
|
||||
// uiLine9
|
||||
//
|
||||
this.uiLine9.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiLine9.Location = new System.Drawing.Point(30, 367);
|
||||
this.uiLine9.MinimumSize = new System.Drawing.Size(16, 16);
|
||||
this.uiLine9.Name = "uiLine9";
|
||||
this.uiLine9.Size = new System.Drawing.Size(319, 20);
|
||||
this.uiLine9.TabIndex = 58;
|
||||
this.uiLine9.Text = "UIRoundProcess";
|
||||
this.uiLine9.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// uiRoundProcess2
|
||||
//
|
||||
this.uiRoundProcess2.BackColor = System.Drawing.Color.Transparent;
|
||||
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(156, 393);
|
||||
this.uiRoundProcess2.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiRoundProcess2.Name = "uiRoundProcess2";
|
||||
this.uiRoundProcess2.ShowProcess = true;
|
||||
this.uiRoundProcess2.Size = new System.Drawing.Size(120, 120);
|
||||
this.uiRoundProcess2.Style = Sunny.UI.UIStyle.Custom;
|
||||
this.uiRoundProcess2.StyleCustomMode = true;
|
||||
this.uiRoundProcess2.TabIndex = 59;
|
||||
this.uiRoundProcess2.Text = "0.0%";
|
||||
//
|
||||
// FOther
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.ClientSize = new System.Drawing.Size(800, 507);
|
||||
this.ClientSize = new System.Drawing.Size(800, 613);
|
||||
this.Name = "FOther";
|
||||
this.Symbol = 62173;
|
||||
this.Text = "Other";
|
||||
@ -452,5 +480,7 @@
|
||||
private UIToolTip uiToolTip1;
|
||||
private UIProcessBar uiProcessBar2;
|
||||
private UIRoundProcess uiRoundProcess1;
|
||||
private UIRoundProcess uiRoundProcess2;
|
||||
private UILine uiLine9;
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@
|
||||
value++;
|
||||
uiTrackBar1.Value = value;
|
||||
uiProcessBar2.Value = uiProcessBar1.Value = value;
|
||||
uiRoundProcess2.Value = uiRoundProcess1.Value = value;
|
||||
}
|
||||
}
|
||||
}
|
@ -123,9 +123,6 @@
|
||||
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="uiToolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>107, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>35</value>
|
||||
</metadata>
|
||||
|
@ -19,16 +19,19 @@
|
||||
* 2021-04-08: V3.0.2 增加文件说明
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace Sunny.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// 圆形滚动条
|
||||
/// </summary>
|
||||
[ToolboxItem(false)]
|
||||
[ToolboxItem(true)]
|
||||
[DefaultEvent("ValueChanged")]
|
||||
[DefaultProperty("Value")]
|
||||
public class UIRoundProcess : UIControl
|
||||
{
|
||||
public UIRoundProcess()
|
||||
@ -37,29 +40,136 @@ namespace Sunny.UI
|
||||
Inner = 30;
|
||||
Outer = 50;
|
||||
|
||||
ProcessColor = UIColor.Blue;
|
||||
ProcessBackColor = Color.FromArgb(155, 200, 255);
|
||||
base.BackColor = Color.Transparent;
|
||||
fillColor = UIColor.Blue;
|
||||
rectColor = Color.FromArgb(155, 200, 255);
|
||||
foreColor = UIColor.Blue;
|
||||
ShowText = false;
|
||||
ShowRect = false;
|
||||
ShowFill = false;
|
||||
}
|
||||
|
||||
public int Inner { get; set; }
|
||||
private int maximum = 100;
|
||||
|
||||
public int Outer { get; set; }
|
||||
|
||||
public Color ProcessColor { get; set; }
|
||||
|
||||
public Color ProcessBackColor { get; set; }
|
||||
|
||||
public int Value { get; set; }
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
[DefaultValue(100)]
|
||||
[Description("最大值"), Category("SunnyUI")]
|
||||
public int Maximum
|
||||
{
|
||||
base.OnPaint(e);
|
||||
e.Graphics.FillFan(ProcessBackColor, ClientRectangle.Center(), Inner, Outer, 0, 360);
|
||||
e.Graphics.FillFan(ProcessColor, ClientRectangle.Center(), Inner, Outer, -90, Value / 100.0f * 360);
|
||||
get => maximum;
|
||||
set
|
||||
{
|
||||
maximum = Math.Max(1, value);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private int inner = 30;
|
||||
private int outer = 50;
|
||||
|
||||
[Description("内径")]
|
||||
[Category("SunnyUI")]
|
||||
[DefaultValue(30)]
|
||||
public int Inner
|
||||
{
|
||||
get => inner;
|
||||
set
|
||||
{
|
||||
inner = Math.Max(value, 0);
|
||||
inner = Math.Min(value, outer - 5);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Description("外径")]
|
||||
[Category("SunnyUI")]
|
||||
[DefaultValue(50)]
|
||||
public int Outer
|
||||
{
|
||||
get => outer;
|
||||
set
|
||||
{
|
||||
outer = Math.Max(value, 5);
|
||||
inner = Math.Min(inner, outer - 5);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进度条前景色
|
||||
/// </summary>
|
||||
[Description("进度条前景色")]
|
||||
[Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "80, 160, 255")]
|
||||
public Color ProcessColor
|
||||
{
|
||||
get => fillColor;
|
||||
set => SetFillColor(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进度条背景色
|
||||
/// </summary>
|
||||
[Description("进度条背景色")]
|
||||
[Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "155, 200, 255")]
|
||||
public Color ProcessBackColor
|
||||
{
|
||||
get => rectColor;
|
||||
set => SetRectColor(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字体颜色
|
||||
/// </summary>
|
||||
[Description("字体颜色")]
|
||||
[Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "80, 160, 255")]
|
||||
public override Color ForeColor
|
||||
{
|
||||
get => foreColor;
|
||||
set => SetForeColor(value);
|
||||
}
|
||||
|
||||
private int posValue;
|
||||
|
||||
[DefaultValue(0)]
|
||||
[Description("当前位置"), Category("SunnyUI")]
|
||||
public int Value
|
||||
{
|
||||
get => posValue;
|
||||
set
|
||||
{
|
||||
posValue = Math.Max(value, 0);
|
||||
posValue = Math.Min(posValue, maximum);
|
||||
Text = (posValue * 100.0 / maximum).ToString("F1") + "%";
|
||||
ValueChanged?.Invoke(this, posValue);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void OnValueChanged(object sender, int value);
|
||||
|
||||
public event OnValueChanged ValueChanged;
|
||||
|
||||
protected override void OnPaintFill(Graphics g, GraphicsPath path)
|
||||
{
|
||||
g.FillFan(ProcessBackColor, ClientRectangle.Center(), Inner, Outer, 0, 360);
|
||||
g.FillFan(ProcessColor, ClientRectangle.Center(), Inner, Outer, -90, Value * 1.0f / Maximum * 360.0f);
|
||||
}
|
||||
|
||||
public override void SetStyleColor(UIBaseStyle uiColor)
|
||||
{
|
||||
base.SetStyleColor(uiColor);
|
||||
if (uiColor.IsCustom()) return;
|
||||
|
||||
fillColor = uiColor.PrimaryColor;
|
||||
foreColor = uiColor.PrimaryColor;
|
||||
rectColor = uiColor.GridSelectedColor;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
public bool ShowProcess
|
||||
{
|
||||
get => ShowText;
|
||||
set => ShowText = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -727,32 +727,60 @@ namespace Sunny.UI
|
||||
}
|
||||
|
||||
public static void DrawFan(this Graphics g, Color color, Point center, float d1, float d2, float startAngle, float sweepAngle, bool smooth = true)
|
||||
{
|
||||
if (d1.Equals(0))
|
||||
{
|
||||
g.DrawPie(color, center.X - d2, center.Y - d2, d2 * 2, d2 * 2, startAngle, sweepAngle);
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphicsPath path = g.CreateFanPath(center, d1, d2, startAngle, sweepAngle);
|
||||
g.DrawPath(color, path, smooth);
|
||||
path.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawFan(this Graphics g, Color color, PointF center, float d1, float d2, float startAngle, float sweepAngle, bool smooth = true)
|
||||
{
|
||||
if (d1.Equals(0))
|
||||
{
|
||||
g.DrawPie(color, center.X - d2, center.Y - d2, d2 * 2, d2 * 2, startAngle, sweepAngle);
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphicsPath path = g.CreateFanPath(center, d1, d2, startAngle, sweepAngle);
|
||||
g.DrawPath(color, path, smooth);
|
||||
path.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public static void FillFan(this Graphics g, Color color, Point center, float d1, float d2, float startAngle, float sweepAngle, bool smooth = true)
|
||||
{
|
||||
if (d1.Equals(0))
|
||||
{
|
||||
g.FillPie(color, center.X - d2, center.Y - d2, d2 * 2, d2 * 2, startAngle, sweepAngle);
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphicsPath path = g.CreateFanPath(center, d1, d2, startAngle, sweepAngle);
|
||||
g.FillPath(color, path, smooth);
|
||||
path.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public static void FillFan(this Graphics g, Color color, PointF center, float d1, float d2, float startAngle, float sweepAngle, bool smooth = true)
|
||||
{
|
||||
if (d1.Equals(0))
|
||||
{
|
||||
g.FillPie(color, center.X - d2, center.Y - d2, d2 * 2, d2 * 2, startAngle, sweepAngle);
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphicsPath path = g.CreateFanPath(center, d1, d2, startAngle, sweepAngle);
|
||||
g.FillPath(color, path, smooth);
|
||||
path.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public static void FillPie(this Graphics g, Color color, int x, int y, int width, int height, float startAngle, float sweepAngle, bool smooth = true)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user