|
private void button1_Click (object sender, EventArgs e)
{
Graphics g = this.CreateGraphics ();
SizeF MyFontSize = SizeF.Empty;
Rectangle MyRect = new Rectangle (0, 0, 200, 100);
Font MyFont = new Font ("Arial", 100);
string str = "Where to write qweqwewqewqeqwe?";
MyFontSize = g.MeasureString ("String to draw ...", MyFont);
while (MyFontSize.Width> MyRect.Width ||
MyFontSize.Height> MyRect.Height)
{
MyFont = new Font ("Arial", (MyFont.Size-.01F));
MyFontSize = g.MeasureString (str, MyFont);
}
g.DrawRectangle (Pens.Black, 0,0, MyFontSize.Width, MyFontSize.Height);
g.DrawString (str, MyFont, Brushes.Black, new PointF (0, 0));
}
Fill a rectangle completely. |
|