* 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-05: V3.0.9 线
* 2022-01-10: V3.1.0 * 2022-01-10: V3.1.0
* 2022-03-19: V3.1.1 * 2022-03-19: V3.1.1
* 2022-11-26: V3.2.9 线
******************************************************************************/ ******************************************************************************/
using System; using System;
@ -93,6 +94,7 @@ namespace Sunny.UI
rectColor = uiColor.LineRectColor; rectColor = uiColor.LineRectColor;
foreColor = uiColor.LineForeColor; foreColor = uiColor.LineForeColor;
fillColor = uiColor.LineFillColor; fillColor = uiColor.LineFillColor;
fillColor2 = uiColor.PanelFillColor2;
} }
/// <summary> /// <summary>
@ -244,13 +246,29 @@ namespace Sunny.UI
g.DrawLine(pen, x + sf.Width + 2, top, Width - 2 - Padding.Left - Padding.Right, top); g.DrawLine(pen, x + sf.Width + 2, top, Width - 2 - Padding.Left - Padding.Right, top);
break; break;
default: 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; break;
} }
} }
else 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) switch (startCap)
@ -323,14 +341,40 @@ namespace Sunny.UI
} }
/// <summary> /// <summary>
/// 边框颜色 /// 线颜色
/// </summary> /// </summary>
[Description("边框颜色"), Category("SunnyUI")] [Description("线颜色"), Category("SunnyUI")]
[DefaultValue(typeof(Color), "80, 160, 255")] [DefaultValue(typeof(Color), "80, 160, 255")]
public Color LineColor public Color LineColor
{ {
get => rectColor; get => rectColor;
set => SetRectColor(value); 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();
}
}
}
} }
} }