diff --git a/Bin/SunnyUI.dll b/Bin/SunnyUI.dll index ffaef7b3..0a3b3fbc 100644 Binary files a/Bin/SunnyUI.dll and b/Bin/SunnyUI.dll differ diff --git a/Bin/SunnyUI.pdb b/Bin/SunnyUI.pdb index 0ba83ea6..c149abc8 100644 Binary files a/Bin/SunnyUI.pdb and b/Bin/SunnyUI.pdb differ diff --git a/SunnyUI.Demo/Bin/SunnyUI.Demo.exe b/SunnyUI.Demo/Bin/SunnyUI.Demo.exe index 0936a5fe..d190e5f0 100644 Binary files a/SunnyUI.Demo/Bin/SunnyUI.Demo.exe and b/SunnyUI.Demo/Bin/SunnyUI.Demo.exe differ diff --git a/SunnyUI.Demo/Bin/SunnyUI.dll b/SunnyUI.Demo/Bin/SunnyUI.dll index ffaef7b3..0a3b3fbc 100644 Binary files a/SunnyUI.Demo/Bin/SunnyUI.dll and b/SunnyUI.Demo/Bin/SunnyUI.dll differ diff --git a/SunnyUI.Demo/Controls/FOther.Designer.cs b/SunnyUI.Demo/Controls/FOther.Designer.cs index 71754915..eff839ff 100644 --- a/SunnyUI.Demo/Controls/FOther.Designer.cs +++ b/SunnyUI.Demo/Controls/FOther.Designer.cs @@ -49,11 +49,15 @@ this.uiLine6 = new Sunny.UI.UILine(); this.uiScrollingText1 = new Sunny.UI.UIScrollingText(); this.uiScrollingText2 = new Sunny.UI.UIScrollingText(); + this.uiWaitingBar1 = new Sunny.UI.UIWaitingBar(); + this.uiLine1 = new Sunny.UI.UILine(); this.PagePanel.SuspendLayout(); this.SuspendLayout(); // // PagePanel // + this.PagePanel.Controls.Add(this.uiLine1); + this.PagePanel.Controls.Add(this.uiWaitingBar1); this.PagePanel.Controls.Add(this.uiScrollingText2); this.PagePanel.Controls.Add(this.uiScrollingText1); this.PagePanel.Controls.Add(this.uiLine6); @@ -145,7 +149,7 @@ // uiProgressIndicator1 // this.uiProgressIndicator1.Font = new System.Drawing.Font("微软雅黑", 12F); - this.uiProgressIndicator1.Location = new System.Drawing.Point(30, 209); + this.uiProgressIndicator1.Location = new System.Drawing.Point(30, 298); this.uiProgressIndicator1.Name = "uiProgressIndicator1"; this.uiProgressIndicator1.Size = new System.Drawing.Size(119, 132); this.uiProgressIndicator1.TabIndex = 26; @@ -154,7 +158,7 @@ // uiLine4 // this.uiLine4.Font = new System.Drawing.Font("微软雅黑", 12F); - this.uiLine4.Location = new System.Drawing.Point(30, 182); + this.uiLine4.Location = new System.Drawing.Point(30, 271); this.uiLine4.MinimumSize = new System.Drawing.Size(16, 16); this.uiLine4.Name = "uiLine4"; this.uiLine4.Size = new System.Drawing.Size(319, 20); @@ -264,7 +268,7 @@ this.uiScrollingText1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255))))); this.uiScrollingText1.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiScrollingText1.ForeColor = System.Drawing.Color.Red; - this.uiScrollingText1.Location = new System.Drawing.Point(381, 208); + this.uiScrollingText1.Location = new System.Drawing.Point(381, 215); this.uiScrollingText1.Name = "uiScrollingText1"; this.uiScrollingText1.ScrollingType = Sunny.UI.UIScrollingText.UIScrollingType.LeftToRight; this.uiScrollingText1.Size = new System.Drawing.Size(319, 35); @@ -278,12 +282,33 @@ this.uiScrollingText2.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255))))); this.uiScrollingText2.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiScrollingText2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); - this.uiScrollingText2.Location = new System.Drawing.Point(381, 249); + this.uiScrollingText2.Location = new System.Drawing.Point(381, 256); this.uiScrollingText2.Name = "uiScrollingText2"; this.uiScrollingText2.Size = new System.Drawing.Size(319, 35); this.uiScrollingText2.TabIndex = 49; this.uiScrollingText2.Text = "赠人玫瑰手有余香"; // + // uiWaitingBar1 + // + this.uiWaitingBar1.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiWaitingBar1.Location = new System.Drawing.Point(30, 215); + this.uiWaitingBar1.MinimumSize = new System.Drawing.Size(70, 23); + this.uiWaitingBar1.Name = "uiWaitingBar1"; + this.uiWaitingBar1.Size = new System.Drawing.Size(319, 29); + this.uiWaitingBar1.TabIndex = 50; + this.uiWaitingBar1.Text = "uiWaitingBar1"; + // + // uiLine1 + // + this.uiLine1.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiLine1.Location = new System.Drawing.Point(30, 182); + this.uiLine1.MinimumSize = new System.Drawing.Size(16, 16); + this.uiLine1.Name = "uiLine1"; + this.uiLine1.Size = new System.Drawing.Size(319, 20); + this.uiLine1.TabIndex = 51; + this.uiLine1.Text = "UIWaitingBar"; + this.uiLine1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // // FOther // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); @@ -318,5 +343,7 @@ private UILine uiLine6; private UIScrollingText uiScrollingText1; private UIScrollingText uiScrollingText2; + private UIWaitingBar uiWaitingBar1; + private UILine uiLine1; } } \ No newline at end of file diff --git a/SunnyUI/Controls/UIControl.cs b/SunnyUI/Controls/UIControl.cs index ac53daee..dd86a4dc 100644 --- a/SunnyUI/Controls/UIControl.cs +++ b/SunnyUI/Controls/UIControl.cs @@ -296,8 +296,12 @@ namespace Sunny.UI } path.Dispose(); + + PaintOther?.Invoke(this, e); } + public event PaintEventHandler PaintOther; + /// /// 获取边框颜色 /// diff --git a/SunnyUI/Controls/UIWaitingBar.cs b/SunnyUI/Controls/UIWaitingBar.cs new file mode 100644 index 00000000..55609d6d --- /dev/null +++ b/SunnyUI/Controls/UIWaitingBar.cs @@ -0,0 +1,104 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace Sunny.UI +{ + [ToolboxItem(true)] + public sealed class UIWaitingBar : UIControl + { + private System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); + + public UIWaitingBar() + { + MinimumSize = new Size(70, 23); + Size = new Size(300, 29); + ShowText = false; + + PaintOther += UIWaitingBar_PaintOther; + + fillColor = UIColor.LightBlue; + foreColor = UIColor.Blue; + timer.Interval = 200; + timer.Tick += Timer_Tick; + timer.Start(); + } + + private void UIWaitingBar_PaintOther(object sender, PaintEventArgs e) + { + e.Graphics.FillRoundRectangle(rectColor, (int)dz + 1, 1, sliderWidth, Height - 3, Radius); + } + + //d是度数,不是弧度 + private double d; + + private double dz; + + private int blockCount = 20; + + [DefaultValue(20)] + public int BlockCount + { + get => blockCount; + set => blockCount = Math.Max(10, value); + } + + private void Timer_Tick(object sender, EventArgs e) + { + //移动距离要减去滑块本身的宽度 + double dMoveDistance = Width - SliderWidth - 3; + //需要变化的次数 + double dStep = dMoveDistance / blockCount; + //每次变化所增加的度数 + double dPer = 180.0 / dStep; + + d += dPer; + if (d > 360) + { + //一个周期是360度 + d = 0; + } + + //通过公式:弧度=度*π/180,将度数i转为Math.Sin()所需要的弧度数 + dz = dMoveDistance * (1 + Math.Sin((d - 90) * Math.PI / 180)) / 2; + + Invalidate(); + } + + [DefaultValue(200)] + public int Interval + { + get => timer.Interval; + set + { + timer.Stop(); + timer.Interval = Math.Max(50, value); + timer.Start(); + } + } + + private int sliderWidth = 60; + + [DefaultValue(60)] + public int SliderWidth + { + get => sliderWidth; + set + { + sliderWidth = value; + Invalidate(); + } + } + + public override void SetStyleColor(UIBaseStyle uiColor) + { + base.SetStyleColor(uiColor); + if (uiColor.IsCustom()) return; + + fillColor = uiColor.ProcessBarFillColor; + foreColor = uiColor.ProcessBarForeColor; + Invalidate(); + } + } +} \ No newline at end of file diff --git a/SunnyUI/SunnyUI.csproj b/SunnyUI/SunnyUI.csproj index 812b5b71..8ceeae56 100644 --- a/SunnyUI/SunnyUI.csproj +++ b/SunnyUI/SunnyUI.csproj @@ -129,6 +129,9 @@ UserControl + + Component + Form