public mypoint dpoint(float x, float y) { mypoint p = new mypoint(); p.xcord = x; p.ycord = y; p.p_color = Color.Black; return(p); }
public void Form1_MouseClick(object sender, MouseEventArgs e) { void delete(mypoint p) { this.coordinates.Remove(p); this.Invalidate(); } if (e.Button == MouseButtons.Left) { mypoint p = dpoint(e.X, e.Y); this.coordinates.Add(p); this.Invalidate(); } if (e.Button == MouseButtons.Right) { float x = e.X; float y = e.Y; List <mypoint> temp = new List <mypoint>(); foreach (mypoint p in this.coordinates) { try { if (x > p.xcord - 20 && x < p.xcord + 20 && y > p.ycord - 20 && y < p.ycord + 20 && p.p_color == Color.Black) { p.p_color = Color.Red; } else if (x > p.xcord - 20 && x < p.xcord + 20 && y > p.ycord - 20 && y < p.ycord + 20 && p.p_color == Color.Red) { temp.Add(p); } } catch (System.InvalidOperationException) { temp.Add(p); } } foreach (mypoint p in temp) { this.coordinates.Remove(p); } } this.Invalidate(); }