* UIHeaderButton: 增加字体图标背景时鼠标移上背景色

This commit is contained in:
Sunny 2021-03-27 21:22:54 +08:00
parent b483f27724
commit 02fc4e38d5
7 changed files with 28 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -181,6 +181,7 @@ namespace Sunny.UI.Demo
// uiHeaderButton1
//
this.uiHeaderButton1.CircleColor = System.Drawing.Color.RoyalBlue;
this.uiHeaderButton1.CircleHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
this.uiHeaderButton1.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiHeaderButton1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.uiHeaderButton1.Location = new System.Drawing.Point(100, 1);
@ -190,6 +191,7 @@ namespace Sunny.UI.Demo
this.uiHeaderButton1.Radius = 0;
this.uiHeaderButton1.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
this.uiHeaderButton1.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None;
this.uiHeaderButton1.ShowCircleHoverColor = true;
this.uiHeaderButton1.Size = new System.Drawing.Size(100, 88);
this.uiHeaderButton1.Style = Sunny.UI.UIStyle.Custom;
this.uiHeaderButton1.Symbol = 61461;

View File

@ -17,6 +17,7 @@
* : 2021-02-10
*
* 2021-02-10: V3.0.1
* 2021-03-27: V3.0.2
******************************************************************************/
@ -283,6 +284,24 @@ namespace Sunny.UI
}
}
[DefaultValue(false)]
[Description("是否显示字体图标鼠标移上背景颜色"), Category("SunnyUI")]
public bool ShowCircleHoverColor { get; set; }
private Color circleHoverColor = Color.Bisque;
[DefaultValue(typeof(Color), "Bisque")]
[Description("字体图标鼠标移上背景颜色"), Category("SunnyUI")]
public Color CircleHoverColor
{
get => circleHoverColor;
set
{
circleHoverColor = value;
Invalidate();
}
}
protected override void OnPaddingChanged(EventArgs e)
{
base.OnPaddingChanged(e);
@ -397,7 +416,6 @@ namespace Sunny.UI
//重绘父类
base.OnPaint(e);
SizeF ImageSize = new SizeF(0, 0);
if (Symbol > 0)
ImageSize = e.Graphics.GetFontImageSize(Symbol, SymbolSize);
@ -407,7 +425,13 @@ namespace Sunny.UI
//字体图标
if (Symbol > 0 && Image == null)
{
e.Graphics.FillEllipse(CircleColor, (Width - CircleSize) / 2.0f, Padding.Top, CircleSize, CircleSize);
Color bcColor = CircleColor;
if (ShowCircleHoverColor && IsHover)
{
bcColor = CircleHoverColor;
}
e.Graphics.FillEllipse(bcColor, (Width - CircleSize) / 2.0f, Padding.Top, CircleSize, CircleSize);
e.Graphics.DrawFontImage(Symbol, SymbolSize, SymbolColor,
new RectangleF(
symbolOffset.X + (Width - CircleSize) / 2.0f,