public void RemoveConnection() { if (connection != null) { connection.RemoveConnection(this); connection = null; FindForm().Controls.Remove(line); } }
private void OnDragDrop(object sender, DragEventArgs e) { if (connection != null) { RemoveConnection(); } Form form = FindForm(); connection = (OutLabel)e.Data.GetData(typeof(OutLabel)); connection.AddConnection(this); DragDot dh = connection.DragHandle; this.line = new ConnectionLine(); this.line.End = form.PointToClient(PointToScreen(DragHandle.Center)); this.line.Start = form.PointToClient(connection.PointToScreen(dh.Center)); form.Controls.Add(line); form.Invalidate(); }