增加全局矩形设计,忽略圆角
This commit is contained in:
parent
01e292b111
commit
8295a99e2b
@ -312,7 +312,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
GraphicsPath path;
|
GraphicsPath path;
|
||||||
|
|
||||||
if (radiusSides == UICornerRadiusSides.None || radius == 0)
|
if (UIStyles.GlobalRectangle || radiusSides == UICornerRadiusSides.None || radius == 0)
|
||||||
{
|
{
|
||||||
path = new GraphicsPath();
|
path = new GraphicsPath();
|
||||||
path.AddLine(new Point(rect.X, rect.Y), new Point(rect.X, rect.Y + rect.Height));
|
path.AddLine(new Point(rect.X, rect.Y), new Point(rect.X, rect.Y + rect.Height));
|
||||||
@ -341,7 +341,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
GraphicsPath path = new GraphicsPath();
|
GraphicsPath path = new GraphicsPath();
|
||||||
|
|
||||||
if ((!cornerLeftTop && !cornerRightTop && !cornerRightBottom && !cornerLeftBottom) || radius <= 0)
|
if (UIStyles.GlobalRectangle || (!cornerLeftTop && !cornerRightTop && !cornerRightBottom && !cornerLeftBottom) || radius <= 0)
|
||||||
{
|
{
|
||||||
path.AddLine(new Point(rect.X, rect.Y), new Point(rect.X, rect.Y + rect.Height));
|
path.AddLine(new Point(rect.X, rect.Y), new Point(rect.X, rect.Y + rect.Height));
|
||||||
path.AddLine(new Point(rect.X, rect.Y + rect.Height), new Point(rect.X + rect.Width, rect.Y + rect.Height));
|
path.AddLine(new Point(rect.X, rect.Y + rect.Height), new Point(rect.X + rect.Width, rect.Y + rect.Height));
|
||||||
@ -473,7 +473,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
GraphicsPath path = new GraphicsPath();
|
GraphicsPath path = new GraphicsPath();
|
||||||
|
|
||||||
if ((!cornerLeftTop && !cornerRightTop && !cornerRightBottom && !cornerLeftBottom) || radius <= 0)
|
if (UIStyles.GlobalRectangle || (!cornerLeftTop && !cornerRightTop && !cornerRightBottom && !cornerLeftBottom) || radius <= 0)
|
||||||
{
|
{
|
||||||
path = rect.GraphicsPath();
|
path = rect.GraphicsPath();
|
||||||
}
|
}
|
||||||
@ -507,6 +507,18 @@ namespace Sunny.UI
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static GraphicsPath CreateTrueRoundedRectanglePath(this Rectangle rect, int radius, int lineSize = 1)
|
||||||
|
{
|
||||||
|
GraphicsPath path = new GraphicsPath();
|
||||||
|
radius *= lineSize;
|
||||||
|
path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
|
||||||
|
path.AddArc(rect.X + rect.Width - radius, rect.Y, radius, radius, 270, 90);
|
||||||
|
path.AddArc(rect.X + rect.Width - radius, rect.Y + rect.Height - radius, radius, radius, 0, 90);
|
||||||
|
path.AddArc(rect.X, rect.Bottom - radius, radius, radius, 90, 90);
|
||||||
|
path.CloseFigure();
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置GDI高质量模式抗锯齿
|
/// 设置GDI高质量模式抗锯齿
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1135,7 +1135,7 @@ namespace Sunny.UI
|
|||||||
public static void DrawRoundRectangle(this Graphics g, Pen pen, Rectangle rect, int cornerRadius, bool smooth = true)
|
public static void DrawRoundRectangle(this Graphics g, Pen pen, Rectangle rect, int cornerRadius, bool smooth = true)
|
||||||
{
|
{
|
||||||
g.Smooth(smooth);
|
g.Smooth(smooth);
|
||||||
if (cornerRadius > 0)
|
if (!UIStyles.GlobalRectangle && cornerRadius > 0)
|
||||||
{
|
{
|
||||||
using GraphicsPath path = rect.CreateRoundedRectanglePath(cornerRadius);
|
using GraphicsPath path = rect.CreateRoundedRectanglePath(cornerRadius);
|
||||||
g.DrawPath(pen, path);
|
g.DrawPath(pen, path);
|
||||||
@ -1159,7 +1159,7 @@ namespace Sunny.UI
|
|||||||
public static void FillRoundRectangle(this Graphics g, Brush brush, Rectangle rect, int cornerRadius, bool smooth = true)
|
public static void FillRoundRectangle(this Graphics g, Brush brush, Rectangle rect, int cornerRadius, bool smooth = true)
|
||||||
{
|
{
|
||||||
g.Smooth(smooth);
|
g.Smooth(smooth);
|
||||||
if (cornerRadius > 0)
|
if (!UIStyles.GlobalRectangle && cornerRadius > 0)
|
||||||
{
|
{
|
||||||
using GraphicsPath path = rect.CreateRoundedRectanglePath(cornerRadius);
|
using GraphicsPath path = rect.CreateRoundedRectanglePath(cornerRadius);
|
||||||
g.FillPath(brush, path);
|
g.FillPath(brush, path);
|
||||||
@ -1215,7 +1215,7 @@ namespace Sunny.UI
|
|||||||
/// <param name="penWidth">笔宽</param>
|
/// <param name="penWidth">笔宽</param>
|
||||||
public static void DrawRoundRectangle(this Graphics g, Color color, Rectangle rect, int cornerRadius, bool smooth = true, float penWidth = 1)
|
public static void DrawRoundRectangle(this Graphics g, Color color, Rectangle rect, int cornerRadius, bool smooth = true, float penWidth = 1)
|
||||||
{
|
{
|
||||||
if (cornerRadius > 0)
|
if (!UIStyles.GlobalRectangle && cornerRadius > 0)
|
||||||
{
|
{
|
||||||
using GraphicsPath path = rect.CreateRoundedRectanglePath(cornerRadius);
|
using GraphicsPath path = rect.CreateRoundedRectanglePath(cornerRadius);
|
||||||
g.DrawPath(color, path, smooth, penWidth);
|
g.DrawPath(color, path, smooth, penWidth);
|
||||||
@ -1236,7 +1236,7 @@ namespace Sunny.UI
|
|||||||
/// <param name="smooth">平滑</param>
|
/// <param name="smooth">平滑</param>
|
||||||
public static void FillRoundRectangle(this Graphics g, Color color, Rectangle rect, int cornerRadius, bool smooth = true)
|
public static void FillRoundRectangle(this Graphics g, Color color, Rectangle rect, int cornerRadius, bool smooth = true)
|
||||||
{
|
{
|
||||||
if (cornerRadius > 0)
|
if (!UIStyles.GlobalRectangle && cornerRadius > 0)
|
||||||
{
|
{
|
||||||
using GraphicsPath path = rect.CreateRoundedRectanglePath(cornerRadius);
|
using GraphicsPath path = rect.CreateRoundedRectanglePath(cornerRadius);
|
||||||
g.FillPath(color, path, smooth);
|
g.FillPath(color, path, smooth);
|
||||||
|
@ -96,27 +96,14 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
tipsBtn = new UIButton();
|
tipsBtn = new UIButton();
|
||||||
tipsBtn.Cursor = System.Windows.Forms.Cursors.Hand;
|
tipsBtn.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
tipsBtn.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
tipsBtn.Size = new System.Drawing.Size(6, 6);
|
||||||
tipsBtn.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.Location = new System.Drawing.Point(285, 519);
|
|
||||||
tipsBtn.MinimumSize = new System.Drawing.Size(1, 1);
|
|
||||||
tipsBtn.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.Size = new System.Drawing.Size(9, 9);
|
|
||||||
tipsBtn.Style = Sunny.UI.UIStyle.Red;
|
tipsBtn.Style = Sunny.UI.UIStyle.Red;
|
||||||
tipsBtn.StyleCustomMode = true;
|
tipsBtn.StyleCustomMode = true;
|
||||||
tipsBtn.TabIndex = 118;
|
|
||||||
tipsBtn.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
|
|
||||||
tipsBtn.Text = "";
|
tipsBtn.Text = "";
|
||||||
tipsBtn.Click += TipsBtn_Click;
|
tipsBtn.Click += TipsBtn_Click;
|
||||||
|
|
||||||
Controls.Add(tipsBtn);
|
Controls.Add(tipsBtn);
|
||||||
tipsBtn.Location = new System.Drawing.Point(Width - 11, 2);
|
tipsBtn.Location = new System.Drawing.Point(Width - 8, 2);
|
||||||
tipsBtn.BringToFront();
|
tipsBtn.BringToFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +363,7 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
if (tipsBtn != null)
|
if (tipsBtn != null)
|
||||||
{
|
{
|
||||||
tipsBtn.Location = new System.Drawing.Point(Width - 11, 2);
|
tipsBtn.Location = new System.Drawing.Point(Width - 8, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ namespace Sunny.UI
|
|||||||
public UIGroupBox()
|
public UIGroupBox()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
TextAlignment = ContentAlignment.MiddleLeft;
|
||||||
TextAlignmentChange += UIGroupBox_TextAlignmentChange;
|
TextAlignmentChange += UIGroupBox_TextAlignmentChange;
|
||||||
SetStyleFlags(true, false);
|
SetStyleFlags(true, false);
|
||||||
}
|
}
|
||||||
@ -109,7 +110,7 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
if (RectSides.GetValue(ToolStripStatusLabelBorderSides.Top))
|
if (RectSides.GetValue(ToolStripStatusLabelBorderSides.Top))
|
||||||
{
|
{
|
||||||
if (RadiusSides.GetValue(UICornerRadiusSides.LeftTop))
|
if (RadiusSides.GetValue(UICornerRadiusSides.LeftTop) && !UIStyles.GlobalRectangle)
|
||||||
{
|
{
|
||||||
g.DrawLine(RectColor, Radius / 2 * RectSize, TitleTop, textLeft, TitleTop, true, RectSize);
|
g.DrawLine(RectColor, Radius / 2 * RectSize, TitleTop, textLeft, TitleTop, true, RectSize);
|
||||||
}
|
}
|
||||||
@ -118,7 +119,7 @@ namespace Sunny.UI
|
|||||||
g.DrawLine(RectColor, 0, TitleTop, textLeft, TitleTop, true, RectSize);
|
g.DrawLine(RectColor, 0, TitleTop, textLeft, TitleTop, true, RectSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RadiusSides.GetValue(UICornerRadiusSides.RightTop))
|
if (RadiusSides.GetValue(UICornerRadiusSides.RightTop) && !UIStyles.GlobalRectangle)
|
||||||
{
|
{
|
||||||
g.DrawLine(RectColor, textLeft + size.Width, TitleTop, Width - Radius / 2 * RectSize, TitleTop, true, RectSize);
|
g.DrawLine(RectColor, textLeft + size.Width, TitleTop, Width - Radius / 2 * RectSize, TitleTop, true, RectSize);
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,8 @@ namespace Sunny.UI
|
|||||||
if (SwitchShape == UISwitchShape.Round)
|
if (SwitchShape == UISwitchShape.Round)
|
||||||
{
|
{
|
||||||
Rectangle rect = new Rectangle(0, 0, Width - 1, Height - 1);
|
Rectangle rect = new Rectangle(0, 0, Width - 1, Height - 1);
|
||||||
g.FillRoundRectangle(color, rect, rect.Height);
|
using GraphicsPath path1 = rect.CreateTrueRoundedRectanglePath(rect.Height);
|
||||||
|
g.FillPath(color, path1, true);
|
||||||
|
|
||||||
int width = Width - 3 - 1 - 3 - (rect.Height - 6);
|
int width = Width - 3 - 1 - 3 - (rect.Height - 6);
|
||||||
if (!Active)
|
if (!Active)
|
||||||
|
@ -153,27 +153,14 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
tipsBtn = new UIButton();
|
tipsBtn = new UIButton();
|
||||||
tipsBtn.Cursor = System.Windows.Forms.Cursors.Hand;
|
tipsBtn.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
tipsBtn.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
tipsBtn.Size = new System.Drawing.Size(6, 6);
|
||||||
tipsBtn.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.Location = new System.Drawing.Point(285, 519);
|
|
||||||
tipsBtn.MinimumSize = new System.Drawing.Size(1, 1);
|
|
||||||
tipsBtn.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
|
|
||||||
tipsBtn.Size = new System.Drawing.Size(9, 9);
|
|
||||||
tipsBtn.Style = Sunny.UI.UIStyle.Red;
|
tipsBtn.Style = Sunny.UI.UIStyle.Red;
|
||||||
tipsBtn.StyleCustomMode = true;
|
tipsBtn.StyleCustomMode = true;
|
||||||
tipsBtn.TabIndex = 118;
|
|
||||||
tipsBtn.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
|
|
||||||
tipsBtn.Text = "";
|
tipsBtn.Text = "";
|
||||||
tipsBtn.Click += TipsBtn_Click;
|
tipsBtn.Click += TipsBtn_Click;
|
||||||
|
|
||||||
Controls.Add(tipsBtn);
|
Controls.Add(tipsBtn);
|
||||||
tipsBtn.Location = new System.Drawing.Point(Width - 11, 2);
|
tipsBtn.Location = new System.Drawing.Point(Width - 8, 2);
|
||||||
tipsBtn.BringToFront();
|
tipsBtn.BringToFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,7 +667,7 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
if (tipsBtn != null)
|
if (tipsBtn != null)
|
||||||
{
|
{
|
||||||
tipsBtn.Location = new System.Drawing.Point(Width - 11, 2);
|
tipsBtn.Location = new System.Drawing.Point(Width - 8, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1638,7 +1638,7 @@ namespace Sunny.UI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WindowState == FormWindowState.Maximized)
|
if (WindowState == FormWindowState.Maximized || UIStyles.GlobalRectangle)
|
||||||
{
|
{
|
||||||
FormEx.SetFormRoundRectRegion(this, 0);
|
FormEx.SetFormRoundRectRegion(this, 0);
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,14 @@ namespace Sunny.UI
|
|||||||
set => UIStyles.GlobalFont = value;
|
set => UIStyles.GlobalFont = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DefaultValue(false)]
|
||||||
|
[Description("全局矩形设置,开启后所有控件都关闭圆角效果"), Category("SunnyUI")]
|
||||||
|
public bool GlobalRectangle
|
||||||
|
{
|
||||||
|
get => UIStyles.GlobalRectangle;
|
||||||
|
set => UIStyles.GlobalRectangle = value;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 版本
|
/// 版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -41,6 +41,8 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
public static bool GlobalFont { get; set; } = false;
|
public static bool GlobalFont { get; set; } = false;
|
||||||
|
|
||||||
|
public static bool GlobalRectangle { get; set; } = false;
|
||||||
|
|
||||||
public static bool DPIScale { get; set; }
|
public static bool DPIScale { get; set; }
|
||||||
|
|
||||||
public static bool ZoomScale { get; set; }
|
public static bool ZoomScale { get; set; }
|
||||||
@ -115,7 +117,7 @@ namespace Sunny.UI
|
|||||||
internal static Font Font()
|
internal static Font Font()
|
||||||
{
|
{
|
||||||
byte gdiCharSet = GetGdiCharSet("微软雅黑");
|
byte gdiCharSet = GetGdiCharSet("微软雅黑");
|
||||||
return new Font("微软雅黑", DefaultFontSize, FontStyle.Regular, GraphicsUnit.Point, gdiCharSet);
|
return new Font(familyName: "微软雅黑", DefaultFontSize, FontStyle.Regular, GraphicsUnit.Point, gdiCharSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user