Click here to Skip to main content
15,743,299 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
private Graphics grap;
private List<point> polygonP=new List<point>();
private void panel1_MouseDown(object sender, MouseEventArgs e)
           x1 = e.X;
           y1 = e.Y;
           polygonP.Add(new Point(e.X, e.Y));
private void panel1_MouseUp(object sender, MouseEventArgs e)
            Graphics grap = panel1.CreateGraphics();
            Pen mypen = new Pen(colour,linewidth);
             polygonP.Add(new Point(e.X,e.Y));
                        if (polygonP.Count > 2)  *****
                            grap.DrawLine(mypen, polygonP[polygonP.Count - 1], polygonP[0]);

Help me to think new if in line *****to end draw polygon if the last point == the first point.
Updated 15-May-11 7:03am
Olivier Levrey 16-May-11 4:08am    
Your question is not clear. Do you want to detect whether user clicked the first point or not to close the polygon?

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