From e916d6911dd6a443fcde9e1e82d81d4f4a7a17fa Mon Sep 17 00:00:00 2001 From: Sunny Date: Thu, 11 Aug 2022 21:11:18 +0800 Subject: [PATCH] =?UTF-8?q?*=20UITabControlMenu:=20=E9=87=8D=E5=86=99ItemS?= =?UTF-8?q?ize=EF=BC=8C=E5=B0=86=E5=AE=BD=E3=80=81=E9=AB=98=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E4=B8=BA=E6=AD=A3=E5=B8=B8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UITabControlMenu.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/SunnyUI/Controls/UITabControlMenu.cs b/SunnyUI/Controls/UITabControlMenu.cs index ec97c95a..ff66b6bb 100644 --- a/SunnyUI/Controls/UITabControlMenu.cs +++ b/SunnyUI/Controls/UITabControlMenu.cs @@ -17,6 +17,7 @@ * 创建日期: 2020-01-01 * * 2020-01-01: V2.2.0 增加文件说明 + * 2022-08-11: V3.0.2 重写ItemSize,将宽、高调整为正常显示 ******************************************************************************/ using System; @@ -38,7 +39,7 @@ namespace Sunny.UI DoubleBuffered = true; UpdateStyles(); - ItemSize = new Size(40, 200); + base.ItemSize = new Size(40, 200); DrawMode = TabDrawMode.OwnerDrawFixed; Font = UIFontColor.Font(); AfterSetFillColor(FillColor); @@ -50,6 +51,17 @@ namespace Sunny.UI _fillColor = UIStyles.Blue.TabControlBackColor; } + [DefaultValue(typeof(Size), "200, 40")] + public new Size ItemSize + { + get => new Size(base.ItemSize.Height, base.ItemSize.Width); + set + { + base.ItemSize = new Size(value.Height, value.Width); + Invalidate(); + } + } + /// /// 禁止控件跟随窗体缩放 /// @@ -346,7 +358,7 @@ namespace Sunny.UI e.Graphics.Clear(TabBackColor); for (int index = 0; index <= TabCount - 1; index++) { - Rectangle TabRect = new Rectangle(GetTabRect(index).Location.X - 2, GetTabRect(index).Location.Y - 2, ItemSize.Height + 4, ItemSize.Width); + Rectangle TabRect = new Rectangle(GetTabRect(index).Location.X - 2, GetTabRect(index).Location.Y - 2, base.ItemSize.Height + 4, base.ItemSize.Width); SizeF sf = e.Graphics.MeasureString(TabPages[index].Text, Font); int textLeft = 4 + 6 + 4 + (ImageList?.ImageSize.Width ?? 0); if (TextAlignment == HorizontalAlignment.Right)