private void DeleteNode(object obj) { ucGraphNode o = (ucGraphNode)obj; Lines.RemoveAll(x => x.start.Parent == o || x.end.Parent == o); //контрол это узлы куда мы привязываем нам нужен сама вся нода Nodes.Remove(o); o.Dispose(); }
public ucGraphNode CreateNode(int x, int y, Type t) { ucGraphNode uc = new ucGraphNode(t); uc.Location = new Point(x, y); uc.Parent = this; uc.InitConnect += NodeInitConnect; uc.Moving += NodeMoving; uc.MethodChanging += NodeChangeMethod; uc.Delete += DeleteNode; return(uc); }
private void NodeMoving(object obj, Point innrerPoint) { ucGraphNode node = obj as ucGraphNode; Point needPosition = node.Parent.PointToClient(MousePosition); node.Location = new Point(needPosition.X - innrerPoint.X, needPosition.Y - innrerPoint.Y); if (node.Location.X < 0) { node.Location = new Point(0, node.Location.Y); } if (node.Location.Y < 0) { node.Location = new Point(node.Location.X, 0); } if (node.Bounds.Right + 80 > this.Width) { this.Width = node.Bounds.Right + 80; } if (node.Bounds.Bottom + 80 > this.Height) { this.Height = node.Bounds.Bottom + 80; } Invalidate(); }