Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public Port(string name, Node parent, PortTypes portType, Type type)
        {
            ParentNode  = parent;
            hostCanvas  = ParentNode.HostCanvas;
            DataType    = type;
            PortType    = portType;
            Name        = name;
            Description = name;

            if (portType == PortTypes.Input)
            {
                Style = hostCanvas.FindResource("VplPortStyleLeft") as Style;
            }
            else
            {
                Style = 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);
        }
Ejemplo n.º 3
0
        public Connector(VplControl hostCanvas, Port startPort, Port endPort)
        {
            HostCanvas = hostCanvas;

            Path = new Path();

            srtEllipse = new Ellipse
            {
                Style = hostCanvas.FindResource("VplEllipseConnStyle") as Style
            };

            endEllipse = new Ellipse
            {
                Style = hostCanvas.FindResource("VplEllipseConnStyle") as Style
            };

            Panel.SetZIndex(Path, 2);
            Panel.SetZIndex(srtEllipse, startPort.ParentNode.Id + 1);
            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;

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

            ObserveNode(StartPort.ParentNode);
            ObserveNode(EndPort.ParentNode);

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

            endPort.CalculateData(startPort.Data);

            DefinePath();

            HostCanvas.Children.Add(Path);
            HostCanvas.Children.Add(srtEllipse);
            HostCanvas.Children.Add(endEllipse);
        }
Ejemplo n.º 4
0
        public Connector(VplControl hostCanvas, Port startPort, Port endPort)
        {
            HostCanvas = hostCanvas;

            Path = new Path();

            srtEllipse = new Ellipse
            {
                Style = hostCanvas.FindResource("VplEllipseConnStyle") as Style
            };

            endEllipse = new Ellipse
            {
                Style = hostCanvas.FindResource("VplEllipseConnStyle") as Style
            };

            Panel.SetZIndex(Path, 2);
            Panel.SetZIndex(srtEllipse, startPort.ParentNode.Id + 1);
            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;

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

            ObserveNode(StartPort.ParentNode);
            ObserveNode(EndPort.ParentNode);

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

            endPort.CalculateData(startPort.Data);

            DefinePath();

            HostCanvas.Children.Add(Path);
            HostCanvas.Children.Add(srtEllipse);
            HostCanvas.Children.Add(endEllipse);
        }
Ejemplo n.º 5
0
        public Port(string name, Node parent, PortTypes portType, Type type)
        {
            ParentNode = parent;

            DataType = type;
            PortType = portType;
            Name = name;

            if (portType == PortTypes.Input)
                Style = ParentNode.HostCanvas.FindResource("VplPortStyleLeft") as Style;
            else
                Style = ParentNode.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);
        }