Task in c# windows forms on picturebox

Draw two circles with the mouse on picturebox. When lowering the mouse, the center of the circle is set, and when released, its radius set. The coordinates of the center of the circles and their radii are displayed on the form (in Cartesian CS). Determine the mutual arrangement of circles (coincide, intersect, touch or have no common points). Create the ability to move the circles with the mouse.

This sounds like homework. We don’t DO other people’s homework. We’ll help, but you have to make an effort and show us what you’ve tried so far…

List<Point> Pnt = new List<Point>();
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (Pnt.Count < 4) Pnt.Add(new Point(e.X, e.Y));
        }
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            if (Pnt.Count < 4)
            {
                Pnt.Add(new Point(e.X, e.Y));
                using (Graphics g = CreateGraphics())
                    Circle(g);
            }
        }
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            if (Pnt.Count > 1) Circle(e.Graphics);
        }
        void Circle(Graphics g)
        {
            for (int i = 0; i < Pnt.Count; i += 2)
            {
                int dx = Pnt[i].X - Pnt[i + 1].X;
                int dy = Pnt[i].Y - Pnt[i + 1].Y;
                int r = (int)Math.Sqrt(dx * dx + dy * dy);
                g.DrawEllipse(Pens.Black, Pnt[i].X - r, Pnt[i].Y - r, 2 * r, 2 * r);
            }
        }

OK, now step #2

  • What output are you getting?
  • How is that different from what you were expecting