From ce0182ebbf295bd7ffdc0dead04b4d74cf3c7fcd Mon Sep 17 00:00:00 2001 From: dazuo0312 Date: Mon, 12 Jul 2021 16:55:20 +0800 Subject: [PATCH] =?UTF-8?q?UITabControl=E6=8E=A7=E4=BB=B6=E6=94=B9?= =?UTF-8?q?=E8=BF=9B=EF=BC=9A=E6=94=AF=E6=8C=81Tab=E5=9C=A8=E4=B8=8B?= =?UTF-8?q?=E6=96=B9=E6=98=BE=E7=A4=BA=E3=80=82=20Alignment=20=3D=20TabAli?= =?UTF-8?q?gnment.Top=20Alignment=20=3D=20TabAlignment.Bottom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UITabControl.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/SunnyUI/Controls/UITabControl.cs b/SunnyUI/Controls/UITabControl.cs index 681b4e8e..57275b45 100644 --- a/SunnyUI/Controls/UITabControl.cs +++ b/SunnyUI/Controls/UITabControl.cs @@ -396,7 +396,7 @@ namespace Sunny.UI DoubleBuffered = true; SizeMode = TabSizeMode.Fixed; Appearance = TabAppearance.Normal; - Alignment = TabAlignment.Top; + //Alignment = TabAlignment.Top; } private bool showCloseButton; @@ -463,8 +463,8 @@ namespace Sunny.UI if (TabSelectedHighColorSize > 0) g.FillRectangle(TabSelectedHighColor, 0, bmp.Height - TabSelectedHighColorSize, bmp.Width, TabSelectedHighColorSize); } - - g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, TabRect.Top + 2 + (TabRect.Height - sf.Height - 4) / 2.0f); + + g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, 2 + (TabRect.Height - sf.Height - 4) / 2.0f); var menuItem = Helper[index]; bool show1 = TabPages[index].Text != MainPage; @@ -475,7 +475,7 @@ namespace Sunny.UI { if (ShowCloseButton || (ShowActiveCloseButton && index == SelectedIndex)) { - g.DrawFontImage(77, 28, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, new Rectangle(TabRect.Width - 28, TabRect.Top, 24, TabRect.Height)); + g.DrawFontImage(77, 28, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, new Rectangle(TabRect.Width - 28, 0, 24, TabRect.Height)); } } @@ -840,7 +840,16 @@ namespace Sunny.UI case User.WM_PAINT: if (!_bPainting) { - Point UpDownButtonLocation = new Point(_owner.Size.Width - 52, 0); + int itemTop = 0; + if(_owner.Alignment ==TabAlignment.Top ) + { + itemTop = 0; + } + else if (_owner.Alignment == TabAlignment.Bottom) + { + itemTop = _owner.Size.Height - _owner.ItemSize.Height; + } + Point UpDownButtonLocation = new Point(_owner.Size.Width - 52, itemTop); Size UpDownButtonSize = new Size(52, _owner.ItemSize.Height); clipRect = new Rectangle(UpDownButtonLocation, UpDownButtonSize); User.MoveWindow(Handle, UpDownButtonLocation.X, UpDownButtonLocation.Y, clipRect.Width, clipRect.Height);