From 3143d2f775c208a39a070bd398653eb114daa15c Mon Sep 17 00:00:00 2001 From: dazuo0312 Date: Tue, 12 Oct 2021 17:40:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=BD=93Alignment=20=3DTabAlignment.Bottom?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E9=A1=B5=E7=AD=BE=E6=96=87=E5=AD=97=E5=81=8F?= =?UTF-8?q?=E4=B8=8A=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UITabControl.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/SunnyUI/Controls/UITabControl.cs b/SunnyUI/Controls/UITabControl.cs index 1760123d..8eb87f52 100644 --- a/SunnyUI/Controls/UITabControl.cs +++ b/SunnyUI/Controls/UITabControl.cs @@ -476,8 +476,14 @@ 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, 2 + (TabRect.Height - sf.Height - 4) / 2.0f); + if(Alignment ==TabAlignment.Bottom ) + { + g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, 2 + (TabRect.Height - sf.Height + 4) / 2.0f); + } + else + { + 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; -- Gitee From 160aa97d2cee2f77b99efcb3ffc23f9cf8795e13 Mon Sep 17 00:00:00 2001 From: dazuo0312 Date: Wed, 13 Oct 2021 15:56:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=BD=93Alignment=20=3D=20TabAlignment.Bot?= =?UTF-8?q?tom=E6=97=B6=EF=BC=8C=E9=A1=B5=E7=AD=BE=E6=96=87=E5=AD=97?= =?UTF-8?q?=E5=81=8F=E4=B8=8A=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UITabControl.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/SunnyUI/Controls/UITabControl.cs b/SunnyUI/Controls/UITabControl.cs index 8eb87f52..d63a3007 100644 --- a/SunnyUI/Controls/UITabControl.cs +++ b/SunnyUI/Controls/UITabControl.cs @@ -455,7 +455,10 @@ namespace Sunny.UI 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); - + if (Alignment == TabAlignment.Bottom) + { + TabRect = new Rectangle(GetTabRect(index).Location.X- 2, GetTabRect(index).Location.Y + 2, ItemSize.Width, ItemSize.Height); + } Bitmap bmp = new Bitmap(TabRect.Width, TabRect.Height); Graphics g = Graphics.FromImage(bmp); @@ -476,13 +479,14 @@ namespace Sunny.UI if (TabSelectedHighColorSize > 0) g.FillRectangle(TabSelectedHighColor, 0, bmp.Height - TabSelectedHighColorSize, bmp.Width, TabSelectedHighColorSize); } - if(Alignment ==TabAlignment.Bottom ) + + if (Alignment == TabAlignment.Bottom) { - g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, 2 + (TabRect.Height - sf.Height + 4) / 2.0f); + g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, (TabRect.Height - sf.Height - TabSelectedHighColorSize) / 2.0f); } else { - g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, 2 + (TabRect.Height - sf.Height - 4) / 2.0f); + g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, 2 + (TabRect.Height - sf.Height - TabSelectedHighColorSize) / 2.0f); } var menuItem = Helper[index]; -- Gitee