*UISymbolButton: 字体图标增加颜色设置

This commit is contained in:
Sunny 2022-01-05 09:59:06 +08:00
parent 5b0f056f49
commit 54ad9892e8
4 changed files with 28 additions and 4 deletions

Binary file not shown.

Binary file not shown.

View File

@ -279,7 +279,7 @@ namespace Sunny.UI
Invalidate();
}
private UIStyle _style = UIStyle.Blue;
protected UIStyle _style = UIStyle.Blue;
/// <summary>
/// 主题样式

View File

@ -18,6 +18,7 @@
*
* 2020-01-01: V2.2.0
* 2020-07-26: V2.2.6 Image属性
* 2022-01-05: V3.0.9
******************************************************************************/
using System;
@ -54,6 +55,29 @@ namespace Sunny.UI
}
}
private Color symbolColor = Color.White;
[Description("图标颜色"), Category("SunnyUI")]
[DefaultValue(typeof(Color), "White")]
public Color SymbolColor
{
get => symbolColor;
set
{
if (symbolColor != value)
{
symbolColor = value;
_style = UIStyle.Custom;
Invalidate();
}
}
}
public override void SetStyleColor(UIBaseStyle uiColor)
{
symbolColor = uiColor.ButtonForeColor;
base.SetStyleColor(uiColor);
}
[DefaultValue(null)]
[Description("图片"), Category("SunnyUI")]
public Image Image
@ -215,7 +239,7 @@ namespace Sunny.UI
{
if (Symbol > 0 && Image == null)
{
e.Graphics.DrawFontImage(Symbol, SymbolSize, color,
e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor,
new RectangleF(
(Width - ImageSize.Width) / 2.0f,
Padding.Top + (Height - ImageSize.Height - Padding.Top - Padding.Bottom) / 2.0f,
@ -237,7 +261,7 @@ namespace Sunny.UI
if (Symbol > 0 && Image == null)
{
e.Graphics.DrawFontImage(Symbol, SymbolSize, color,
e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor,
new RectangleF((Width - allWidth) / 2.0f, (Height - ImageSize.Height) / 2.0f, ImageSize.Width, ImageSize.Height), SymbolOffset.X, SymbolOffset.Y);
}
@ -308,7 +332,7 @@ namespace Sunny.UI
if (Symbol > 0 && Image == null)
{
e.Graphics.DrawFontImage(Symbol, SymbolSize, color,
e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor,
new RectangleF(left, top, ImageSize.Width, ImageSize.Height), SymbolOffset.X, SymbolOffset.Y);
}