简体   繁体   中英

How can I calculate the distance between the sides of a rectangle?

In this example:

private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
    label10.Text = ((n - 1) * 4).ToString();
    _mrect = new Rectangle(Math.Min(RectStartPoint.X, point.X), Math.Min(RectStartPoint.Y, point.Y),
                                Math.Abs(RectStartPoint.X - point.X), Math.Abs(RectStartPoint.Y - point.Y));
}

_mrect is:

X = 125
Y = 144
Width = 250 
Height = 169

I want to find the distance between the left edge of the rectangle to the right edge. And the distance between the top edge to the bottom edge.

please note that!

在此处输入图片说明

then, your answer is Width and Height ,

for more information: http://www.functionx.com/csharp1/winprog/pointsizerect.htm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM