diff --git a/SunnyUI/Controls/UILight.cs b/SunnyUI/Controls/UILight.cs index 9b8326eb..d2d47d8d 100644 --- a/SunnyUI/Controls/UILight.cs +++ b/SunnyUI/Controls/UILight.cs @@ -20,6 +20,7 @@ * 2021-06-19: V3.0.4 增加方形显示,优化渐变色 * 2021-08-07: V3.0.5 默认不显示灯光亮线 * 2022-05-15: V3.1.8 增加文字显示 + * 2022-05-12: V3.3.6 重构DrawString函数 ******************************************************************************/ using System; @@ -89,8 +90,9 @@ namespace Sunny.UI /// 绘图路径 protected override void OnPaintFore(Graphics g, GraphicsPath path) { - SizeF sf = g.MeasureString(Text, Font); - g.DrawString(Text, Font, ForeColor, Width / 2 - sf.Width / 2, Height / 2 - sf.Height / 2); + //SizeF sf = g.MeasureString(Text, Font); + //g.DrawString(Text, Font, ForeColor, Width / 2 - sf.Width / 2, Height / 2 - sf.Height / 2); + g.DrawString(Text, Font, ForeColor, ClientRectangle, TextAlign); } [DefaultValue(500), Description("显示间隔"), Category("SunnyUI")] diff --git a/SunnyUI/Controls/UITabControlMenu.cs b/SunnyUI/Controls/UITabControlMenu.cs index 17eddd28..0ac2c422 100644 --- a/SunnyUI/Controls/UITabControlMenu.cs +++ b/SunnyUI/Controls/UITabControlMenu.cs @@ -18,6 +18,7 @@ * * 2020-01-01: V2.2.0 增加文件说明 * 2022-08-11: V3.0.2 重写ItemSize,将宽、高调整为正常显示 + * 2022-05-12: V3.3.6 重构DrawString函数 ******************************************************************************/ using System; @@ -377,7 +378,8 @@ namespace Sunny.UI // 绘制标题 Color textColor = index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor; - e.Graphics.DrawString(TabPages[index].Text, Font, textColor, textLeft, TabRect.Top + 2 + (TabRect.Height - sf.Height) / 2.0f); + //e.Graphics.DrawString(TabPages[index].Text, Font, textColor, textLeft, TabRect.Top + 2 + (TabRect.Height - sf.Height) / 2.0f); + e.Graphics.DrawString(TabPages[index].Text, Font, textColor, new Rectangle(textLeft, TabRect.Top, TabRect.Width, TabRect.Height), ContentAlignment.MiddleLeft); // 绘制图标 if (ImageList != null) diff --git a/SunnyUI/Forms/UIForm.cs b/SunnyUI/Forms/UIForm.cs index a92b5db5..001e9322 100644 --- a/SunnyUI/Forms/UIForm.cs +++ b/SunnyUI/Forms/UIForm.cs @@ -45,6 +45,7 @@ * 2022-11-30: V3.3.0 增加RemoveAllPages函数 * 2023-01-25: V3.3.1 最大化后,关闭按钮扩大至原按钮右上角全部区域 * 2023-02-24: V3.3.2 修复PageSelected可能未显示选中页面的问题 + * 2022-05-12: V3.3.6 重构DrawString函数 ******************************************************************************/ using System; @@ -1242,14 +1243,16 @@ namespace Sunny.UI } } - SizeF sf = e.Graphics.MeasureString(Text, TitleFont); + //SizeF sf = e.Graphics.MeasureString(Text, TitleFont); if (TextAlignment == StringAlignment.Center) { - e.Graphics.DrawString(Text, TitleFont, titleForeColor, (Width - sf.Width) / 2, (TitleHeight - sf.Height) / 2); + //e.Graphics.DrawString(Text, TitleFont, titleForeColor, (Width - sf.Width) / 2, (TitleHeight - sf.Height) / 2); + e.Graphics.DrawString(Text, TitleFont, titleForeColor, new Rectangle(0, 0, Width, TitleHeight), ContentAlignment.MiddleCenter); } else { - e.Graphics.DrawString(Text, TitleFont, titleForeColor, 6 + (ShowTitleIcon && Icon != null ? 26 : 0), (TitleHeight - sf.Height) / 2); + //e.Graphics.DrawString(Text, TitleFont, titleForeColor, 6 + (ShowTitleIcon && Icon != null ? 26 : 0), (TitleHeight - sf.Height) / 2); + e.Graphics.DrawString(Text, TitleFont, titleForeColor, new Rectangle(6 + (ShowTitleIcon && Icon != null ? 26 : 0), 0, Width, TitleHeight), ContentAlignment.MiddleLeft); } }