title: Center text on a Polygon
body: <p>I am trying to put a label(string) at the center of a user created polygon. I checked the available methods on the Graphics class but I only found the DrawString method which takes a string, Font, and Rectangle. Problem is i am using a polygon. And there is no DrawPolygon overload which takes a string as a parameter.</p>
  
  <pre><code>// Get the highest and lowest of both axis to 
  // determine the width and height of the polygon
  int _lowestX = _slot.Min(o =&gt; o.X);
  int _highestX = _slot.Max(o =&gt; o.X);
  int _lowestY = _slot.Min(o =&gt; o.Y);
  int _highestY = _slot.Max(o =&gt; o.Y);
  
  // Draw the polygon
  e.Graphics.FillPolygon(Brushes.White, _slot.ToArray()); // _slot is a list of points
  e.Graphics.DrawPolygon(Pens.Blue, _slot.ToArray());
  
  Font _font = new Font(FontFamily.GenericSansSerif, _highestX - _lowestX, FontStyle.Regular);
  SizeF _textSize = e.Graphics.MeasureString("Slot 1", _font);
  
  // My attempt at drawing the text using the DrawString method 
  // by trying to mock a rectangle using the height and width of the polygon
  e.Graphics.DrawString("Slot 1", _font, new SolidBrush(Color.Black), (_highestX - _lowestX - _textSize.Width) / 2, 0);
  </code></pre>
  
  <p>Any suggestions on what to do?</p>
  
  <p>Thanks in advance.</p>