!50 当Alignment = TabAlignment.Bottom时,页签文字偏上问题修复。

Merge pull request !50 from dazuo0312/master
This commit is contained in:
Sunny 2021-10-13 08:42:19 +00:00 committed by Gitee
commit 58528d1d7b

View File

@ -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,8 +479,15 @@ 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, (TabRect.Height - sf.Height - TabSelectedHighColorSize) / 2.0f);
}
else
{
g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, 2 + (TabRect.Height - sf.Height - TabSelectedHighColorSize) / 2.0f);
}
var menuItem = Helper[index];
bool show1 = TabPages[index].Text != MainPage;