public virtual void Remove() { timer.Stop(); timer.Tick -= Update; rootcvs.Children.Remove(bpath); A.DisConnect(); B.DisConnect(); A = null; B = null; }
public override void EndDrag(ConnectClickPoint other) { if (other is ComCanvas o) { if (ConnectedConnector == null && o.ConnectedConnector == null) { ConnectedConnector = o.ConnectedConnector = new ComConnectorCanvas(this, o, globalGUIManager.rootcvs); } } else { globalGUIManager.TipText("端口类型不匹配"); } }
public ConnectorCanvas(ConnectClickPoint A, ConnectClickPoint B, Canvas rootcvs) { this.A = A; this.B = B; this.rootcvs = rootcvs; //画一条线 从A到B /* * line.X1 = A.X(); * line.Y1 = A.Y(); * line.X2 = B.X(); * line.Y2 = B.Y(); * line.Stroke = Brushes.LightSteelBlue; * line.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; * line.VerticalAlignment = System.Windows.VerticalAlignment.Top; * rootcvs.Children.Add(line); */ bpath = new Path() { Stroke = Brushes.Red, StrokeThickness = 1, Data = new PathGeometry() { Figures = new PathFigureCollection(new PathFigure[] { bfigureA = new PathFigure() { StartPoint = new Point(A.X(), A.Y()), Segments = new PathSegmentCollection(new PathSegment[] { polyBezierA }) }, bfigureB = new PathFigure() { StartPoint = new Point(A.X(), A.Y()), Segments = new PathSegmentCollection(new PathSegment[] { polyBezierB }) }, bfigureG = new PathFigure() { StartPoint = new Point(A.X(), A.Y()), Segments = new PathSegmentCollection(new PathSegment[] { polyBezierG }) } }) } }; SetupBezierLink(); rootcvs.Children.Add(bpath); timer.Tick += Update; timer.Interval = TimeSpan.FromMilliseconds(100); timer.Start(); bpath.MouseDown += MouseDown; bpath.Cursor = Cursors.No; }