diff --git a/Bin/SunnyUI.dll b/Bin/SunnyUI.dll index 154ea2c1..d898052d 100644 Binary files a/Bin/SunnyUI.dll and b/Bin/SunnyUI.dll differ diff --git a/Bin/SunnyUI.pdb b/Bin/SunnyUI.pdb index 6930a108..4458eb12 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 6c7653d6..0aff5573 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 154ea2c1..d898052d 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 668f8dae..e367588e 100644 --- a/SunnyUI.Demo/Controls/FOther.Designer.cs +++ b/SunnyUI.Demo/Controls/FOther.Designer.cs @@ -51,11 +51,17 @@ this.uiScrollBar2 = new Sunny.UI.UIScrollBar(); this.uiScrollBar3 = new Sunny.UI.UIScrollBar(); this.uiScrollBar4 = new Sunny.UI.UIScrollBar(); + this.uiLine6 = new Sunny.UI.UILine(); + this.uiScrollingText1 = new Sunny.UI.UIScrollingText(); + this.uiScrollingText2 = new Sunny.UI.UIScrollingText(); this.PagePanel.SuspendLayout(); this.SuspendLayout(); // // PagePanel // + this.PagePanel.Controls.Add(this.uiScrollingText2); + this.PagePanel.Controls.Add(this.uiScrollingText1); + this.PagePanel.Controls.Add(this.uiLine6); this.PagePanel.Controls.Add(this.uiScrollBar4); this.PagePanel.Controls.Add(this.uiScrollBar3); this.PagePanel.Controls.Add(this.uiScrollBar2); @@ -316,6 +322,42 @@ this.uiScrollBar4.TabIndex = 45; this.uiScrollBar4.Text = "uiScrollBar4"; // + // uiLine6 + // + this.uiLine6.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiLine6.Location = new System.Drawing.Point(30, 346); + this.uiLine6.MinimumSize = new System.Drawing.Size(16, 16); + this.uiLine6.Name = "uiLine6"; + this.uiLine6.Size = new System.Drawing.Size(319, 20); + this.uiLine6.TabIndex = 47; + this.uiLine6.Text = "UIScrollingText"; + this.uiLine6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // uiScrollingText1 + // + 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(27, 372); + this.uiScrollingText1.Name = "uiScrollingText1"; + this.uiScrollingText1.ScrollingType = Sunny.UI.UIScrollingText.UIScrollingType.LeftToRight; + this.uiScrollingText1.Size = new System.Drawing.Size(322, 35); + this.uiScrollingText1.Style = Sunny.UI.UIStyle.Custom; + this.uiScrollingText1.StyleCustomMode = true; + this.uiScrollingText1.TabIndex = 48; + this.uiScrollingText1.Text = "赠人玫瑰手有余香"; + // + // uiScrollingText2 + // + 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(27, 413); + this.uiScrollingText2.Name = "uiScrollingText2"; + this.uiScrollingText2.Size = new System.Drawing.Size(322, 35); + this.uiScrollingText2.TabIndex = 49; + this.uiScrollingText2.Text = "赠人玫瑰手有余香"; + // // FOther // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); @@ -352,5 +394,8 @@ private UILine uiLine1; private UIScrollBar uiScrollBar4; private UIScrollBar uiScrollBar3; + private UILine uiLine6; + private UIScrollingText uiScrollingText1; + private UIScrollingText uiScrollingText2; } } \ No newline at end of file diff --git a/SunnyUI.Demo/Controls/FOther.resx b/SunnyUI.Demo/Controls/FOther.resx index 1f666f26..e2a4ce32 100644 --- a/SunnyUI.Demo/Controls/FOther.resx +++ b/SunnyUI.Demo/Controls/FOther.resx @@ -120,4 +120,7 @@ 17, 17 + + 35 + \ No newline at end of file diff --git a/SunnyUI/Controls/UIScrollingText.cs b/SunnyUI/Controls/UIScrollingText.cs new file mode 100644 index 00000000..414acb59 --- /dev/null +++ b/SunnyUI/Controls/UIScrollingText.cs @@ -0,0 +1,258 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +namespace Sunny.UI +{ + [ToolboxItem(true)] + public class UIScrollingText : UIControl + { + private readonly Timer timer = new Timer(); + private int XPos = int.MinValue; + private int XPos1 = int.MaxValue; + private int interval = 200; + private int TextWidth = Int32.MinValue; + + public UIScrollingText() + { + fillColor = UIStyles.Blue.PlainColor; + foreColor = UIStyles.Blue.RectColor; + Reset(); + + timer.Interval = interval; + timer.Tick += Timer_Tick; + timer.Start(); + } + + private void Reset() + { + XPos = int.MinValue; + XPos1 = int.MaxValue; + } + + ~UIScrollingText() + { + timer.Stop(); + } + + [DefaultValue(200),Description("刷新间隔")] + public int Interval + { + get => interval; + set + { + interval = Math.Max(value,50); + timer.Stop(); + timer.Interval = interval; + timer.Start(); + } + } + + private int offset = 10; + + [DefaultValue(10),Description("偏移量")] + public int Offset + { + get => offset; + set => offset = Math.Max(2, value); + } + + private void Timer_Tick(object sender, EventArgs e) + { + if (XPos == Int32.MinValue) + { + Invalidate(); + } + else + { + if (ScrollingType == UIScrollingType.RightToLeft) + { + XPos -= Offset; + if (XPos + TextWidth < 0) + { + XPos = XPos1 - Offset; + XPos1 = int.MaxValue; + } + } + + if (ScrollingType == UIScrollingType.LeftToRight) + { + XPos += Offset; + if (XPos > Width) + { + XPos = XPos1 + Offset; + XPos1 = int.MaxValue; + } + } + + Invalidate(); + } + } + + protected override void OnClick(EventArgs e) + { + timer.Enabled = !timer.Enabled; + base.OnClick(e); + } + + protected override void OnPaintFore(Graphics g, GraphicsPath path) + { + SizeF sf = g.MeasureString(Text, Font); + int y = (int)((Height - sf.Height) / 2); + + if (XPos == int.MinValue) + { + XPos = (int)((Width - sf.Width) / 2); + TextWidth = (int)sf.Width; + } + + g.DrawString(Text, Font, ForeColor, XPos, y); + + if (ScrollingType == UIScrollingType.LeftToRight) + { + if (TextWidth <= Width) + { + if (XPos + TextWidth > Width) + { + XPos1 = XPos - Width; + g.DrawString(Text, Font, ForeColor, XPos1, y); + } + } + else + { + if (XPos > 0) + { + if (XPos1 == int.MaxValue) + XPos1 = Offset - TextWidth; + else + XPos1 += Offset; + + g.DrawString(Text, Font, ForeColor, XPos1, y); + } + } + } + + if (ScrollingType == UIScrollingType.RightToLeft) + { + if (TextWidth <= Width) + { + if (XPos < 0) + { + XPos1 = Width + XPos; + g.DrawString(Text, Font, ForeColor, XPos1, y); + } + } + else + { + if (XPos + TextWidth < Width - Offset) + { + if (XPos1 == int.MaxValue) + XPos1 = Width - Offset; + else + XPos1 -= Offset; + + g.DrawString(Text, Font, ForeColor, XPos1, y); + } + } + } + } + + protected override void OnSizeChanged(EventArgs e) + { + Reset(); + base.OnSizeChanged(e); + } + + private UIScrollingType scrollingType; + + [DefaultValue(UIScrollingType.RightToLeft), Description("滚动方向")] + public UIScrollingType ScrollingType + { + get => scrollingType; + set + { + scrollingType = value; + Reset(); + Invalidate(); + } + } + + protected override void OnTextChanged(EventArgs e) + { + Reset(); + base.OnTextChanged(e); + } + + public enum UIScrollingType + { + RightToLeft, + LeftToRight + } + + public override void SetStyleColor(UIBaseStyle uiColor) + { + base.SetStyleColor(uiColor); + if (uiColor.IsCustom()) return; + + fillColor = uiColor.PlainColor; + foreColor = uiColor.RectColor; + Invalidate(); + } + + /// + /// 填充颜色,当值为背景色或透明色或空值则不填充 + /// + [Description("填充颜色"), Category("自定义")] + [DefaultValue(typeof(Color), "80, 160, 255")] + public Color FillColor + { + get => fillColor; + set => SetFillColor(value); + } + + /// + /// 字体颜色 + /// + [Description("字体颜色"), Category("自定义")] + [DefaultValue(typeof(Color), "White")] + public override Color ForeColor + { + get => foreColor; + set => SetForeColor(value); + } + + [DefaultValue(typeof(Color), "244, 244, 244")] + public Color FillDisableColor + { + get => fillDisableColor; + set => SetFillDisableColor(value); + } + + [DefaultValue(typeof(Color), "173, 178, 181")] + public Color RectDisableColor + { + get => rectDisableColor; + set => SetRectDisableColor(value); + } + + [DefaultValue(typeof(Color), "109, 109, 103")] + public Color ForeDisableColor + { + get => foreDisableColor; + set => SetForeDisableColor(value); + } + + /// + /// 边框颜色 + /// + [Description("边框颜色"), Category("自定义")] + [DefaultValue(typeof(Color), "80, 160, 255")] + public Color RectColor + { + get => rectColor; + set => SetRectColor(value); + } + } +} \ No newline at end of file diff --git a/SunnyUI/SunnyUI.csproj b/SunnyUI/SunnyUI.csproj index d577eaa0..7fdf1a41 100644 --- a/SunnyUI/SunnyUI.csproj +++ b/SunnyUI/SunnyUI.csproj @@ -114,6 +114,9 @@ UserControl + + Component + UserControl diff --git a/Updates.txt b/Updates.txt index 43b7d846..b76aae86 100644 --- a/Updates.txt +++ b/Updates.txt @@ -1,5 +1,8 @@ + ӣ - ɾ * ޸ +2020.06.25 ++ UIScrollingTextӿؼ + 2020.06.24 + UICheckBoxGroupȫѡȫѡѡ