Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
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.

What I have tried:

C#
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);
            }
        }
Posted
Updated 18-Sep-19 8:25am
v2
Comments
Patrice T 18-Sep-19 20:55pm    
And you have a question ?

1 solution

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

And the first thing you should do is read the question again, carefully. The code you have is ... um ... very poor: even the one method you do show is not OOPs.

Instead, create a a Circle class which holds the center and Radius, and start by find a way to get the mouse to create an instance (Hint: Look at the MouseDown and MouseUp events for your Form or Panel).
Then add code to the Paint event handler to draw them - to trigger a redraw, Invalidate the form / panel.

From there, the rest starts to fall into place pretty easily.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900