* UIGroupBox: 解决BackColor,FillColor设置为透明时,标题下面会出现横线
This commit is contained in:
parent
22da0fccbd
commit
b95d430599
@ -300,6 +300,83 @@ namespace Sunny.UI
|
||||
return path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建圆角路径
|
||||
/// </summary>
|
||||
/// <param name="rect">区域</param>
|
||||
/// <param name="radius">圆角大小</param>
|
||||
/// <param name="radiusSides">圆角的方位</param>
|
||||
/// <param name="lineSize">线宽</param>
|
||||
/// <returns></returns>
|
||||
internal static GraphicsPath CreateRoundedRectanglePathWithoutTop(this Rectangle rect, int radius, UICornerRadiusSides radiusSides, int lineSize = 1)
|
||||
{
|
||||
GraphicsPath path;
|
||||
|
||||
if (radiusSides == UICornerRadiusSides.None || radius == 0)
|
||||
{
|
||||
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 + rect.Height), new Point(rect.X + rect.Width, rect.Y + rect.Height));
|
||||
path.AddLine(new Point(rect.X + rect.Width, rect.Y + rect.Height), new Point(rect.X + rect.Width, rect.Y));
|
||||
}
|
||||
else
|
||||
{
|
||||
//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 = rect.CreateRoundedRectanglePathWithoutTop(radius, RadiusLeftTop, RadiusRightTop, RadiusRightBottom, RadiusLeftBottom, lineSize);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
internal static GraphicsPath CreateRoundedRectanglePathWithoutTop(this Rectangle rect, int radius,
|
||||
bool cornerLeftTop = true, bool cornerRightTop = true, bool cornerRightBottom = true, bool cornerLeftBottom = true,
|
||||
int lineSize = 1)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
if ((!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 + rect.Height), new Point(rect.X + rect.Width, rect.Y + rect.Height));
|
||||
path.AddLine(new Point(rect.X + rect.Width, rect.Y + rect.Height), new Point(rect.X + rect.Width, rect.Y));
|
||||
}
|
||||
else
|
||||
{
|
||||
radius *= lineSize;
|
||||
|
||||
if (cornerRightTop)
|
||||
path.AddArc(rect.X + rect.Width - radius, rect.Y, radius, radius, 270, 90);
|
||||
else
|
||||
path.AddLine(new Point(rect.X + rect.Width - 1, rect.Y), new Point(rect.X + rect.Width, rect.Y));
|
||||
|
||||
if (cornerRightBottom)
|
||||
path.AddArc(rect.X + rect.Width - radius, rect.Y + rect.Height - radius, radius, radius, 0, 90);
|
||||
else
|
||||
path.AddLine(new Point(rect.X + rect.Width, rect.Y + rect.Height), new Point(rect.X + rect.Width, rect.Y + rect.Height));
|
||||
|
||||
if (cornerLeftBottom)
|
||||
path.AddArc(rect.X, rect.Bottom - radius, radius, radius, 90, 90);
|
||||
else
|
||||
path.AddLine(new Point(rect.X + 1, rect.Y + rect.Height), new Point(rect.X, rect.Y + rect.Height));
|
||||
|
||||
if (cornerLeftTop)
|
||||
path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
|
||||
else
|
||||
path.AddLine(new Point(rect.X, rect.Y + 1), new Point(rect.X, rect.Y));
|
||||
|
||||
//path.CloseFigure();
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绘图路径
|
||||
/// </summary>
|
||||
|
@ -368,7 +368,29 @@ namespace Sunny.UI
|
||||
int idx = VBar.Value;
|
||||
if (idx < 0) idx = 0;
|
||||
if (idx >= RowCount) idx = RowCount - 1;
|
||||
FirstDisplayedScrollingRowIndex = idx;
|
||||
|
||||
int lastFrozen = 0;
|
||||
if (Rows[0].Frozen)
|
||||
{
|
||||
for (int i = 0; i < Rows.Count; i++)
|
||||
{
|
||||
if (Rows[i].Frozen)
|
||||
{
|
||||
lastFrozen = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Rows[0].Frozen)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FirstDisplayedScrollingRowIndex = Math.Max(idx, lastFrozen);
|
||||
}
|
||||
|
||||
private void HorizontalScrollBar_ValueChanged(object sender, EventArgs e)
|
||||
|
@ -20,6 +20,7 @@
|
||||
* 2020-04-25: V2.2.4 更新主题配置类
|
||||
* 2022-05-30: V3.1.9 修复Padding设置
|
||||
* 2023-05-13: V3.3.6 重构DrawString函数
|
||||
* 2023-07-11: V3.4.0 解决BackColor,FillColor设置为透明时,标题下面会出现横线
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
@ -56,8 +57,22 @@ namespace Sunny.UI
|
||||
/// <param name="path">绘图路径</param>
|
||||
protected override void OnPaintRect(Graphics g, GraphicsPath path)
|
||||
{
|
||||
path = new Rectangle(0, TitleTop, Width - 1, Height - _titleTop - 1).CreateRoundedRectanglePath(Radius, RadiusSides);
|
||||
base.OnPaintRect(g, path);
|
||||
if (RectSides == ToolStripStatusLabelBorderSides.None)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var rect = new Rectangle(0, TitleTop, Width - 1, Height - _titleTop - 1);
|
||||
if (Text.IsValid())
|
||||
{
|
||||
path = rect.CreateRoundedRectanglePathWithoutTop(Radius, RadiusSides, RectSize);
|
||||
g.DrawPath(GetRectColor(), path, true, RectSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
path = rect.CreateRoundedRectanglePath(Radius, RadiusSides, RectSize);
|
||||
g.DrawPath(GetRectColor(), path, true, RectSize);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -67,7 +82,29 @@ namespace Sunny.UI
|
||||
/// <param name="path">绘图路径</param>
|
||||
protected override void OnPaintFore(Graphics g, GraphicsPath path)
|
||||
{
|
||||
Size size = TextRenderer.MeasureText(Text, Font);
|
||||
g.DrawString(Text, Font, ForeColor, FillColor, new Rectangle(TitleInterval, 0, Width - TitleInterval * 2, TitleTop * 2), TitleAlignment);
|
||||
|
||||
if (RectSides.GetValue(ToolStripStatusLabelBorderSides.Top))
|
||||
{
|
||||
if (RadiusSides.GetValue(UICornerRadiusSides.LeftTop))
|
||||
{
|
||||
g.DrawLine(RectColor, Radius / 2 * RectSize, TitleTop, TitleInterval, TitleTop, true, RectSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.DrawLine(RectColor, 0, TitleTop, TitleInterval, TitleTop, true, RectSize);
|
||||
}
|
||||
|
||||
if (RadiusSides.GetValue(UICornerRadiusSides.RightTop))
|
||||
{
|
||||
g.DrawLine(RectColor, TitleInterval + size.Width, TitleTop, Width - Radius / 2 * RectSize, TitleTop, true, RectSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.DrawLine(RectColor, TitleInterval + size.Width, TitleTop, Width, TitleTop, true, RectSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _titleTop = 16;
|
||||
|
Loading…
x
Reference in New Issue
Block a user