diff --git a/Bin/net40/SunnyUI.Demo.exe b/Bin/net40/SunnyUI.Demo.exe index 53cec2ee..72d43813 100644 Binary files a/Bin/net40/SunnyUI.Demo.exe and b/Bin/net40/SunnyUI.Demo.exe differ diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll index cc4dc9f9..c38cbe57 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/Bin/net45/SunnyUI.dll b/Bin/net45/SunnyUI.dll index 093cc9c0..5a141553 100644 Binary files a/Bin/net45/SunnyUI.dll and b/Bin/net45/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/SunnyUI.dll b/Bin/net5.0-windows/SunnyUI.dll index 40f6f293..03eb14c0 100644 Binary files a/Bin/net5.0-windows/SunnyUI.dll and b/Bin/net5.0-windows/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/ref/SunnyUI.dll b/Bin/net5.0-windows/ref/SunnyUI.dll index 300dbd60..49b14ee2 100644 Binary files a/Bin/net5.0-windows/ref/SunnyUI.dll and b/Bin/net5.0-windows/ref/SunnyUI.dll differ diff --git a/Bin/netcoreapp3.1/SunnyUI.dll b/Bin/netcoreapp3.1/SunnyUI.dll index 75048fbe..2ccc005f 100644 Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ diff --git a/SunnyUI.Demo/Controls/FProcess.cs b/SunnyUI.Demo/Controls/FProcess.cs index 87469d83..d84dbe42 100644 --- a/SunnyUI.Demo/Controls/FProcess.cs +++ b/SunnyUI.Demo/Controls/FProcess.cs @@ -20,7 +20,7 @@ value++; uiTrackBar2.Value = uiTrackBar1.Value = value; uiProcessBar2.Value = uiProcessBar1.Value = value; - uiRoundProcess2.Value = uiRoundProcess1.Value = value; + uiProcessBar3.Value = uiRoundProcess2.Value = uiRoundProcess1.Value = value; } } } diff --git a/SunnyUI.Demo/Controls/FProcess.designer.cs b/SunnyUI.Demo/Controls/FProcess.designer.cs index 0e264f66..45bc08bc 100644 --- a/SunnyUI.Demo/Controls/FProcess.designer.cs +++ b/SunnyUI.Demo/Controls/FProcess.designer.cs @@ -52,6 +52,8 @@ namespace Sunny.UI.Demo this.uiLine3 = new Sunny.UI.UILine(); this.uiProcessBar1 = new Sunny.UI.UIProcessBar(); this.timer1 = new System.Windows.Forms.Timer(this.components); + this.uiProcessBar3 = new Sunny.UI.UIProcessBar(); + this.uiLine6 = new Sunny.UI.UILine(); this.SuspendLayout(); // // uiTrackBar8 @@ -147,7 +149,7 @@ namespace Sunny.UI.Demo this.uiLine2.Location = new System.Drawing.Point(29, 287); this.uiLine2.MinimumSize = new System.Drawing.Size(16, 16); this.uiLine2.Name = "uiLine2"; - this.uiLine2.Size = new System.Drawing.Size(319, 20); + this.uiLine2.Size = new System.Drawing.Size(440, 20); this.uiLine2.TabIndex = 95; this.uiLine2.Text = "UIBreadcrumb"; this.uiLine2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -211,7 +213,6 @@ namespace Sunny.UI.Demo // // uiProcessBar2 // - this.uiProcessBar2.DecimalCount = 1; this.uiProcessBar2.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiProcessBar2.Location = new System.Drawing.Point(30, 123); this.uiProcessBar2.MinimumSize = new System.Drawing.Size(70, 1); @@ -248,7 +249,7 @@ namespace Sunny.UI.Demo this.uiLine5.Location = new System.Drawing.Point(28, 369); this.uiLine5.MinimumSize = new System.Drawing.Size(16, 16); this.uiLine5.Name = "uiLine5"; - this.uiLine5.Size = new System.Drawing.Size(672, 20); + this.uiLine5.Size = new System.Drawing.Size(441, 20); this.uiLine5.TabIndex = 87; this.uiLine5.Text = "UITrackBar"; this.uiLine5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -298,25 +299,47 @@ namespace Sunny.UI.Demo // // uiProcessBar1 // - this.uiProcessBar1.DecimalCount = 1; this.uiProcessBar1.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiProcessBar1.Location = new System.Drawing.Point(30, 88); this.uiProcessBar1.MinimumSize = new System.Drawing.Size(70, 1); this.uiProcessBar1.Name = "uiProcessBar1"; this.uiProcessBar1.Size = new System.Drawing.Size(318, 29); this.uiProcessBar1.TabIndex = 82; - this.uiProcessBar1.Text = "50.0%"; - this.uiProcessBar1.Value = 50; + this.uiProcessBar1.Value = 10; // // timer1 // this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // + // uiProcessBar3 + // + this.uiProcessBar3.Direction = Sunny.UI.UILine.LineDirection.Vertical; + this.uiProcessBar3.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiProcessBar3.Location = new System.Drawing.Point(527, 325); + this.uiProcessBar3.MinimumSize = new System.Drawing.Size(70, 1); + this.uiProcessBar3.Name = "uiProcessBar3"; + this.uiProcessBar3.Size = new System.Drawing.Size(203, 169); + this.uiProcessBar3.TabIndex = 103; + this.uiProcessBar3.Value = 50; + // + // uiLine6 + // + this.uiLine6.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiLine6.Location = new System.Drawing.Point(527, 287); + this.uiLine6.MinimumSize = new System.Drawing.Size(16, 16); + this.uiLine6.Name = "uiLine6"; + this.uiLine6.Size = new System.Drawing.Size(203, 20); + this.uiLine6.TabIndex = 104; + this.uiLine6.Text = "UIProcessBar"; + this.uiLine6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // // FProcess // this.AllowShowTitle = true; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.ClientSize = new System.Drawing.Size(800, 546); + this.Controls.Add(this.uiLine6); + this.Controls.Add(this.uiProcessBar3); this.Controls.Add(this.uiTrackBar8); this.Controls.Add(this.uiTrackBar7); this.Controls.Add(this.uiTrackBar6); @@ -371,5 +394,7 @@ namespace Sunny.UI.Demo private UILine uiLine3; private UIProcessBar uiProcessBar1; private System.Windows.Forms.Timer timer1; + private UIProcessBar uiProcessBar3; + private UILine uiLine6; } } \ No newline at end of file diff --git a/SunnyUI/Controls/UIPipe.cs b/SunnyUI/Controls/UIPipe.cs index c889ca07..5ecaa215 100644 --- a/SunnyUI/Controls/UIPipe.cs +++ b/SunnyUI/Controls/UIPipe.cs @@ -572,7 +572,7 @@ namespace Sunny.UI int pos = FlowPos.Mod(FlowSize + FlowInterval); for (int i = 0; i < int.MaxValue; i++) { - Rectangle rect = new Rectangle(pos - FlowSize - FlowInterval, 1, FlowSize, Height - 3); + Rectangle rect = new Rectangle(pos - FlowSize - FlowInterval, 2, FlowSize, Height - 5); if (rect.Left > Width) break; bool isShow = rect.Left >= 0 & rect.Right <= Width; @@ -596,7 +596,7 @@ namespace Sunny.UI if (rect.Width >= rect.Height && isShow) { - g.FillRoundRectangle(color, rect, Radius - 2); + g.FillRoundRectangle(color, rect, Radius - 4); } pos += FlowSize; @@ -626,7 +626,7 @@ namespace Sunny.UI for (int i = 0; i < int.MaxValue; i++) { - Rectangle rect = new Rectangle(1, pos - FlowSize - FlowInterval, Width - 3, FlowSize); + Rectangle rect = new Rectangle(2, pos - FlowSize - FlowInterval, Width - 5, FlowSize); if (rect.Top > Height) break; bool isShow = rect.Top >= top & rect.Bottom <= bottom; @@ -650,7 +650,7 @@ namespace Sunny.UI if (rect.Height >= rect.Width && isShow) { - g.FillRoundRectangle(color, rect, Radius - 2); + g.FillRoundRectangle(color, rect, Radius - 4); } pos += FlowSize; diff --git a/SunnyUI/Controls/UIProcessBar.cs b/SunnyUI/Controls/UIProcessBar.cs index efc732e1..16dbfdc2 100644 --- a/SunnyUI/Controls/UIProcessBar.cs +++ b/SunnyUI/Controls/UIProcessBar.cs @@ -23,7 +23,6 @@ using System; using System.ComponentModel; using System.Drawing; -using System.Drawing.Drawing2D; using System.Windows.Forms; namespace Sunny.UI @@ -49,6 +48,22 @@ namespace Sunny.UI fillColor = UIColor.LightBlue; foreColor = UIColor.Blue; } + private UILine.LineDirection direction = UILine.LineDirection.Horizontal; + + [DefaultValue(UILine.LineDirection.Horizontal)] + [Description("线条方向"), Category("SunnyUI")] + public UILine.LineDirection Direction + { + get => direction; + set + { + if (direction != value) + { + direction = value; + Invalidate(); + } + } + } [DefaultValue(100)] [Description("最大值"), Category("SunnyUI")] @@ -73,17 +88,11 @@ namespace Sunny.UI { posValue = Math.Max(value, 0); posValue = Math.Min(posValue, maximum); - processWidth = (int)(posValue * Width * 1.0 / Maximum); - processText = (posValue * 100.0 / maximum).ToString("F" + DecimalCount) + "%"; ValueChanged?.Invoke(this, posValue); Invalidate(); } } - private int processWidth; - - private string processText = "0.0%"; - private bool showValue = true; [DefaultValue(true)] @@ -114,6 +123,19 @@ namespace Sunny.UI { base.OnPaint(e); + float processSize; + string processText = "0.0%"; + + if (Direction == UILine.LineDirection.Horizontal) + processSize = posValue * Width * 1.0f / Maximum; + else + processSize = posValue * Height * 1.0f / Maximum; + + if (ShowPercent) + processText = (posValue * 100.0 / maximum).ToString("F" + DecimalCount) + "%"; + else + processText = (posValue * 1.0 / maximum).ToString("F" + DecimalCount); + SizeF sf = e.Graphics.MeasureString(processText, Font); bool canShow = Height > sf.Height + 4; @@ -122,10 +144,10 @@ namespace Sunny.UI e.Graphics.DrawString(processText, Font, foreColor, Size, Padding, TextAlign); } - if (image == null || image.Width != Width + 2 || image.Height != Height + 2 || imageRadius != Radius) + if (image == null || image.Width != Width || image.Height != Height || imageRadius != Radius) { image?.Dispose(); - image = new Bitmap(Width + 2, Height + 2); + image = new Bitmap(Width, Height); imageRadius = Radius; } @@ -143,26 +165,46 @@ namespace Sunny.UI g.Dispose(); - rect = new Rectangle(0, 0, processWidth, image.Height - 1); - GraphicsPath path = rect.CreateRoundedRectanglePath(0, UICornerRadiusSides.None); - using (Bitmap img = image.Split(path)) + if (Direction == UILine.LineDirection.Horizontal) { - e.Graphics.DrawImage(img, 0, 0); + e.Graphics.DrawImage(image, + new RectangleF(0, 0, processSize, image.Height), + new RectangleF(0, 0, processSize, image.Height), + GraphicsUnit.Pixel); + } + else + { + e.Graphics.DrawImage(image, + new RectangleF(0, image.Height - processSize, image.Width, processSize), + new RectangleF(0, image.Height - processSize, image.Width, processSize), + GraphicsUnit.Pixel); } } protected override void OnSizeChanged(EventArgs e) { base.OnSizeChanged(e); - image?.Dispose(); - image = null; - processWidth = (int)(posValue * Width * 1.0 / Maximum); - Text = (posValue * 100.0 / maximum).ToString("F" + DecimalCount) + "%"; Invalidate(); } + private bool showPercent = true; + + [Description("显示文字百分比"), Category("SunnyUI")] + [DefaultValue(true)] + public bool ShowPercent + { + get => showPercent; + set + { + showPercent = value; + Invalidate(); + } + } + private int decimalCount = 1; + [Description("显示文字小数位数"), Category("SunnyUI")] + [DefaultValue(1)] public int DecimalCount { get => decimalCount;