diff --git a/Bin/net40/SunnyUI.Demo.exe b/Bin/net40/SunnyUI.Demo.exe index 5aa42314..0bfb5954 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 3cb91732..89144851 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/SunnyUI.dll b/Bin/net5.0-windows/SunnyUI.dll index 1c01cd39..8e89f660 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 447a02d6..c877d671 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 1153b5ea..3c3476b7 100644 Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ diff --git a/SunnyUI.Demo/Controls/FLabel.Designer.cs b/SunnyUI.Demo/Controls/FLabel.Designer.cs index 3c8388b3..e8e4f725 100644 --- a/SunnyUI.Demo/Controls/FLabel.Designer.cs +++ b/SunnyUI.Demo/Controls/FLabel.Designer.cs @@ -35,11 +35,21 @@ this.uiLine3 = new Sunny.UI.UILine(); this.uiSymbolLabel1 = new Sunny.UI.UISymbolLabel(); this.uiSymbolLabel2 = new Sunny.UI.UISymbolLabel(); + this.uiMarkLabel1 = new Sunny.UI.UIMarkLabel(); + this.uiLine4 = new Sunny.UI.UILine(); + this.uiMarkLabel2 = new Sunny.UI.UIMarkLabel(); + this.uiMarkLabel3 = new Sunny.UI.UIMarkLabel(); + this.uiMarkLabel4 = new Sunny.UI.UIMarkLabel(); this.PagePanel.SuspendLayout(); this.SuspendLayout(); // // PagePanel // + this.PagePanel.Controls.Add(this.uiMarkLabel4); + this.PagePanel.Controls.Add(this.uiMarkLabel3); + this.PagePanel.Controls.Add(this.uiMarkLabel2); + this.PagePanel.Controls.Add(this.uiLine4); + this.PagePanel.Controls.Add(this.uiMarkLabel1); this.PagePanel.Controls.Add(this.uiSymbolLabel2); this.PagePanel.Controls.Add(this.uiSymbolLabel1); this.PagePanel.Controls.Add(this.uiLine3); @@ -113,6 +123,7 @@ // this.uiSymbolLabel1.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiSymbolLabel1.Location = new System.Drawing.Point(42, 209); + this.uiSymbolLabel1.MinimumSize = new System.Drawing.Size(1, 1); this.uiSymbolLabel1.Name = "uiSymbolLabel1"; this.uiSymbolLabel1.Padding = new System.Windows.Forms.Padding(28, 0, 0, 0); this.uiSymbolLabel1.Size = new System.Drawing.Size(91, 24); @@ -124,6 +135,7 @@ // this.uiSymbolLabel2.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiSymbolLabel2.Location = new System.Drawing.Point(139, 209); + this.uiSymbolLabel2.MinimumSize = new System.Drawing.Size(1, 1); this.uiSymbolLabel2.Name = "uiSymbolLabel2"; this.uiSymbolLabel2.Padding = new System.Windows.Forms.Padding(28, 0, 0, 0); this.uiSymbolLabel2.Size = new System.Drawing.Size(91, 24); @@ -132,6 +144,64 @@ this.uiSymbolLabel2.Text = "Cancel"; this.uiSymbolLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // + // uiMarkLabel1 + // + this.uiMarkLabel1.AutoSize = true; + this.uiMarkLabel1.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiMarkLabel1.Location = new System.Drawing.Point(42, 285); + this.uiMarkLabel1.Name = "uiMarkLabel1"; + this.uiMarkLabel1.Padding = new System.Windows.Forms.Padding(5, 0, 0, 0); + this.uiMarkLabel1.Size = new System.Drawing.Size(118, 21); + this.uiMarkLabel1.TabIndex = 24; + this.uiMarkLabel1.Text = "uiMarkLabel1"; + // + // uiLine4 + // + this.uiLine4.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiLine4.Location = new System.Drawing.Point(30, 248); + this.uiLine4.MinimumSize = new System.Drawing.Size(16, 16); + this.uiLine4.Name = "uiLine4"; + this.uiLine4.Size = new System.Drawing.Size(670, 20); + this.uiLine4.TabIndex = 25; + this.uiLine4.Text = "UIMarkLabel"; + this.uiLine4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // uiMarkLabel2 + // + this.uiMarkLabel2.AutoSize = true; + this.uiMarkLabel2.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiMarkLabel2.Location = new System.Drawing.Point(42, 326); + this.uiMarkLabel2.MarkPos = Sunny.UI.UIMarkLabel.UIMarkPos.Bottom; + this.uiMarkLabel2.Name = "uiMarkLabel2"; + this.uiMarkLabel2.Padding = new System.Windows.Forms.Padding(0, 0, 0, 5); + this.uiMarkLabel2.Size = new System.Drawing.Size(113, 26); + this.uiMarkLabel2.TabIndex = 26; + this.uiMarkLabel2.Text = "uiMarkLabel2"; + // + // uiMarkLabel3 + // + this.uiMarkLabel3.AutoSize = true; + this.uiMarkLabel3.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiMarkLabel3.Location = new System.Drawing.Point(185, 285); + this.uiMarkLabel3.MarkPos = Sunny.UI.UIMarkLabel.UIMarkPos.Right; + this.uiMarkLabel3.Name = "uiMarkLabel3"; + this.uiMarkLabel3.Padding = new System.Windows.Forms.Padding(0, 0, 5, 0); + this.uiMarkLabel3.Size = new System.Drawing.Size(118, 21); + this.uiMarkLabel3.TabIndex = 27; + this.uiMarkLabel3.Text = "uiMarkLabel3"; + // + // uiMarkLabel4 + // + this.uiMarkLabel4.AutoSize = true; + this.uiMarkLabel4.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiMarkLabel4.Location = new System.Drawing.Point(190, 326); + this.uiMarkLabel4.MarkPos = Sunny.UI.UIMarkLabel.UIMarkPos.Top; + this.uiMarkLabel4.Name = "uiMarkLabel4"; + this.uiMarkLabel4.Padding = new System.Windows.Forms.Padding(0, 5, 0, 0); + this.uiMarkLabel4.Size = new System.Drawing.Size(113, 26); + this.uiMarkLabel4.TabIndex = 28; + this.uiMarkLabel4.Text = "uiMarkLabel4"; + // // FLabel // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); @@ -156,5 +226,10 @@ private UILine uiLine1; private UISymbolLabel uiSymbolLabel1; private UISymbolLabel uiSymbolLabel2; + private UIMarkLabel uiMarkLabel1; + private UILine uiLine4; + private UIMarkLabel uiMarkLabel4; + private UIMarkLabel uiMarkLabel3; + private UIMarkLabel uiMarkLabel2; } } \ No newline at end of file diff --git a/SunnyUI/Controls/TypeEditor/UIDropEditor.cs b/SunnyUI/Controls/TypeEditor/UIDropEditor.cs index d14282a1..3d79a18b 100644 --- a/SunnyUI/Controls/TypeEditor/UIDropEditor.cs +++ b/SunnyUI/Controls/TypeEditor/UIDropEditor.cs @@ -25,6 +25,7 @@ using System.Drawing.Design; using System.Security.Permissions; using System.Windows.Forms; using System.Windows.Forms.Design; +#pragma warning disable SYSLIB0003 // 类型或成员已过时 namespace Sunny.UI { diff --git a/SunnyUI/Controls/TypeEditor/UIRadiusSidesEditor.cs b/SunnyUI/Controls/TypeEditor/UIRadiusSidesEditor.cs index 8c9164bb..ed6c07d2 100644 --- a/SunnyUI/Controls/TypeEditor/UIRadiusSidesEditor.cs +++ b/SunnyUI/Controls/TypeEditor/UIRadiusSidesEditor.cs @@ -26,6 +26,7 @@ using System.Runtime.InteropServices; using System.Security.Permissions; using System.Windows.Forms; using System.Windows.Forms.Design; +#pragma warning disable SYSLIB0003 // 类型或成员已过时 namespace Sunny.UI { diff --git a/SunnyUI/Controls/UILabel.cs b/SunnyUI/Controls/UILabel.cs index 60b8496f..eb70bb21 100644 --- a/SunnyUI/Controls/UILabel.cs +++ b/SunnyUI/Controls/UILabel.cs @@ -87,10 +87,9 @@ namespace Sunny.UI [Description("获取或设置可以自定义主题风格"), Category("SunnyUI")] public bool StyleCustomMode { get; set; } - public void SetStyleColor(UIBaseStyle uiColor) + public virtual void SetStyleColor(UIBaseStyle uiColor) { if (uiColor.IsCustom()) return; - ForeColor = uiColor.LabelForeColor; Invalidate(); } diff --git a/SunnyUI/Controls/UIMarkLabel.cs b/SunnyUI/Controls/UIMarkLabel.cs new file mode 100644 index 00000000..8873e18e --- /dev/null +++ b/SunnyUI/Controls/UIMarkLabel.cs @@ -0,0 +1,140 @@ +/****************************************************************************** + * SunnyUI 开源控件库、工具类库、扩展类库、多页面开发框架。 + * CopyRight (C) 2012-2021 ShenYongHua(沈永华). + * QQ群:56829229 QQ:17612584 EMail:SunnyUI@QQ.Com + * + * Blog: https://www.cnblogs.com/yhuse + * Gitee: https://gitee.com/yhuse/SunnyUI + * GitHub: https://github.com/yhuse/SunnyUI + * + * SunnyUI.dll can be used for free under the GPL-3.0 license. + * If you use this code, please keep this note. + * 如果您使用此代码,请保留此说明。 + ****************************************************************************** + * 文件名称: UIMarkLabel.cs + * 文件说明: 带颜色标签 + * 当前版本: V3.0 + * 创建日期: 2021-03-07 + * + * 2021-03-07: V3.0.2 增加文件说明 +******************************************************************************/ + +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace Sunny.UI +{ + public class UIMarkLabel : UILabel + { + public UIMarkLabel() + { + Padding = new Padding(MarkSize + 2, 0, 0, 0); + } + + private bool autoSize; + + [Browsable(true)] + [Description("自动大小"), Category("SunnyUI")] + public override bool AutoSize + { + get => autoSize; + set + { + autoSize = value; + Invalidate(); + } + } + + private int markSize = 3; + + [Description("标签大小"), Category("SunnyUI"), DefaultValue(3)] + public int MarkSize + { + get => markSize; + set + { + markSize = value; + Invalidate(); + } + } + + private UIMarkPos markPos = UIMarkPos.Left; + + [Description("标签位置"), Category("SunnyUI"), DefaultValue(UIMarkPos.Left)] + public UIMarkPos MarkPos + { + get => markPos; + set + { + markPos = value; + + switch (markPos) + { + case UIMarkPos.Left: Padding = new Padding(MarkSize + 2, 0, 0, 0); break; + case UIMarkPos.Right: Padding = new Padding(0, 0, MarkSize + 2, 0); break; + case UIMarkPos.Top: Padding = new Padding(0, MarkSize + 2, 0, 0); break; + case UIMarkPos.Bottom: Padding = new Padding(0, 0, 0, MarkSize + 2); break; + } + + Invalidate(); + } + } + + public enum UIMarkPos + { + Left, + Top, + Right, + Bottom + } + + + private Color markColor = UIColor.Blue; + + [Description("标签颜色"), Category("SunnyUI")] + [DefaultValue(typeof(Color), "80, 160, 255")] + public Color MarkColor + { + get => markColor; + set + { + markColor = value; + Invalidate(); + } + } + + public override void SetStyleColor(UIBaseStyle uiColor) + { + base.SetStyleColor(uiColor); + if (uiColor.IsCustom()) return; + markColor = uiColor.PrimaryColor; + Invalidate(); + } + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + + SizeF TextSize = e.Graphics.MeasureString(Text, Font); + if (autoSize) + { + float width = (MarkPos == UIMarkPos.Left || MarkPos == UIMarkPos.Right) ? + TextSize.Width + MarkSize + 2 : TextSize.Width; + float height = (MarkPos == UIMarkPos.Top || MarkPos == UIMarkPos.Bottom) ? + TextSize.Height + MarkSize + 2 : TextSize.Height; + + if (Width != (int)width) Width = (int)width; + if (Height != (int)height) Height = (int)height; + } + + switch (markPos) + { + case UIMarkPos.Left: e.Graphics.FillRectangle(MarkColor, 0, 0, MarkSize, Height); break; + case UIMarkPos.Right: e.Graphics.FillRectangle(MarkColor, Width - MarkSize, 0, MarkSize, Height); break; + case UIMarkPos.Top: e.Graphics.FillRectangle(MarkColor, 0, 0, Width, MarkSize); break; + case UIMarkPos.Bottom: e.Graphics.FillRectangle(MarkColor, 0, Height - MarkSize, Width, MarkSize); break; + } + } + } +} diff --git a/SunnyUI/Static/UAudio.cs b/SunnyUI/Static/UAudio.cs index c69ef919..e38f79a4 100644 --- a/SunnyUI/Static/UAudio.cs +++ b/SunnyUI/Static/UAudio.cs @@ -24,6 +24,7 @@ using System.ComponentModel; using System.Media; using System.Security; using System.Security.Permissions; +#pragma warning disable SYSLIB0003 // 类型或成员已过时 namespace Sunny.UI { diff --git a/SunnyUI/Win32/Win32.User.cs b/SunnyUI/Win32/Win32.User.cs index e471b348..83feccec 100644 --- a/SunnyUI/Win32/Win32.User.cs +++ b/SunnyUI/Win32/Win32.User.cs @@ -4,6 +4,7 @@ using System.Text; using HANDLE = System.IntPtr; using HDC = System.IntPtr; using HWND = System.IntPtr; +#pragma warning disable CS0618 // 类型或成员已过时 namespace Sunny.UI.Win32 {