* UINavBar: 增加选中项圆角
This commit is contained in:
parent
e1823a882b
commit
a1cce40881
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -57,6 +57,16 @@ namespace Sunny.UI
|
||||
Version = UIGlobal.Version;
|
||||
}
|
||||
|
||||
private int radius;
|
||||
|
||||
[DefaultValue(0)]
|
||||
[Description("显示选择项圆角"), Category("SunnyUI")]
|
||||
public int Radius
|
||||
{
|
||||
get => radius;
|
||||
set => radius = Math.Max(0, value);
|
||||
}
|
||||
|
||||
protected override void OnSizeChanged(EventArgs e)
|
||||
{
|
||||
base.OnSizeChanged(e);
|
||||
@ -398,17 +408,34 @@ namespace Sunny.UI
|
||||
Color textColor = ForeColor;
|
||||
|
||||
if (i == ActiveIndex)
|
||||
{
|
||||
if (radius == 0)
|
||||
{
|
||||
e.Graphics.FillRectangle(MenuHoverColor, rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
var path = rect.CreateRoundedRectanglePath(Radius, UICornerRadiusSides.LeftTop | UICornerRadiusSides.RightTop);
|
||||
e.Graphics.FillPath(MenuHoverColor, path);
|
||||
}
|
||||
|
||||
textColor = SelectedForeColor;
|
||||
}
|
||||
|
||||
if (i == SelectedIndex)
|
||||
{
|
||||
if (MenuSelectedColorUsed)
|
||||
{
|
||||
if (radius == 0)
|
||||
{
|
||||
e.Graphics.FillRectangle(MenuSelectedColor, rect.X, Height - NodeSize.Height, rect.Width, NodeSize.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
var path = new Rectangle(rect.X, Height - NodeSize.Height, rect.Width, NodeSize.Height).CreateRoundedRectanglePath(Radius, UICornerRadiusSides.LeftTop | UICornerRadiusSides.RightTop);
|
||||
e.Graphics.FillPath(MenuSelectedColor, path);
|
||||
}
|
||||
}
|
||||
|
||||
if (!NavBarMenu.Visible && SelectedHighColorSize > 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user