protected override void OnMouseDown(MouseEventArgs e) { //foreach(Control ctl in this.Controls) if (e.Button == MouseButtons.Left) { if (this.Tool == DrawingTools.Node) { AddNewNode(e.Location); } else if (this.Tool == DrawingTools.Edge || this.Tool == DrawingTools.Eraser) { int count = 0; foreach (var edge in _edges) { var start = this.Controls[edge.Start].Location; start.X += NODE_RADIUS; start.Y += NODE_RADIUS; var end = this.Controls[edge.End].Location; end.X += NODE_RADIUS; end.Y += NODE_RADIUS; if (Edge.Contains(start, end, e.Location)) { if (this.Tool == DrawingTools.Edge) { _edges.SelectedIndex = count; } else if (this.Tool == DrawingTools.Eraser) { _edges.RemoveAt(count); _edges.SelectedIndex = -1; } this.Invalidate(); break; } count++; } } else if (this.Tool == DrawingTools.Eraser) // delete edge { } } OnContentChanged(null, null); base.OnMouseDown(e); }