Bug when drawing rectangles in my Paint Program

我的梦境 提交于 2019-12-02 09:46:38

Try something like this in order to have the start and end points the right way:

int x0 = Math.Min(upPoint.X, downPoint.X);
int y0 = Math.Min(upPoint.Y, downPoint.Y);
Point upperLeft = new Point(x0, y0);

int x1 = Math.Max(upPoint.X, downPoint.X);
int y1 = Math.Max(upPoint.Y, downPoint.Y);
Point lowerRight = new Point(x1, y1);

And

Rectangle rect = new Rectangle(x0, y0, x1 - x0, y1 - y0);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!