diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll
index 03855800..42dfed2a 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 14aec323..754164d7 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 43619208..2150f96c 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 37a01438..a84074f5 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 18bf2ec3..dcd03eb7 100644
Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ
diff --git a/SunnyUI/Controls/UILabel.cs b/SunnyUI/Controls/UILabel.cs
index 879dcf56..7f95ba85 100644
--- a/SunnyUI/Controls/UILabel.cs
+++ b/SunnyUI/Controls/UILabel.cs
@@ -25,7 +25,6 @@ using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
-using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Sunny.UI
@@ -113,231 +112,6 @@ namespace Sunny.UI
}
}
- [ToolboxItem(true)]
- [DefaultEvent("Click")]
- [DefaultProperty("Text")]
- public sealed class UISymbolLabel : UIControl
- {
- private int _symbolSize = 24;
- private int _imageInterval = 2;
-
- private Color symbolColor = UIFontColor.Primary;
-
- public UISymbolLabel()
- {
- SetStyleFlags(true, false);
- ShowRect = false;
- foreColor = UIFontColor.Primary;
- symbolColor = UIFontColor.Primary;
- Width = 170;
- Height = 35;
- }
-
- private bool autoSize;
-
- [Browsable(true)]
- [Description("自动大小"), Category("SunnyUI")]
- public override bool AutoSize
- {
- get => autoSize;
- set
- {
- autoSize = value;
- Invalidate();
- }
- }
-
- [Description("图标颜色"), Category("SunnyUI")]
- [DefaultValue(typeof(Color), "48, 48, 48")]
- public Color SymbolColor
- {
- get => symbolColor;
- set
- {
- symbolColor = value;
- Invalidate();
- }
- }
-
- ///
- /// 字体颜色
- ///
- [Description("字体颜色"), Category("SunnyUI")]
- [DefaultValue(typeof(Color), "48, 48, 48")]
- public override Color ForeColor
- {
- get => foreColor;
- set => SetForeColor(value);
- }
-
- [DefaultValue(24)]
- [Description("字体大小"), Category("SunnyUI")]
- public int SymbolSize
- {
- get => _symbolSize;
- set
- {
- _symbolSize = Math.Max(value, 16);
- _symbolSize = Math.Min(value, 64);
- Invalidate();
- }
- }
-
- [DefaultValue(2)]
- [Description("图标和文字间间隔"), Category("SunnyUI")]
- public int ImageInterval
- {
- get => _imageInterval;
- set
- {
- _imageInterval = Math.Max(0, value);
- Invalidate();
- }
- }
-
- private bool _isCircle;
-
- [DefaultValue(false)]
- [Description("显示为圆形"), Category("SunnyUI")]
- public bool IsCircle
- {
- get => _isCircle;
- set
- {
- _isCircle = value;
- if (value)
- {
- Text = "";
- }
- else
- {
- Invalidate();
- }
- }
- }
-
- private int _symbol = FontAwesomeIcons.fa_check;
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
- [Editor(typeof(UIImagePropertyEditor), typeof(UITypeEditor))]
- [DefaultValue(61452)]
- [Description("字体图标"), Category("SunnyUI")]
- public int Symbol
- {
- get => _symbol;
- set
- {
- _symbol = value;
- Invalidate();
- }
- }
-
- protected override void OnPaintFill(Graphics g, GraphicsPath path)
- {
- g.FillRectangle(BackColor, Bounds);
- }
-
- private int circleRectWidth = 1;
-
- [DefaultValue(1)]
- [Description("圆形边框大小"), Category("SunnyUI")]
- public int CircleRectWidth
- {
- get => circleRectWidth;
- set
- {
- circleRectWidth = value;
- Invalidate();
- }
- }
-
- protected override void OnPaintRect(Graphics g, GraphicsPath path)
- {
- if (IsCircle)
- {
- int size = Math.Min(Width, Height) - 2 - CircleRectWidth;
- using (Pen pn = new Pen(GetRectColor(), CircleRectWidth))
- {
- g.SetHighQuality();
- g.DrawEllipse(pn, (Width - size) / 2.0f, (Height - size) / 2.0f, size, size);
- g.SetDefaultQuality();
- }
- }
- else
- {
- base.OnPaintRect(g, path);
- }
- }
-
- protected override void OnPaintFore(Graphics g, GraphicsPath path)
- {
- Padding = new Padding(_symbolSize + _imageInterval * 2, Padding.Top, Padding.Right, Padding.Bottom);
- //填充文字
- g.DrawString(Text, Font, foreColor, Size, Padding, TextAlign);
- }
-
- public override void SetStyleColor(UIBaseStyle uiColor)
- {
- base.SetStyleColor(uiColor);
- if (uiColor.IsCustom()) return;
-
- symbolColor = foreColor = uiColor.LabelForeColor;
- }
-
- protected override void OnPaint(PaintEventArgs e)
- {
- //重绘父类
- base.OnPaint(e);
-
- float left = 0;
- float top = 0;
- SizeF ImageSize = e.Graphics.GetFontImageSize(Symbol, SymbolSize);
- SizeF TextSize = e.Graphics.MeasureString(Text, Font);
-
- if (autoSize)
- {
- Width = (int)(SymbolSize + ImageInterval * 3 + TextSize.Width);
- Height = (int)Math.Max(SymbolSize, TextSize.Height);
- }
-
- if (TextAlign == ContentAlignment.TopCenter || TextAlign == ContentAlignment.TopLeft || TextAlign == ContentAlignment.TopRight)
- {
- top = Padding.Top;
- }
-
- if (TextAlign == ContentAlignment.MiddleCenter || TextAlign == ContentAlignment.MiddleLeft || TextAlign == ContentAlignment.MiddleRight)
- {
- top = Padding.Top + (Height - Padding.Top - Padding.Bottom - ImageSize.Height) / 2.0f;
- }
-
- if (TextAlign == ContentAlignment.BottomCenter || TextAlign == ContentAlignment.BottomLeft || TextAlign == ContentAlignment.BottomRight)
- {
- top = Height - Padding.Bottom - ImageSize.Height;
- }
-
- if (TextAlign == ContentAlignment.TopCenter || TextAlign == ContentAlignment.MiddleCenter || TextAlign == ContentAlignment.BottomCenter)
- {
- left = Padding.Left + (Width - TextSize.Width - Padding.Left - Padding.Right) / 2.0f;
- left = left - ImageInterval - ImageSize.Width;
- }
-
- if (TextAlign == ContentAlignment.TopLeft || TextAlign == ContentAlignment.MiddleLeft || TextAlign == ContentAlignment.BottomLeft)
- {
- left = ImageInterval;
- }
-
- if (TextAlign == ContentAlignment.TopRight || TextAlign == ContentAlignment.MiddleRight || TextAlign == ContentAlignment.BottomRight)
- {
- left = Width - Padding.Right - TextSize.Width - ImageInterval - ImageSize.Width;
- }
-
- if (Text.IsNullOrEmpty())
- e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor, ImageInterval + (Width - ImageSize.Width) / 2.0f, (Height - ImageSize.Height) / 2.0f);
- else
- e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor, left, top);
- }
- }
-
[ToolboxItem(true)]
[DefaultEvent("Click")]
[DefaultProperty("Text")]
diff --git a/SunnyUI/Controls/UISymbolLabel.cs b/SunnyUI/Controls/UISymbolLabel.cs
new file mode 100644
index 00000000..ca9af759
--- /dev/null
+++ b/SunnyUI/Controls/UISymbolLabel.cs
@@ -0,0 +1,255 @@
+/******************************************************************************
+ * 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.
+ * 如果您使用此代码,请保留此说明。
+ ******************************************************************************
+ * 文件名称: UISymbolLabel.cs
+ * 文件说明: 带字体图标的标签
+ * 当前版本: V3.0
+ * 创建日期: 2020-01-01
+ *
+ * 2020-04-23: V2.2.4 增加UISymbolLabel
+******************************************************************************/
+
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Design;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+
+namespace Sunny.UI
+{
+ [ToolboxItem(true)]
+ [DefaultEvent("Click")]
+ [DefaultProperty("Text")]
+ public sealed class UISymbolLabel : UIControl
+ {
+ private int _symbolSize = 24;
+ private int _imageInterval = 2;
+
+ private Color symbolColor = UIFontColor.Primary;
+
+ public UISymbolLabel()
+ {
+ SetStyleFlags(true, false);
+ ShowRect = false;
+ foreColor = UIFontColor.Primary;
+ symbolColor = UIFontColor.Primary;
+ Width = 170;
+ Height = 35;
+ }
+
+ private bool autoSize;
+
+ [Browsable(true)]
+ [Description("自动大小"), Category("SunnyUI")]
+ public override bool AutoSize
+ {
+ get => autoSize;
+ set
+ {
+ autoSize = value;
+ Invalidate();
+ }
+ }
+
+ [Description("图标颜色"), Category("SunnyUI")]
+ [DefaultValue(typeof(Color), "48, 48, 48")]
+ public Color SymbolColor
+ {
+ get => symbolColor;
+ set
+ {
+ symbolColor = value;
+ Invalidate();
+ }
+ }
+
+ ///
+ /// 字体颜色
+ ///
+ [Description("字体颜色"), Category("SunnyUI")]
+ [DefaultValue(typeof(Color), "48, 48, 48")]
+ public override Color ForeColor
+ {
+ get => foreColor;
+ set => SetForeColor(value);
+ }
+
+ [DefaultValue(24)]
+ [Description("字体大小"), Category("SunnyUI")]
+ public int SymbolSize
+ {
+ get => _symbolSize;
+ set
+ {
+ _symbolSize = Math.Max(value, 16);
+ _symbolSize = Math.Min(value, 64);
+ Invalidate();
+ }
+ }
+
+ [DefaultValue(2)]
+ [Description("图标和文字间间隔"), Category("SunnyUI")]
+ public int ImageInterval
+ {
+ get => _imageInterval;
+ set
+ {
+ _imageInterval = Math.Max(0, value);
+ Invalidate();
+ }
+ }
+
+ private bool _isCircle;
+
+ [DefaultValue(false)]
+ [Description("显示为圆形"), Category("SunnyUI")]
+ public bool IsCircle
+ {
+ get => _isCircle;
+ set
+ {
+ _isCircle = value;
+ if (value)
+ {
+ Text = "";
+ }
+ else
+ {
+ Invalidate();
+ }
+ }
+ }
+
+ private int _symbol = FontAwesomeIcons.fa_check;
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
+ [Editor(typeof(UIImagePropertyEditor), typeof(UITypeEditor))]
+ [DefaultValue(61452)]
+ [Description("字体图标"), Category("SunnyUI")]
+ public int Symbol
+ {
+ get => _symbol;
+ set
+ {
+ _symbol = value;
+ Invalidate();
+ }
+ }
+
+ protected override void OnPaintFill(Graphics g, GraphicsPath path)
+ {
+ g.FillRectangle(BackColor, Bounds);
+ }
+
+ private int circleRectWidth = 1;
+
+ [DefaultValue(1)]
+ [Description("圆形边框大小"), Category("SunnyUI")]
+ public int CircleRectWidth
+ {
+ get => circleRectWidth;
+ set
+ {
+ circleRectWidth = value;
+ Invalidate();
+ }
+ }
+
+ protected override void OnPaintRect(Graphics g, GraphicsPath path)
+ {
+ if (IsCircle)
+ {
+ int size = Math.Min(Width, Height) - 2 - CircleRectWidth;
+ using (Pen pn = new Pen(GetRectColor(), CircleRectWidth))
+ {
+ g.SetHighQuality();
+ g.DrawEllipse(pn, (Width - size) / 2.0f, (Height - size) / 2.0f, size, size);
+ g.SetDefaultQuality();
+ }
+ }
+ else
+ {
+ base.OnPaintRect(g, path);
+ }
+ }
+
+ protected override void OnPaintFore(Graphics g, GraphicsPath path)
+ {
+ Padding = new Padding(_symbolSize + _imageInterval * 2, Padding.Top, Padding.Right, Padding.Bottom);
+ //填充文字
+ g.DrawString(Text, Font, foreColor, Size, Padding, TextAlign);
+ }
+
+ public override void SetStyleColor(UIBaseStyle uiColor)
+ {
+ base.SetStyleColor(uiColor);
+ if (uiColor.IsCustom()) return;
+
+ symbolColor = foreColor = uiColor.LabelForeColor;
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ //重绘父类
+ base.OnPaint(e);
+
+ float left = 0;
+ float top = 0;
+ SizeF ImageSize = e.Graphics.GetFontImageSize(Symbol, SymbolSize);
+ SizeF TextSize = e.Graphics.MeasureString(Text, Font);
+
+ if (autoSize)
+ {
+ Width = (int)(SymbolSize + ImageInterval * 3 + TextSize.Width);
+ Height = (int)Math.Max(SymbolSize, TextSize.Height);
+ }
+
+ if (TextAlign == ContentAlignment.TopCenter || TextAlign == ContentAlignment.TopLeft || TextAlign == ContentAlignment.TopRight)
+ {
+ top = Padding.Top;
+ }
+
+ if (TextAlign == ContentAlignment.MiddleCenter || TextAlign == ContentAlignment.MiddleLeft || TextAlign == ContentAlignment.MiddleRight)
+ {
+ top = Padding.Top + (Height - Padding.Top - Padding.Bottom - ImageSize.Height) / 2.0f;
+ }
+
+ if (TextAlign == ContentAlignment.BottomCenter || TextAlign == ContentAlignment.BottomLeft || TextAlign == ContentAlignment.BottomRight)
+ {
+ top = Height - Padding.Bottom - ImageSize.Height;
+ }
+
+ if (TextAlign == ContentAlignment.TopCenter || TextAlign == ContentAlignment.MiddleCenter || TextAlign == ContentAlignment.BottomCenter)
+ {
+ left = Padding.Left + (Width - TextSize.Width - Padding.Left - Padding.Right) / 2.0f;
+ left = left - ImageInterval - ImageSize.Width;
+ }
+
+ if (TextAlign == ContentAlignment.TopLeft || TextAlign == ContentAlignment.MiddleLeft || TextAlign == ContentAlignment.BottomLeft)
+ {
+ left = ImageInterval;
+ }
+
+ if (TextAlign == ContentAlignment.TopRight || TextAlign == ContentAlignment.MiddleRight || TextAlign == ContentAlignment.BottomRight)
+ {
+ left = Width - Padding.Right - TextSize.Width - ImageInterval - ImageSize.Width;
+ }
+
+ if (Text.IsNullOrEmpty())
+ e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor, ImageInterval + (Width - ImageSize.Width) / 2.0f, (Height - ImageSize.Height) / 2.0f);
+ else
+ e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor, left, top);
+ }
+ }
+}
diff --git a/SunnyUI/Style/UIStyle.cs b/SunnyUI/Style/UIStyle.cs
index bd67bed1..f9d9ab0e 100644
--- a/SunnyUI/Style/UIStyle.cs
+++ b/SunnyUI/Style/UIStyle.cs
@@ -101,8 +101,8 @@ namespace Sunny.UI
///
/// 紫
///
- [DisplayText("Purple")]
- Purple = 9,
+ //[DisplayText("Purple")]
+ //Purple = 9,
///
/// Office蓝
@@ -284,7 +284,7 @@ namespace Sunny.UI
AddStyle(DarkBlue);
AddStyle(Black);
AddStyle(White);
- AddStyle(PurpleStyle);
+ //AddStyle(PurpleStyle);
AddStyle(Office2010Blue);
AddStyle(Office2010Silver);
AddStyle(Office2010Black);
@@ -510,7 +510,7 @@ namespace Sunny.UI
///
/// 紫
///
- public static readonly Color Purple = Color.FromArgb(184, 36, 255);// Color.FromArgb(123, 81, 201);
+ public static readonly Color Purple = Color.FromArgb(102, 58, 183);// Color.FromArgb(123, 81, 201);
///
/// 浅紫
diff --git a/SunnyUI/Style/UIStyleColor.cs b/SunnyUI/Style/UIStyleColor.cs
index 874a73e5..7bb83851 100644
--- a/SunnyUI/Style/UIStyleColor.cs
+++ b/SunnyUI/Style/UIStyleColor.cs
@@ -31,10 +31,10 @@ namespace Sunny.UI
{
public abstract UIStyle Name { get; }
- public abstract Color PrimaryColor { get; }
- public abstract Color RegularColor { get; }
- public abstract Color SecondaryColor { get; }
- public abstract Color PlainColor { get; }
+ public virtual Color PrimaryColor { get; protected set; }
+ public virtual Color RegularColor { get; protected set; }
+ public virtual Color SecondaryColor { get; protected set; }
+ public virtual Color PlainColor { get; protected set; }
public abstract Color RectColor { get; }
public abstract Color RectHoverColor { get; }
@@ -44,9 +44,9 @@ namespace Sunny.UI
public abstract Color ButtonForeSelectedColor { get; }
public abstract Color ButtonFillSelectedColor { get; }
- public abstract Color ButtonFillColor { get; }
- public abstract Color ButtonFillHoverColor { get; }
- public abstract Color ButtonFillPressColor { get; }
+ public virtual Color ButtonFillColor { get; protected set; }
+ public virtual Color ButtonFillHoverColor { get; protected set; }
+ public virtual Color ButtonFillPressColor { get; protected set; }
public abstract Color ButtonForeColor { get; }
public abstract Color ButtonForeHoverColor { get; }
@@ -72,7 +72,7 @@ namespace Sunny.UI
public virtual Color MenuSelectedColor => UIColor.Blue;
- public virtual Color GridSelectedColor => Color.FromArgb(155, 200, 255);
+ public virtual Color GridSelectedColor { get; protected set; } = Color.FromArgb(155, 200, 255);
public virtual Color GridSelectedForeColor => UIFontColor.Primary;
public virtual Color GridStripeEvenColor => Color.White;
@@ -129,6 +129,49 @@ namespace Sunny.UI
}
}
+ public class UIPurpleStyle : UIBaseStyle
+ {
+ public UIPurpleStyle()
+ {
+ PrimaryColor = UIColor.Purple;
+ Color[] colors = GDIEx.GradientColors(Color.White, PrimaryColor, 16);
+ Color[] colors1 = GDIEx.GradientColors(PrimaryColor, Color.Black, 16);
+ PlainColor = colors[1];
+ SecondaryColor = colors[5];
+ RegularColor = colors[10];
+
+ ButtonFillColor = PrimaryColor;
+ ButtonFillHoverColor = colors[12];
+ ButtonFillPressColor = colors1[3];
+ GridSelectedColor = colors[3];
+ }
+
+ public override UIStyle Name => UIStyle.Blue;
+
+ public override Color PrimaryColor { get; protected set; }
+ public override Color RegularColor { get; protected set; }
+ public override Color SecondaryColor { get; protected set; }
+ public override Color PlainColor { get; protected set; }
+
+ public override Color ButtonFillColor { get; protected set; }
+ public override Color ButtonFillHoverColor { get; protected set; }
+ public override Color ButtonFillPressColor { get; protected set; }
+
+ public override Color ButtonForeColor => Color.White;
+ public override Color ButtonForeHoverColor => Color.White;
+ public override Color ButtonForePressColor => Color.White;
+ public override Color RectSelectedColor => RectPressColor;
+ public override Color ButtonForeSelectedColor => ButtonForePressColor;
+ public override Color ButtonFillSelectedColor => ButtonFillPressColor;
+ public override Color RectColor => UIColor.Purple;
+ public override Color RectHoverColor => ButtonFillHoverColor;
+ public override Color RectPressColor => ButtonFillPressColor;
+ public override Color TitleColor => UIColor.Purple;
+ public override Color TitleForeColor => Color.White;
+ public override Color MenuSelectedColor => UIColor.Purple;
+ public override Color GridSelectedColor { get; protected set; }
+ }
+
public class UICustomStyle : UIBlueStyle
{
public override UIStyle Name => UIStyle.Custom;
@@ -227,31 +270,6 @@ namespace Sunny.UI
public override Color TitleForeColor => Color.White;
}
- public class UIPurpleStyle : UIBaseStyle
- {
- public override UIStyle Name => UIStyle.Purple;
- public override Color PrimaryColor => UIColor.Purple;
- public override Color RegularColor => Color.FromArgb(201, 89, 255);
- public override Color SecondaryColor => Color.FromArgb(220, 147, 255);
- public override Color PlainColor => UIColor.LightPurple;
- public override Color ButtonFillColor => UIColor.Purple;
- public override Color ButtonFillHoverColor => Color.FromArgb(194, 70, 255);
- public override Color ButtonFillPressColor => Color.FromArgb(172, 0, 255);
- public override Color ButtonForeColor => Color.White;
- public override Color ButtonForeHoverColor => Color.White;
- public override Color ButtonForePressColor => Color.White;
- public override Color RectSelectedColor => RectPressColor;
- public override Color ButtonForeSelectedColor => ButtonForePressColor;
- public override Color ButtonFillSelectedColor => ButtonFillPressColor;
- public override Color RectColor => UIColor.Purple;
- public override Color RectHoverColor => Color.FromArgb(194, 70, 255);
- public override Color RectPressColor => Color.FromArgb(172, 0, 255);
- public override Color TitleColor => UIColor.Purple;
- public override Color TitleForeColor => Color.White;
- public override Color MenuSelectedColor => UIColor.Purple;
- public override Color GridSelectedColor => Color.FromArgb(230, 176, 255);
- }
-
public class UILightBlueStyle : UIBaseStyle
{
public override UIStyle Name => UIStyle.LightBlue;
diff --git a/SunnyUI/SunnyUI.csproj b/SunnyUI/SunnyUI.csproj
index 4b9f08ce..fe609dfa 100644
--- a/SunnyUI/SunnyUI.csproj
+++ b/SunnyUI/SunnyUI.csproj
@@ -42,6 +42,7 @@
+
True