From 282c1ae17cf12b335d1314dc115b6ef89fc4e76c Mon Sep 17 00:00:00 2001 From: Sunny Date: Thu, 13 Feb 2025 10:45:17 +0800 Subject: [PATCH] =?UTF-8?q?*=20UITabControl:=20=E5=A2=9E=E5=8A=A0=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E9=A1=B5=E5=88=86=E5=89=B2=E7=BA=BF=E5=B1=9E=E6=80=A7?= =?UTF-8?q?ShowTabDivider=EF=BC=8C#IBLERL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UITabControl.cs | 38 +++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/SunnyUI/Controls/UITabControl.cs b/SunnyUI/Controls/UITabControl.cs index 12fb5d94..d92aeb5c 100644 --- a/SunnyUI/Controls/UITabControl.cs +++ b/SunnyUI/Controls/UITabControl.cs @@ -37,6 +37,7 @@ * 2024-12-12: V3.8.0 修复标签文字越界显示 #IB8571 * 2024-12-12: V3.8.0 增加未选页签颜色 #IB7U69 * 2025-02-07: V3.8.1 修复切换主题色时,TabPage未设置背景色,#IBKDR7 + * 2025-02-13: V3.8.1 增加标签页分割线属性ShowTabDivider,#IBLERL ******************************************************************************/ using System; @@ -104,6 +105,20 @@ namespace Sunny.UI [Browsable(false), DefaultValue(typeof(Rectangle), "0, 0, 0, 0")] public Rectangle ZoomScaleRect { get; set; } + private bool _showTabDivider = true; + + [Description("显示标签页分割线"), Category("SunnyUI")] + [DefaultValue(true)] + public bool ShowTabDivider + { + get => _showTabDivider; + set + { + _showTabDivider = value; + Invalidate(); + } + } + /// /// 设置控件缩放比例 /// @@ -661,6 +676,16 @@ namespace Sunny.UI return; } + int tabIdx = -1; + for (int i = 0; i < TabCount; i++) + { + if (SelectedTab == TabPages[i]) + { + tabIdx = i; + break; + } + } + for (int index = 0; index <= TabCount - 1; index++) { Rectangle TabRect = new Rectangle(GetTabRect(index).Location.X - 2, GetTabRect(index).Location.Y - 2, ItemSize.Width, ItemSize.Height); @@ -690,11 +715,6 @@ namespace Sunny.UI if (TabSelectedHighColorSize > 0 && index == SelectedIndex) e.Graphics.FillRectangle(TabSelectedHighColor, TabRect.Left, TabRect.Height - TabSelectedHighColorSize, TabRect.Width, TabSelectedHighColorSize); - if (index <= TabCount - 2) - { - e.Graphics.DrawLine(tabUnSelectedForeColor.Alpha(100), TabRect.Right - 1, TabRect.Center().Y - sf.Height / 2.0f, TabRect.Right - 1, sf.Height + sf.Height / 2.0f); - } - //e.Graphics.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, // new Rectangle(TabRect.Left + textLeft, TabRect.Top, TabRect.Width, TabRect.Height), ContentAlignment.MiddleLeft); @@ -743,6 +763,12 @@ namespace Sunny.UI e.Graphics.FillEllipse(TipsColor, TabRect.Left + x - 1, y, sfMax, sfMax); e.Graphics.DrawString(TipsText, TempFont, TipsForeColor, new Rectangle(TabRect.Left + x, y, sfMax, sfMax), ContentAlignment.MiddleCenter); } + + if (index <= TabCount - 2 && ShowTabDivider) + { + if (index != tabIdx) + e.Graphics.DrawLine(tabUnSelectedForeColor.Alpha(100), TabRect.Right - 1, TabRect.Center().Y - TabRect.Height / 4.0f, TabRect.Right - 1, TabRect.Center().Y + TabRect.Height / 4.0f); + } } } @@ -898,7 +924,7 @@ namespace Sunny.UI base.OnSelectedIndexChanged(e); CloseRects.Clear(); Init(); - if (ShowActiveCloseButton && !ShowCloseButton) + if ((ShowActiveCloseButton && !ShowCloseButton) || ShowTabDivider) { timer.Start(); }