/// <summary> /// Draw a one-line string to fit in the specified rectangle. /// </summary> /// <param name="text">Text to draw.</param> /// <param name="baseFont">Start from this font, but resize it.</param> /// <param name="brush">Brush to use for drawing.</param> /// <param name="place">Where to draw it.</param> public void DrawTextInRectangle(string text, Brush brush, Font baseFont, Rectangle2D place) { Rectangle dest = this.Scale(place); Font font = DrawingSurface2D.ChooseFont(this.grph, baseFont, dest.Size, text); if (font == null || font.Size < 3) { // too small anyway return; } SizeF actualSize = this.grph.MeasureString(text, font); int adjustX = (int)(dest.Width - actualSize.Width) / 2; int adjustY = dest.Height / 2; this.DrawRightJustifiedTextAbsoluteCoordinates(text, font, brush, dest.Right - adjustX, dest.Top + adjustY); }