0

Hi,I am able to draw rectangles on the picture but I am not able to capture the co-ordinates of the picture box instead it capture the screen coordinates.So the rectangle that I draw on the picture box doesn't appear on the position that I desire.

// Convert and normalize the points and draw the reversible frame.

private void MyDrawReversibleRectangle(Point p1, Point p2)
        {
            Rectangle rc = new Rectangle();

            // Convert the points to screen coordinates.
            p1 = this.pictureBox1.PointToScreen  (p1);
            p2 = this.pictureBox1.PointToScreen (p2);
            // Normalize the rectangle.
            if (p1.X < p2.X)
            {
                rc.X = p1.X;
                rc.Width = p2.X - p1.X;
            }
            else
            {
                rc.X = p2.X;
                rc.Width = p1.X - p2.X;
            }
            if (p1.Y < p2.Y)
            {
                rc.Y = p1.Y;
                rc.Height = p2.Y - p1.Y;
            }
            else
            {
                rc.Y = p2.Y;
                rc.Height = p1.Y - p2.Y;
            }
            
            textBox1.Text = Convert.ToString(rc.X);
            textBox2.Text = Convert.ToString(rc.Y);
            textBox3.Text = Convert.ToString(rc.Width);
            textBox4.Text = Convert.ToString(rc.Height);
            // Draw the reversible frame.
            ControlPaint.DrawReversibleFrame(rc,
                            Color.Black, FrameStyle.Thick);

        }
private void button1_Click(object sender, EventArgs e)
        {
            
            motionDetector = new MotionDetector(simpleBackgroundModeling, blobCounting);
            //string[] s = File.ReadAllLines("MotionZone.txt");
            int x = Convert.ToInt32 (textBox1.Text);
            int y = Convert.ToInt32(textBox2.Text);
            int width = Convert.ToInt32(textBox3.Text);
            int height = Convert.ToInt32(textBox4.Text);
            bflag = true;
           // btnVideoStop.Enabled = true;
           // btnPlay.Enabled = false;
            rectangle[1] = new Rectangle(x, y, width, height);
2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by nick.crane
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.