* 重构DrawString函数
This commit is contained in:
parent
ce0f45cc20
commit
527935aedd
@ -168,7 +168,8 @@ namespace Sunny.UI
|
|||||||
g.FillPolygon(br, points.ToArray());
|
g.FillPolygon(br, points.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
g.DrawString(Text, Font, ForeColor, (Width - sf.Width) / 2.0f, (Height - sf.Height) / 2.0f);
|
//g.DrawString(Text, Font, ForeColor, (Width - sf.Width) / 2.0f, (Height - sf.Height) / 2.0f);
|
||||||
|
g.DrawString(Text, Font, ForeColor, ClientRectangle, ContentAlignment.MiddleCenter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -181,7 +182,7 @@ namespace Sunny.UI
|
|||||||
width = width + Height + 6;
|
width = width + Height + 6;
|
||||||
if (itemWidth < width) itemWidth = (int)width;
|
if (itemWidth < width) itemWidth = (int)width;
|
||||||
|
|
||||||
float begin = 0;
|
int begin = 0;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
foreach (var item in Items)
|
foreach (var item in Items)
|
||||||
{
|
{
|
||||||
@ -237,9 +238,10 @@ namespace Sunny.UI
|
|||||||
g.FillPolygon(br, points.ToArray());
|
g.FillPolygon(br, points.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
g.DrawString(item.ToString(), Font, index <= ItemIndex ? ForeColor : UnSelectedForeColor, begin + (itemWidth - sf.Width) / 2.0f, (Height - sf.Height) / 2.0f);
|
//g.DrawString(item.ToString(), Font, index <= ItemIndex ? ForeColor : UnSelectedForeColor, begin + (itemWidth - sf.Width) / 2.0f, (Height - sf.Height) / 2.0f);
|
||||||
|
g.DrawString(item.ToString(), Font, index <= ItemIndex ? ForeColor : UnSelectedForeColor,
|
||||||
begin = begin + itemWidth - 3 - Height / 2.0f + Interval;
|
new Rectangle(begin, 0, itemWidth, Height), ContentAlignment.MiddleCenter);
|
||||||
|
begin = begin + itemWidth - 3 - Height / 2 + Interval;
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,11 +319,12 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
e.Graphics.SetHighQuality();
|
e.Graphics.SetHighQuality();
|
||||||
SizeF sf = e.Graphics.MeasureString(TipsText, TempFont);
|
SizeF sf = e.Graphics.MeasureString(TipsText, TempFont);
|
||||||
float sfMax = Math.Max(sf.Width, sf.Height);
|
int sfMax = (int)Math.Max(sf.Width, sf.Height) + 1;
|
||||||
float x = Width - 1 - 2 - sfMax;
|
int x = Width - 1 - 2 - sfMax;
|
||||||
float y = 1 + 1;
|
int y = 1 + 1;
|
||||||
e.Graphics.FillEllipse(TipsColor, x, y, sfMax, sfMax);
|
e.Graphics.FillEllipse(TipsColor, x - 1, y, sfMax, sfMax);
|
||||||
e.Graphics.DrawString(TipsText, TempFont, TipsForeColor, x + sfMax / 2.0f - sf.Width / 2.0f, y + sfMax / 2.0f - sf.Height / 2.0f);
|
//e.Graphics.DrawString(TipsText, TempFont, TipsForeColor, x + sfMax / 2.0f - sf.Width / 2.0f, y + sfMax / 2.0f - sf.Height / 2.0f);
|
||||||
|
e.Graphics.DrawString(TipsText, TempFont, TipsForeColor, new Rectangle(x, y, sfMax, sfMax), ContentAlignment.MiddleCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Focused && ShowFocusLine)
|
if (Focused && ShowFocusLine)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user