I have a question..

I have this script:

int mouseDownX;
        int mouseDownY;

        int width;
        int height;

        private void Form1_MouseUp(object sender, MouseEventArgs mouseEv)
            width = mouseEv.X - mouseDownX;
            height = mouseEv.Y - mouseDownY;

            textBox2.Text = Convert.ToString(mouseEv.Location);

            Graphics graphics = this.CreateGraphics();

            Rectangle rectangle = new Rectangle(
                    mouseDownX, mouseDownY, width, height);

            graphics.DrawRectangle(Pens.Red, rectangle);

        private void Form1_MouseDown(object sender, MouseEventArgs mouseEv)
            textBox1.Text = Convert.ToString(mouseEv.Location);

            mouseDownX = mouseEv.X;
            mouseDownY = mouseEv.Y;

Which works fine if I make a rectangle from the left top corner to the right bottom corner

But is there any easier way of just making rectangles?

Here is a video of what I want:

And here is a download link to my project:

So I want to be able to draw rectangles from any angle if you understand?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.