* UIButton: 渐变色增加方向选择

This commit is contained in:
Sunny 2023-07-02 17:02:32 +08:00
parent cc1e8dadcc
commit 442014fa11
2 changed files with 39 additions and 2 deletions

View File

@ -28,6 +28,7 @@
* 2022-03-31: V3.1.2 * 2022-03-31: V3.1.2
* 2022-08-25: V3.2.3 GroupIndex的按钮控件的Selected单选 * 2022-08-25: V3.2.3 GroupIndex的按钮控件的Selected单选
* 2023-05-12: V3.3.6 DrawString函数 * 2023-05-12: V3.3.6 DrawString函数
* 2023-07-02: V3.3.9
******************************************************************************/ ******************************************************************************/
using System; using System;
@ -230,7 +231,26 @@ namespace Sunny.UI
} }
else else
{ {
LinearGradientBrush br = new LinearGradientBrush(new Point(0, 0), new Point(0, Height), FillColor, FillColor2); LinearGradientBrush br;
switch (fillColorGradientDirection)
{
case FlowDirection.LeftToRight:
br = new LinearGradientBrush(new Point(0, 0), new Point(Width, y: 0), FillColor, FillColor2);
break;
case FlowDirection.TopDown:
br = new LinearGradientBrush(new Point(0, 0), new Point(0, Height), FillColor, FillColor2);
break;
case FlowDirection.RightToLeft:
br = new LinearGradientBrush(new Point(Width, 0), new Point(0, y: 0), FillColor, FillColor2);
break;
case FlowDirection.BottomUp:
br = new LinearGradientBrush(new Point(0, Height), new Point(0, 0), FillColor, FillColor2);
break;
default:
br = new LinearGradientBrush(new Point(0, 0), new Point(0, Height), FillColor, FillColor2);
break;
}
br.GammaCorrection = true; br.GammaCorrection = true;
g.FillPath(br, path); g.FillPath(br, path);
br.Dispose(); br.Dispose();
@ -452,6 +472,23 @@ namespace Sunny.UI
} }
} }
private FlowDirection fillColorGradientDirection = FlowDirection.TopDown;
[Description("填充颜色渐变方向"), Category("SunnyUI")]
[DefaultValue(FlowDirection.TopDown)]
public FlowDirection FillColorGradientDirection
{
get => fillColorGradientDirection;
set
{
if (fillColorGradientDirection != value)
{
fillColorGradientDirection = value;
Invalidate();
}
}
}
/// <summary> /// <summary>
/// 边框颜色 /// 边框颜色
/// </summary> /// </summary>

View File

@ -19,6 +19,7 @@
* 2022-04-02: V3.1.1 * 2022-04-02: V3.1.1
* 2022-04-02: V3.1.2 AutoScaleMode为None * 2022-04-02: V3.1.2 AutoScaleMode为None
* 2023-05-12: V3.3.6 DrawString函数 * 2023-05-12: V3.3.6 DrawString函数
* 2023-07-02: V3.3.9
******************************************************************************/ ******************************************************************************/
using System; using System;
@ -535,7 +536,6 @@ namespace Sunny.UI
} }
} }
protected virtual void OnPaintFill(Graphics g, GraphicsPath path) protected virtual void OnPaintFill(Graphics g, GraphicsPath path)
{ {
Color color = GetFillColor(); Color color = GetFillColor();