* UILine: 水平方向文字不居中时,可设置线条渐变色

This commit is contained in:
Sunny 2022-11-26 10:09:39 +08:00
parent fcd3f86f49
commit b270317f31

View File

@ -20,6 +20,7 @@
* 2022-01-05: V3.0.9 线
* 2022-01-10: V3.1.0
* 2022-03-19: V3.1.1
* 2022-11-26: V3.2.9 线
******************************************************************************/
using System;
@ -93,6 +94,7 @@ namespace Sunny.UI
rectColor = uiColor.LineRectColor;
foreColor = uiColor.LineForeColor;
fillColor = uiColor.LineFillColor;
fillColor2 = uiColor.PanelFillColor2;
}
/// <summary>
@ -244,13 +246,29 @@ namespace Sunny.UI
g.DrawLine(pen, x + sf.Width + 2, top, Width - 2 - Padding.Left - Padding.Right, top);
break;
default:
g.DrawLine(pen, Padding.Left, top, Width - 2 - Padding.Left - Padding.Right, top);
if (LineColorGradient)
{
using LinearGradientBrush br = new LinearGradientBrush(new Point(0, 0), new Point(Width, 0), LineColor, LineColor2);
g.FillRectangle(br, new Rectangle(Padding.Left, top, Width - 2 - Padding.Left - Padding.Right, LineSize));
}
else
{
g.DrawLine(pen, Padding.Left, top, Width - 2 - Padding.Left - Padding.Right, top);
}
break;
}
}
else
{
g.DrawLine(pen, Padding.Left, top, Width - 2 - Padding.Left - Padding.Right, top);
if (LineColorGradient)
{
using LinearGradientBrush br = new LinearGradientBrush(new Point(0, 0), new Point(Width, 0), LineColor, LineColor2);
g.FillRectangle(br, new Rectangle(Padding.Left, top, Width - 2 - Padding.Left - Padding.Right, LineSize));
}
else
{
g.DrawLine(pen, Padding.Left, top, Width - 2 - Padding.Left - Padding.Right, top);
}
}
switch (startCap)
@ -323,14 +341,40 @@ namespace Sunny.UI
}
/// <summary>
/// 边框颜色
/// 线颜色
/// </summary>
[Description("边框颜色"), Category("SunnyUI")]
[Description("线颜色"), Category("SunnyUI")]
[DefaultValue(typeof(Color), "80, 160, 255")]
public Color LineColor
{
get => rectColor;
set => SetRectColor(value);
}
/// <summary>
/// 线颜色2
/// </summary>
[Description("线颜色2"), Category("SunnyUI")]
[DefaultValue(typeof(Color), "243, 249, 255")]
public Color LineColor2
{
get => fillColor2;
set => SetFillColor2(value);
}
[Description("线颜色渐变"), Category("SunnyUI")]
[DefaultValue(false)]
public bool LineColorGradient
{
get => fillColorGradient;
set
{
if (fillColorGradient != value)
{
fillColorGradient = value;
Invalidate();
}
}
}
}
}