diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll
index f556d06d..7e570fd6 100644
Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ
diff --git a/SunnyUI/Common/UGDI.cs b/SunnyUI/Common/UGDI.cs
index de5d0684..004b24b8 100644
--- a/SunnyUI/Common/UGDI.cs
+++ b/SunnyUI/Common/UGDI.cs
@@ -222,7 +222,7 @@ namespace Sunny.UI
return rect.CreateRoundedRectanglePath(radius, cornerLeftTop, cornerRightTop, cornerRightBottom, cornerLeftBottom);
}
- public static GraphicsPath CreateRoundedRectanglePath(this Rectangle rect, int radius, UICornerRadiusSides radiusSides)
+ public static GraphicsPath CreateRoundedRectanglePath(this Rectangle rect, int radius, UICornerRadiusSides radiusSides, int lineSize = 1)
{
GraphicsPath path;
@@ -240,7 +240,7 @@ namespace Sunny.UI
bool RadiusRightTop = radiusSides.GetValue(UICornerRadiusSides.RightTop);
//IsRadius为True时,显示右下圆角
bool RadiusRightBottom = radiusSides.GetValue(UICornerRadiusSides.RightBottom);
- path = rect.CreateRoundedRectanglePath(radius, RadiusLeftTop, RadiusRightTop, RadiusRightBottom, RadiusLeftBottom);
+ path = rect.CreateRoundedRectanglePath(radius, RadiusLeftTop, RadiusRightTop, RadiusRightBottom, RadiusLeftBottom, lineSize);
}
return path;
@@ -281,7 +281,9 @@ namespace Sunny.UI
return path;
}
- public static GraphicsPath CreateRoundedRectanglePath(this Rectangle rect, int radius, bool cornerLeftTop = true, bool cornerRightTop = true, bool cornerRightBottom = true, bool cornerLeftBottom = true)
+ public static GraphicsPath CreateRoundedRectanglePath(this Rectangle rect, int radius,
+ bool cornerLeftTop = true, bool cornerRightTop = true, bool cornerRightBottom = true, bool cornerLeftBottom = true,
+ int lineSize = 1)
{
GraphicsPath path = new GraphicsPath();
@@ -291,6 +293,7 @@ namespace Sunny.UI
}
else
{
+ radius *= lineSize;
if (cornerLeftTop)
path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
else
@@ -311,6 +314,7 @@ namespace Sunny.UI
else
path.AddLine(new Point(rect.X + 1, rect.Y + rect.Height), new Point(rect.X, rect.Y + rect.Height));
+
path.CloseFigure();
}
diff --git a/SunnyUI/Controls/UIButton.cs b/SunnyUI/Controls/UIButton.cs
index 15b24ff0..4c289c61 100644
--- a/SunnyUI/Controls/UIButton.cs
+++ b/SunnyUI/Controls/UIButton.cs
@@ -22,6 +22,7 @@
* 2020-08-22: V2.2.7 空格键按下press背景效果,添加双击事件,解决因快速点击导致过慢问题
* 2020-09-14: V2.2.7 Tips颜色可设置
* 2021-07-18: V3.0.5 增加ShowFocusColor,用来显示Focus状态
+ * 2021-12-11: V3.0.9 增加了渐变色
******************************************************************************/
using System;
@@ -76,10 +77,24 @@ namespace Sunny.UI
protected override void OnClick(EventArgs e)
{
+ Form form = FindFormInternal();
+ if (form != null) form.DialogResult = DialogResult;
+
Focus();
base.OnClick(e);
}
+ internal Form FindFormInternal()
+ {
+ Control cur = this;
+ while (cur != null && !(cur is Form))
+ {
+ cur = cur.Parent;
+ }
+
+ return (Form)cur;
+ }
+
private bool showTips = false;
[Description("是否显示角标"), Category("SunnyUI")]
@@ -139,13 +154,23 @@ namespace Sunny.UI
protected override void OnPaintFill(Graphics g, GraphicsPath path)
{
- if (!selected)
+ if (FillColorGradient)
{
- base.OnPaintFill(g, path);
+ if (IsHover || IsPress || Selected)
+ {
+ base.OnPaintFill(g, path);
+ }
+ else
+ {
+ LinearGradientBrush br = new LinearGradientBrush(new Point(0, 0), new Point(0, Height), FillColor, FillColor2);
+ br.GammaCorrection = true;
+ g.FillPath(br, path);
+ br.Dispose();
+ }
}
else
{
- g.FillPath(FillSelectedColor, path);
+ base.OnPaintFill(g, path);
}
}
@@ -274,6 +299,32 @@ namespace Sunny.UI
set => SetFillColor(value);
}
+ ///
+ /// 填充颜色,当值为背景色或透明色或空值则不填充
+ ///
+ [Description("填充颜色"), Category("SunnyUI")]
+ [DefaultValue(typeof(Color), "80, 160, 255")]
+ public Color FillColor2
+ {
+ get => fillColor2;
+ set => SetFillColor2(value);
+ }
+
+ [Description("填充颜色渐变"), Category("SunnyUI")]
+ [DefaultValue(false)]
+ public bool FillColorGradient
+ {
+ get => fillColorGradient;
+ set
+ {
+ if (fillColorGradient != value)
+ {
+ fillColorGradient = value;
+ Invalidate();
+ }
+ }
+ }
+
///
/// 边框颜色
///
diff --git a/SunnyUI/Controls/UIControl.cs b/SunnyUI/Controls/UIControl.cs
index acb1037c..d801f137 100644
--- a/SunnyUI/Controls/UIControl.cs
+++ b/SunnyUI/Controls/UIControl.cs
@@ -261,6 +261,7 @@ namespace Sunny.UI
public virtual void SetStyleColor(UIBaseStyle uiColor)
{
fillColor = uiColor.ButtonFillColor;
+ fillColor2 = uiColor.ButtonFillColor2;
rectColor = uiColor.RectColor;
foreColor = uiColor.ButtonForeColor;
@@ -352,7 +353,7 @@ namespace Sunny.UI
if (IsDisposed) return;
Rectangle rect = new Rectangle(0, 0, Width - 1, Height - 1);
- GraphicsPath path = rect.CreateRoundedRectanglePath(radius, RadiusSides);
+ GraphicsPath path = rect.CreateRoundedRectanglePath(radius, RadiusSides, RectSize);
//填充背景色
if (ShowFill && fillColor.IsValid())
@@ -452,6 +453,29 @@ namespace Sunny.UI
g.FillPath(color, path);
}
+ private int rectSize = 1;
+
+ ///
+ /// 边框颜色
+ ///
+ [Description("边框宽度"), Category("SunnyUI")]
+ [DefaultValue(1)]
+ public int RectSize
+ {
+ get => rectSize;
+ set
+ {
+ int v = value;
+ if (v > 2) v = 2;
+ if (v < 1) v = 1;
+ if (rectSize != v)
+ {
+ rectSize = v;
+ Invalidate();
+ }
+ }
+ }
+
private void PaintRectDisableSides(Graphics g)
{
//IsRadius为False时,显示左侧边线
@@ -472,85 +496,86 @@ namespace Sunny.UI
//IsRadius为True时,显示右下圆角
bool RadiusRightBottom = RadiusSides.GetValue(UICornerRadiusSides.RightBottom);
- var ShowRadius = RadiusSides > 0;
- using (Pen pen = new Pen(GetFillColor()))
- using (Pen penR = new Pen(GetRectColor()))
+ var ShowRadius = RadiusSides > 0;//肯定少有一个角显示圆角
+
+ if (!ShowRadius || (!RadiusLeftBottom && !RadiusLeftTop))
+ {
+ g.DrawLine(GetRectColor(), 0, 0, 0, Height - 1);
+ }
+
+ if (!ShowRadius || (!RadiusRightTop && !RadiusLeftTop))
+ {
+ g.DrawLine(GetRectColor(), 0, 0, Width - 1, 0);
+ }
+
+ if (!ShowRadius || (!RadiusRightTop && !RadiusRightBottom))
+ {
+ g.DrawLine(GetRectColor(), Width - 1, 0, Width - 1, Height - 1);
+ }
+
+ if (!ShowRadius || (!RadiusLeftBottom && !RadiusRightBottom))
+ {
+ g.DrawLine(GetRectColor(), 0, Height - 1, Width - 1, Height - 1);
+ }
+
+ if (!ShowRectLeft)
{
if (!ShowRadius || (!RadiusLeftBottom && !RadiusLeftTop))
{
- g.DrawLine(penR, 0, 0, 0, Height - 1);
+ g.DrawLine(GetFillColor(), 0, RectSize, 0, Height - 1 - RectSize);
+ if (RectSize == 2) g.DrawLine(GetFillColor(), 1, RectSize, 1, Height - 1 - RectSize);
}
+ }
+ if (!ShowRectTop)
+ {
if (!ShowRadius || (!RadiusRightTop && !RadiusLeftTop))
{
- g.DrawLine(penR, 0, 0, Width - 1, 0);
+ g.DrawLine(GetFillColor(), RectSize, 0, Width - 1 - RectSize, 0);
+ if (RectSize == 2) g.DrawLine(GetFillColor(), RectSize, 1, Width - 1 - RectSize, 1);
}
+ }
+ if (!ShowRectRight)
+ {
if (!ShowRadius || (!RadiusRightTop && !RadiusRightBottom))
{
- g.DrawLine(penR, Width - 1, 0, Width - 1, Height - 1);
+ g.DrawLine(GetFillColor(), Width - 1, RectSize, Width - 1, Height - 1 - RectSize);
+ if (RectSize == 2) g.DrawLine(GetFillColor(), Width - 2, RectSize, Width - 2, Height - 1 - RectSize);
}
+ }
+ if (!ShowRectBottom)
+ {
if (!ShowRadius || (!RadiusLeftBottom && !RadiusRightBottom))
{
- g.DrawLine(penR, 0, Height - 1, Width - 1, Height - 1);
+ g.DrawLine(GetFillColor(), RectSize, Height - 1, Width - 1 - RectSize, Height - 1);
+ if (RectSize == 2) g.DrawLine(GetFillColor(), RectSize, Height - 2, Width - 1 - RectSize, Height - 2);
}
+ }
- if (!ShowRectLeft)
- {
- if (!ShowRadius || (!RadiusLeftBottom && !RadiusLeftTop))
- {
- g.DrawLine(pen, 0, 1, 0, Height - 2);
- }
- }
+ if (!ShowRectLeft && !ShowRectTop)
+ {
+ if (!ShowRadius || (!RadiusLeftBottom && !RadiusLeftTop))
+ g.FillRectangle(GetFillColor(), 0, 0, RectSize, RectSize);
+ }
- if (!ShowRectTop)
- {
- if (!ShowRadius || (!RadiusRightTop && !RadiusLeftTop))
- {
- g.DrawLine(pen, 1, 0, Width - 2, 0);
- }
- }
+ if (!ShowRectRight && !ShowRectTop)
+ {
+ if (!ShowRadius || (!RadiusLeftBottom && !RadiusLeftTop))
+ g.FillRectangle(GetFillColor(), Width - 1 - RectSize, 0, RectSize, RectSize);
+ }
- if (!ShowRectRight)
- {
- if (!ShowRadius || (!RadiusRightTop && !RadiusRightBottom))
- {
- g.DrawLine(pen, Width - 1, 1, Width - 1, Height - 2);
- }
- }
+ if (!ShowRectLeft && !ShowRectBottom)
+ {
+ if (!ShowRadius || (!RadiusLeftBottom && !RadiusLeftTop))
+ g.FillRectangle(GetFillColor(), 0, Height - 1 - RectSize, RectSize, RectSize);
+ }
- if (!ShowRectBottom)
- {
- if (!ShowRadius || (!RadiusLeftBottom && !RadiusRightBottom))
- {
- g.DrawLine(pen, 1, Height - 1, Width - 2, Height - 1);
- }
- }
-
- if (!ShowRectLeft && !ShowRectTop)
- {
- if (!ShowRadius || (!RadiusLeftBottom && !RadiusLeftTop))
- g.DrawLine(pen, 0, 0, 0, 1);
- }
-
- if (!ShowRectRight && !ShowRectTop)
- {
- if (!ShowRadius || (!RadiusLeftBottom && !RadiusLeftTop))
- g.DrawLine(pen, Width - 1, 0, Width - 1, 1);
- }
-
- if (!ShowRectLeft && !ShowRectBottom)
- {
- if (!ShowRadius || (!RadiusLeftBottom && !RadiusLeftTop))
- g.DrawLine(pen, 0, Height - 1, 0, Height - 2);
- }
-
- if (!ShowRectRight && !ShowRectBottom)
- {
- if (!ShowRadius || (!RadiusLeftBottom && !RadiusLeftTop))
- g.DrawLine(pen, Width - 1, Height - 1, Width - 1, Height - 2);
- }
+ if (!ShowRectRight && !ShowRectBottom)
+ {
+ if (!ShowRadius || (!RadiusLeftBottom && !RadiusLeftTop))
+ g.FillRectangle(GetFillColor(), Width - 1 - RectSize, Height - 1 - RectSize, RectSize, RectSize);
}
}
@@ -561,8 +586,7 @@ namespace Sunny.UI
/// 路径
protected virtual void OnPaintRect(Graphics g, GraphicsPath path)
{
- Color color = GetRectColor();
- g.DrawPath(color, path);
+ g.DrawPath(GetRectColor(), path, true, RectSize);
PaintRectDisableSides(g);
}
@@ -593,11 +617,18 @@ namespace Sunny.UI
///
protected Color rectColor = UIStyles.GetStyleColor(UIStyle.Blue).RectColor;
+ protected bool fillColorGradient = false;
+
///
/// 填充颜色
///
protected Color fillColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillColor;
+ ///
+ /// 填充颜色
+ ///
+ protected Color fillColor2 = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillColor;
+
///
/// 字体颜色
///
@@ -810,6 +841,20 @@ namespace Sunny.UI
}
}
+ ///
+ /// 设置填充颜色
+ ///
+ /// 颜色
+ protected void SetFillColor2(Color value)
+ {
+ if (fillColor2 != value)
+ {
+ fillColor2 = value;
+ _style = UIStyle.Custom;
+ Invalidate();
+ }
+ }
+
///
/// 设置字体颜色
///
diff --git a/SunnyUI/Controls/UIPanel.cs b/SunnyUI/Controls/UIPanel.cs
index fbcd08d9..1ac38b9b 100644
--- a/SunnyUI/Controls/UIPanel.cs
+++ b/SunnyUI/Controls/UIPanel.cs
@@ -20,6 +20,7 @@
* 2020-04-25: V2.2.4 更新主题配置类
* 2021-05-09: V3.0.3 增加双缓冲,减少闪烁
* 2021-09-03: V3.0.6 支持背景图片显示
+ * 2021-12-11: V3.0.9 增加了渐变色
******************************************************************************/
using System;
@@ -264,6 +265,53 @@ namespace Sunny.UI
}
}
+ private bool fillColorGradient;
+
+ [Description("填充颜色渐变"), Category("SunnyUI")]
+ [DefaultValue(false)]
+ public bool FillColorGradient
+ {
+ get => fillColorGradient;
+ set
+ {
+ if (fillColorGradient != value)
+ {
+ fillColorGradient = value;
+ Invalidate();
+ }
+ }
+ }
+
+ ///
+ /// 设置填充颜色
+ ///
+ /// 颜色
+ protected void SetFillColor2(Color value)
+ {
+ if (fillColor2 != value)
+ {
+ fillColor2 = value;
+ _style = UIStyle.Custom;
+ Invalidate();
+ }
+ }
+
+ ///
+ /// 填充颜色
+ ///
+ protected Color fillColor2 = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillColor;
+
+ ///
+ /// 填充颜色,当值为背景色或透明色或空值则不填充
+ ///
+ [Description("填充颜色"), Category("SunnyUI")]
+ [DefaultValue(typeof(Color), "80, 160, 255")]
+ public Color FillColor2
+ {
+ get => fillColor2;
+ set => SetFillColor2(value);
+ }
+
protected void SetFillDisableColor(Color color)
{
fillDisableColor = color;
@@ -468,10 +516,25 @@ namespace Sunny.UI
{
Color color = GetFillColor();
- if (RadiusSides == UICornerRadiusSides.None)
- g.Clear(color);
+ if (fillColorGradient)
+ {
+ LinearGradientBrush br = new LinearGradientBrush(new Point(0, 0), new Point(0, Height), FillColor, FillColor2);
+ br.GammaCorrection = true;
+
+ if (RadiusSides == UICornerRadiusSides.None)
+ g.FillRectangle(br, ClientRectangle);
+ else
+ g.FillPath(br, path);
+
+ br.Dispose();
+ }
else
- g.FillPath(color, path);
+ {
+ if (RadiusSides == UICornerRadiusSides.None)
+ g.Clear(color);
+ else
+ g.FillPath(color, path);
+ }
}
protected virtual void AfterSetFillColor(Color color)
@@ -521,7 +584,7 @@ namespace Sunny.UI
public virtual void SetStyleColor(UIBaseStyle uiColor)
{
- fillColor = uiColor.PlainColor;
+ fillColor2 = fillColor = uiColor.PlainColor;
rectColor = uiColor.RectColor;
foreColor = uiColor.PanelForeColor;
diff --git a/SunnyUI/Controls/UIRichTextBox.cs b/SunnyUI/Controls/UIRichTextBox.cs
index 00a4b4a5..9b390fc4 100644
--- a/SunnyUI/Controls/UIRichTextBox.cs
+++ b/SunnyUI/Controls/UIRichTextBox.cs
@@ -74,6 +74,11 @@ namespace Sunny.UI
return edit;
}
+ public void Clear()
+ {
+ edit.Clear();
+ }
+
public RichTextBox RichTextBox => edit;
public override Color BackColor { get => edit.BackColor; set { edit.BackColor = base.BackColor = value; } }
diff --git a/SunnyUI/Forms/UIForm.cs b/SunnyUI/Forms/UIForm.cs
index 02ecc9e5..40075290 100644
--- a/SunnyUI/Forms/UIForm.cs
+++ b/SunnyUI/Forms/UIForm.cs
@@ -1415,7 +1415,7 @@ namespace Sunny.UI
{
if (CloseAskString.IsValid())
{
- if (!this.ShowAskDialog(CloseAskString))
+ if (!this.ShowAskDialog(CloseAskString, false))
{
e.Cancel = true;
}
diff --git a/SunnyUI/Forms/UIForm.designer.cs b/SunnyUI/Forms/UIForm.designer.cs
index 84154206..70c40661 100644
--- a/SunnyUI/Forms/UIForm.designer.cs
+++ b/SunnyUI/Forms/UIForm.designer.cs
@@ -52,7 +52,6 @@ namespace Sunny.UI
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "UIForm";
this.Padding = new System.Windows.Forms.Padding(0, 35, 0, 0);
- this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "UIForm";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.UIForm_FormClosing);
diff --git a/SunnyUI/Style/UIStyleColor.cs b/SunnyUI/Style/UIStyleColor.cs
index 5da10e7c..5e281199 100644
--- a/SunnyUI/Style/UIStyleColor.cs
+++ b/SunnyUI/Style/UIStyleColor.cs
@@ -117,6 +117,8 @@ namespace Sunny.UI
public virtual Color EditorBackColor => Color.White;
+ public virtual Color ButtonFillColor2 => ButtonFillColor;
+
public virtual void LoadFromFile()
{
}
@@ -535,24 +537,63 @@ namespace Sunny.UI
public class UIDarkBlueStyle : UIBaseStyle
{
public override UIStyle Name => UIStyle.DarkBlue;
- public override Color PrimaryColor => UIColor.DarkBlue;
+ public override Color PrimaryColor => Color.FromArgb(30, 32, 135);
public override Color RegularColor => Color.FromArgb(120, 148, 182);
public override Color SecondaryColor => Color.FromArgb(120, 148, 182);
- public override Color PlainColor => UIColor.LightGray;
- public override Color ButtonFillColor => UIColor.DarkBlue;
- public override Color ButtonFillHoverColor => Color.FromArgb(190, 230, 253);
- public override Color ButtonFillPressColor => Color.FromArgb(169, 217, 242);
- public override Color ButtonForeColor => Color.FromArgb(130, 130, 130);
- public override Color ButtonForeHoverColor => Color.FromArgb(130, 130, 130);
- public override Color ButtonForePressColor => Color.FromArgb(130, 130, 130);
- public override Color RectSelectedColor => RectPressColor;
- public override Color ButtonForeSelectedColor => ButtonForePressColor;
- public override Color ButtonFillSelectedColor => ButtonFillPressColor;
- public override Color RectColor => Color.FromArgb(130, 130, 130);
- public override Color RectHoverColor => Color.FromArgb(130, 130, 130);
- public override Color RectPressColor => Color.FromArgb(130, 130, 130);
+ public override Color PlainColor => Color.FromArgb(30, 32, 135);
+ public override Color ButtonFillColor => Color.FromArgb(2, 167, 240);
+ public override Color ButtonFillColor2 => Color.FromArgb(6, 13, 192);
+ public override Color ButtonFillHoverColor => Color.FromArgb(128, 255, 255);
+ public override Color ButtonFillPressColor => Color.FromArgb(108, 255, 255);
+ public override Color ButtonForeColor => Color.FromArgb(242, 242, 242);
+ public override Color ButtonForeHoverColor => UIFontColor.Primary;
+ public override Color ButtonForePressColor => UIFontColor.Primary;
+ public override Color RectSelectedColor => Color.FromArgb(128, 255, 255);
+ public override Color ButtonForeSelectedColor => UIFontColor.Primary;
+ public override Color ButtonFillSelectedColor => Color.FromArgb(128, 255, 255);
+ public override Color RectColor => Color.FromArgb(128, 255, 255);
+ public override Color RectHoverColor => Color.FromArgb(128, 255, 255);
+ public override Color RectPressColor => Color.FromArgb(128, 255, 255);
+ public override Color LabelForeColor => UIFontColor.Plain;
+ public override Color DropDownControlColor => UIFontColor.Primary;
+ public override Color CheckBoxColor => UIColor.Blue;
+
public override Color TitleColor => Color.FromArgb(130, 130, 130);
public override Color TitleForeColor => Color.White;
+ public override Color LineForeColor => UIFontColor.Plain;
+ public override Color ContextMenuColor => UIColor.RegularGray;
+
+ public override Color GridStripeOddColor => UIColor.RegularGray;
+ public override Color GridSelectedColor => UIFontColor.Plain;
+
+ public override Color GridSelectedForeColor => UIColor.White;
+
+ public override Color ListItemSelectBackColor => UIColor.Blue;
+ public override Color ListItemSelectForeColor => UIColor.LightBlue;
+
+ public override Color ProgressIndicatorColor => UIColor.Blue;
+
+ public override Color ProcessBarFillColor => PlainColor;
+
+ public override Color ProcessBarForeColor => UIColor.RegularGray;
+
+ public override Color ScrollBarForeColor => UIColor.RegularGray;
+
+ public override Color SwitchActiveColor => UIColor.DarkBlue;
+
+ public override Color SwitchInActiveColor => UIFontColor.Plain;
+
+ public override Color SwitchFillColor => Color.White;
+
+ public override Color TrackBarForeColor => UIColor.Blue;
+
+ public override Color TrackBarRectColor => UIColor.Blue;
+
+ public override Color TrackDisableColor => Color.Silver;
+
+ public override Color TreeViewSelectedColor => UIFontColor.Secondary;
+
+ public override Color TreeViewHoverColor => UIFontColor.Plain;
}
public class UIBlackStyle : UIBaseStyle