You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[API Proposal]: DrawRectangle should accept RectangleF as one of the overloads #62401
api-approvedAPI was approved in API review, it can be implementedarea-System.Drawingin-prThere is an active PR which will close this issue when it is merged
In Graphics class, FillRectangle contains the following 4 overloads:
public void FillRectangle(Brush brush, RectangleF rect)
public void FillRectangle(Brush brush, float x, float y, float width, float height)
public void FillRectangle(Brush brush, Rectangle rect)
public void FillRectangle(Brush brush, int x, int y, int width, int height)
However, DrawRectangle, contains only the following 3 overloads:
public void DrawRectangle(Pen pen, Rectangle rect)
public void DrawRectangle(Pen pen, float x, float y, float width, float height)
public void DrawRectangle(Pen pen, int x, int y, int width, int height)
In the interest of symmetry, I propose adding the "missing" RectangleF overload:
public void DrawRectangle(Pen pen, RectangleF rect)
During a development process one can quite often switch between DrawRectangle and FillRectangle API. This would allow to do so without changing the variables around, i.e. just by changing Fill into Draw and backward. Likewise, this would make drawing filled rectangles with outline in different color minutely easier.
API usage would be comparable to the existing API:
varrect=newRectangleF(...);e.Graphics.FillRectangle(Brushes.Blue,rect);// this works even nowe.Graphics.DrawRectangle(Pens.Red,rect);// this would be a new overload
Alternative Designs
No response
Risks
Since method will just be a convenient way of calling already existing overload, risk is minimal if any.
Are there any other? Seems like FillPie would be in the same category.
Agreed; missed that one. I believe FillPie is the only one missing RectangleF but having Rectangle. There is a DrawIcon but there I believe having just Rectangle is appropriate.
I did ask for pull request to be reopened (yes, I did things slightly out of order). Once that happens I will push commit for FillPie in addition to DrawRectangle that was already part of original pull request.
api-approvedAPI was approved in API review, it can be implementedarea-System.Drawingin-prThere is an active PR which will close this issue when it is merged
Activity
safern commentedon Dec 6, 2021
Makes sense to add this overload to be consistent with what we have on other APIs, i.e
Graphics.FillRectangle.Marking it as api-ready-for-review to discuss it on the review meeting.
terrajobst commentedon Dec 14, 2021
Video
FillPiewould be in the same category.medo64 commentedon Dec 15, 2021
Agreed; missed that one. I believe
FillPieis the only one missingRectangleFbut havingRectangle. There is aDrawIconbut there I believe having justRectangleis appropriate.medo64 commentedon Dec 15, 2021
I did ask for pull request to be reopened (yes, I did things slightly out of order). Once that happens I will push commit for
FillPiein addition toDrawRectanglethat was already part of original pull request.deeprobin commentedon Dec 21, 2021
Please tag this with "in pr" 😄 thank you
jeffhandley commentedon Mar 16, 2022
This was completed in #62385