http://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawrectangle.aspx
FillRectangle, DrawRectangle, FillElipse and DrawEllipse all can take 4 Float (or "Single") parameters: x, y, width, height. DrawRectangle is the only one that will not take a RectangleF, though.
I was wondering if anyone knew why this is. It sure seems like they just plain forgot to overload it.
Well it sure does look like an omission to me too.
Interestingly, there is an overload of DrawRectangles that takes a RectangleF[] array as a parameter.
So I suppose you could use this with an array size of one if needed.
According to the Andy's answer the extension should be as below
public static class GraphicsExtensions
{
public static void DrawRectangle(this Graphics g, Pen pen, RectangleF rect)
{
g.DrawRectangles(pen, new[] { rect });
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With