I have a List
with float
coordinates and I'm trying to draw a rectangle around a line previously drawn.
Graphics G = e.Graphics;
Pen pen5 = new Pen(Color.DodgerBlue, 0.01f);
var rect2 = new RectangleF();
GraphicsPath maliOkvir = new GraphicsPath();
maliOkvir.AddLine(((float)(odabraniSegment[0].startX)),
(float)(odabraniSegment[0].startY),
(float)(odabraniSegment[0].endX),
(float)(odabraniSegment[0].endY));
rect2 = maliOkvir.GetBounds();
G.DrawRectangle(pen5, rect2);
I'm getting an error on rect2
part:
G.DrawRectangles(pen5, rect2);
Cannot convert from 'System.Drawing.RectangleF' to 'System.Drawing.RectangleF[]'
How can I fix this? tried multiple variations of Rectangle
and RectangleF
, none works together.. the end result should look like this:
The DrawRectangles
method expects an array of Rectangle
or RectangleF
objects but you are only passing in a single item. You should either:
DrawRectangle
Pass in an array:
G.DrawRectangles(pen5, new [] { rect2 });