* 重构DrawString函数
This commit is contained in:
parent
6587289286
commit
368f0c4498
@ -638,9 +638,8 @@ namespace Sunny.UI
|
|||||||
/// <param name="path">路径</param>
|
/// <param name="path">路径</param>
|
||||||
protected virtual void OnPaintFore(Graphics g, GraphicsPath path)
|
protected virtual void OnPaintFore(Graphics g, GraphicsPath path)
|
||||||
{
|
{
|
||||||
Color color = GetForeColor();
|
|
||||||
Rectangle rect = new Rectangle(Padding.Left, Padding.Top, Width - Padding.Left - Padding.Right, Height - Padding.Top - Padding.Bottom);
|
Rectangle rect = new Rectangle(Padding.Left, Padding.Top, Width - Padding.Left - Padding.Right, Height - Padding.Top - Padding.Bottom);
|
||||||
g.DrawString(Text, Font, color, rect, TextAlign);
|
g.DrawString(Text, Font, GetForeColor(), rect, TextAlign);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnTextChanged(EventArgs e)
|
protected override void OnTextChanged(EventArgs e)
|
||||||
|
@ -220,18 +220,6 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 绘制前景颜色
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g">绘图图面</param>
|
|
||||||
/// <param name="path">绘图路径</param>
|
|
||||||
protected override void OnPaintFore(Graphics g, GraphicsPath path)
|
|
||||||
{
|
|
||||||
Padding = new Padding(_symbolSize + _imageInterval * 2, Padding.Top, Padding.Right, Padding.Bottom);
|
|
||||||
//填充文字
|
|
||||||
g.DrawString(Text, Font, foreColor, Size, Padding, TextAlign);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置主题样式
|
/// 设置主题样式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -255,7 +243,7 @@ namespace Sunny.UI
|
|||||||
float left = 0;
|
float left = 0;
|
||||||
float top = 0;
|
float top = 0;
|
||||||
SizeF ImageSize = e.Graphics.GetFontImageSize(Symbol, SymbolSize);
|
SizeF ImageSize = e.Graphics.GetFontImageSize(Symbol, SymbolSize);
|
||||||
SizeF TextSize = e.Graphics.MeasureString(Text, Font);
|
Size TextSize = TextRenderer.MeasureText(Text, Font);
|
||||||
|
|
||||||
if (Dock == DockStyle.None && autoSize)
|
if (Dock == DockStyle.None && autoSize)
|
||||||
{
|
{
|
||||||
@ -300,6 +288,12 @@ namespace Sunny.UI
|
|||||||
e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor, ImageInterval + (Width - ImageSize.Width) / 2.0f, (Height - ImageSize.Height) / 2.0f, SymbolOffset.X, SymbolOffset.Y);
|
e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor, ImageInterval + (Width - ImageSize.Width) / 2.0f, (Height - ImageSize.Height) / 2.0f, SymbolOffset.X, SymbolOffset.Y);
|
||||||
else
|
else
|
||||||
e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor, left, top, SymbolOffset.X, SymbolOffset.Y);
|
e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor, left, top, SymbolOffset.X, SymbolOffset.Y);
|
||||||
}
|
|
||||||
|
Rectangle rect = new Rectangle((int)left + SymbolSize, (int)top, Width, SymbolSize);
|
||||||
|
e.Graphics.DrawString(Text, Font, ForeColor, rect, ContentAlignment.MiddleLeft);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnPaintFore(Graphics g, GraphicsPath path)
|
||||||
|
{ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,8 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
string text = Text;
|
string text = Text;
|
||||||
if (!showText && Text.IsValid()) text = "";
|
if (!showText && Text.IsValid()) text = "";
|
||||||
g.DrawString(text, Font, GetForeColor(), Size, Padding, TextAlignment);
|
Rectangle rect = new Rectangle(Padding.Left, Padding.Top, Width - Padding.Left - Padding.Right, Height - Padding.Top - Padding.Bottom);
|
||||||
|
g.DrawString(text, Font, GetForeColor(), rect, TextAlignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user