* UIGroupBox: 解决Radius为0时的报错
This commit is contained in:
parent
c112b98c66
commit
8724325508
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -43,15 +43,7 @@ namespace Sunny.UI
|
||||
|
||||
protected override void OnPaintRect(Graphics g, GraphicsPath path)
|
||||
{
|
||||
//IsRadius为True时,显示左上圆角
|
||||
bool RadiusLeftTop = RadiusSides.GetValue(UICornerRadiusSides.LeftTop);
|
||||
//IsRadius为True时,显示左下圆角
|
||||
bool RadiusLeftBottom = RadiusSides.GetValue(UICornerRadiusSides.LeftBottom);
|
||||
//IsRadius为True时,显示右上圆角
|
||||
bool RadiusRightTop = RadiusSides.GetValue(UICornerRadiusSides.RightTop);
|
||||
//IsRadius为True时,显示右下圆角
|
||||
bool RadiusRightBottom = RadiusSides.GetValue(UICornerRadiusSides.RightBottom);
|
||||
path = new Rectangle(0, TitleTop, Width - 1, Height - _titleTop - 1).CreateRoundedRectanglePath(Radius, RadiusLeftTop, RadiusRightTop, RadiusRightBottom, RadiusLeftBottom);
|
||||
path = new Rectangle(0, TitleTop, Width - 1, Height - _titleTop - 1).CreateRoundedRectanglePath(Radius, RadiusSides);
|
||||
base.OnPaintRect(g, path);
|
||||
}
|
||||
|
||||
|
@ -697,7 +697,12 @@ namespace Sunny.UI
|
||||
|
||||
if (radiusSides == UICornerRadiusSides.None || radius == 0)
|
||||
{
|
||||
Point[] points = new Point[] { new Point(0, 0), new Point(rect.Width, 0), new Point(rect.Width, rect.Height), new Point(0, rect.Height), new Point(0, 0), };
|
||||
Point[] points = new Point[] {
|
||||
new Point(rect.Left, rect.Top),
|
||||
new Point(rect.Right, rect.Top),
|
||||
new Point(rect.Right, rect.Bottom),
|
||||
new Point(rect.Left, rect.Bottom),
|
||||
new Point(rect.Left, rect.Top) };
|
||||
path = points.Path();
|
||||
}
|
||||
else
|
||||
@ -889,6 +894,19 @@ namespace Sunny.UI
|
||||
public static GraphicsPath CreateRoundedRectanglePath(this Rectangle rect, int radius, bool cornerLeftTop = true, bool cornerRightTop = true, bool cornerRightBottom = true, bool cornerLeftBottom = true)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
if ((!cornerLeftTop && !cornerRightTop && !cornerRightBottom && !cornerLeftBottom) || radius <= 0)
|
||||
{
|
||||
Point[] points = new Point[] {
|
||||
new Point(rect.Left, rect.Top),
|
||||
new Point(rect.Right, rect.Top),
|
||||
new Point(rect.Right, rect.Bottom),
|
||||
new Point(rect.Left, rect.Bottom),
|
||||
new Point(rect.Left, rect.Top) };
|
||||
path = points.Path();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cornerLeftTop)
|
||||
path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
|
||||
else
|
||||
@ -910,6 +928,8 @@ namespace Sunny.UI
|
||||
path.AddLine(new Point(rect.X + 1, rect.Y + rect.Height), new Point(rect.X, rect.Y + rect.Height));
|
||||
|
||||
path.CloseFigure();
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user