Beispiel #1
0
        public virtual void Remove()
        {
            timer.Stop();
            timer.Tick -= Update;

            rootcvs.Children.Remove(bpath);
            A.DisConnect();
            B.DisConnect();
            A = null;
            B = null;
        }
Beispiel #2
0
 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("端口类型不匹配");
     }
 }
Beispiel #3
0
        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;
        }