Inheritance: System.Windows.Controls.Control
Esempio n. 1
0
        public Connector(VplControl hostCanvas, Port startPort, Port endPort)
        {
            HostCanvas = hostCanvas;

            Path = new Path();

            srtEllipse = new ConnectorPort(hostCanvas);
            endEllipse = new ConnectorPort(hostCanvas);

            Panel.SetZIndex(Path, 2);

            if (startPort.ParentNode != null)
            {
                Panel.SetZIndex(srtEllipse, startPort.ParentNode.Id + 1);
            }

            if (endPort.ParentNode != null)
            {
                Panel.SetZIndex(endEllipse, endPort.ParentNode.Id + 1);
            }


            Path.Style = HostCanvas.FindResource("VplConnectorStyle") as Style;

            StartPort = startPort;
            EndPort = endPort;

            Canvas.SetLeft(srtEllipse, StartPort.Origin.X - srtEllipse.ActualWidth/2);
            Canvas.SetTop(srtEllipse, StartPort.Origin.Y - srtEllipse.ActualHeight/2);

            Canvas.SetLeft(endEllipse, EndPort.Origin.X - endEllipse.ActualWidth/2);
            Canvas.SetTop(endEllipse, EndPort.Origin.Y - endEllipse.ActualHeight/2);

            StartBezierPoint = new BindingPoint(StartPort.Origin.X, StartPort.Origin.Y);
            EndBezierPoint = new BindingPoint(EndPort.Origin.X, EndPort.Origin.Y);

            startPort.DataChanged += endPort.StartPort_DataChanged;

            StartPort.Origin.PropertyChanged += Origin_PropertyChanged;
            EndPort.Origin.PropertyChanged += Origin_PropertyChanged;

            if (startPort.ParentNode != null)
            {
                StartPort.ParentNode.PropertyChanged += Origin_PropertyChanged;
                ObserveNode(StartPort.ParentNode);
            }

            if (endPort.ParentNode != null)
            {
                EndPort.ParentNode.PropertyChanged += Origin_PropertyChanged;
                ObserveNode(EndPort.ParentNode);
            }


            startPort.ConnectedConnectors.Add(this);
            endPort.ConnectedConnectors.Add(this);

            endPort.CalculateData(startPort.Data);

            DefinePath();
            HostCanvas.Children.Add(Path);

            Path.MouseDown += Path_MouseDown;
            Path.MouseUp += PathOnMouseUp;
        }
Esempio n. 2
0
        public Connector(VplControl hostCanvas, Port startPort, Port endPort)
        {
            HostCanvas = hostCanvas;

            Path = new Path();

            srtEllipse = new ConnectorPort(hostCanvas);
            endEllipse = new ConnectorPort(hostCanvas);

            Panel.SetZIndex(Path, 2);

            if (startPort.ParentNode != null)
            {
                Panel.SetZIndex(srtEllipse, startPort.ParentNode.Id + 1);
            }

            if (endPort.ParentNode != null)
            {
                Panel.SetZIndex(endEllipse, endPort.ParentNode.Id + 1);
            }


            Path.Style = HostCanvas.FindResource("" +
                                                 "VplConnectorStyle" +
                                                 "") as Style;

            StartPort = startPort;
            EndPort   = endPort;

            Canvas.SetLeft(srtEllipse, StartPort.Origin.X - srtEllipse.ActualWidth / 2);
            Canvas.SetTop(srtEllipse, StartPort.Origin.Y - srtEllipse.ActualHeight / 2);

            Canvas.SetLeft(endEllipse, EndPort.Origin.X - endEllipse.ActualWidth / 2);
            Canvas.SetTop(endEllipse, EndPort.Origin.Y - endEllipse.ActualHeight / 2);

            StartBezierPoint = new BindingPoint(StartPort.Origin.X, StartPort.Origin.Y);
            EndBezierPoint   = new BindingPoint(EndPort.Origin.X, EndPort.Origin.Y);

            startPort.DataChanged += endPort.StartPort_DataChanged;

            StartPort.Origin.PropertyChanged += Origin_PropertyChanged;
            EndPort.Origin.PropertyChanged   += Origin_PropertyChanged;

            if (startPort.ParentNode != null)
            {
                StartPort.ParentNode.PropertyChanged += Origin_PropertyChanged;
                ObserveNode(StartPort.ParentNode);
            }

            if (endPort.ParentNode != null)
            {
                EndPort.ParentNode.PropertyChanged += Origin_PropertyChanged;
                ObserveNode(EndPort.ParentNode);
            }


            startPort.ConnectedConnectors.Add(this);
            endPort.ConnectedConnectors.Add(this);

            endPort.CalculateData(startPort.Data);

            DefinePath();
            HostCanvas.Children.Add(Path);

            Path.MouseDown += Path_MouseDown;
            Path.MouseUp   += PathOnMouseUp;
        }