示例#1
0
        public Port(string name, PortTypes portType, Type type, VplControl hostCanvas)
        {
            DataType = type;
            PortType = portType;
            Name     = name;

            this.hostCanvas = hostCanvas;

            if (portType == PortTypes.Input)
            {
                Style = this.hostCanvas.FindResource("VplPortStyleLeft") as Style;
            }
            else
            {
                Style = this.hostCanvas.FindResource("VplPortStyleRight") as Style;
            }

            MouseDown += Port_MouseDown;

            // ParentNode.SizeChanged += ParentNode_SizeChanged;
            // ParentNode.PropertyChanged += ParentNode_PropertyChanged;

            ConnectedConnectors = new List <Connector>();
            Origin = new BindingPoint(0, 0);
        }
示例#2
0
        public Connector(VplControl hostCanvas, Port startPort, Port endPort)
        {
            HostCanvas = hostCanvas;

            Path = new Path();

            StartEllipse = new ConnectorPort(hostCanvas);
            EndEllipse   = new ConnectorPort(hostCanvas);

            Panel.SetZIndex(Path, 2);

            if (startPort.ParentNode != null)
            {
                Panel.SetZIndex(StartEllipse, 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(StartEllipse, StartPort.Origin.X - StartEllipse.ActualWidth / 2);
            Canvas.SetTop(StartEllipse, StartPort.Origin.Y - StartEllipse.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;
        }