Esempio n. 1
0
        public bool Connect(dynPortModel p)
        {
            //test if the port that you are connecting too is not the start port or the end port
            //of the current connector
            if (p.Equals(pStart) || p.Equals(pEnd))
            {
                return(false);
            }

            //if the selected connector is also an output connector, return false
            //output ports can't be connected to eachother
            if (p.PortType == PortType.OUTPUT)
            {
                return(false);
            }

            //test if the port that you are connecting to is an input and
            //already has other connectors
            if (p.PortType == PortType.INPUT && p.Connectors.Count > 0)
            {
                p.Disconnect(p.Connectors[0]);
            }

            //turn the line solid
            pEnd = p;

            if (pEnd != null)
            {
                p.Connect(this);
            }

            return(true);
        }
Esempio n. 2
0
 public dynPortViewModel(dynPortModel port, dynNodeModel node)
 {
     _node = node;
     _port = port;
     _port.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_port_PropertyChanged);
     _node.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_node_PropertyChanged);
     ConnectCommand = new DelegateCommand(Connect, CanConnect);
     HighlightCommand = new DelegateCommand(Highlight, CanHighlight);
     UnHighlightCommand = new DelegateCommand(UnHighlight, CanUnHighlight);
 }
Esempio n. 3
0
 public dynPortViewModel(dynPortModel port, dynNodeModel node)
 {
     _node = node;
     _port = port;
     _port.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_port_PropertyChanged);
     _node.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_node_PropertyChanged);
     ConnectCommand         = new DelegateCommand(Connect, CanConnect);
     HighlightCommand       = new DelegateCommand(Highlight, CanHighlight);
     UnHighlightCommand     = new DelegateCommand(UnHighlight, CanUnHighlight);
 }
Esempio n. 4
0
 public dynPortViewModel(dynPortModel port, dynNodeModel node)
 {
     _node = node;
     _port = port;
     _port.PropertyChanged += _port_PropertyChanged;
     _node.PropertyChanged += _node_PropertyChanged;
     ConnectCommand         = new DelegateCommand(Connect, CanConnect);
     HighlightCommand       = new DelegateCommand(Highlight, CanHighlight);
     UnHighlightCommand     = new DelegateCommand(UnHighlight, CanUnHighlight);
 }
Esempio n. 5
0
        public void Disconnect(dynPortModel p)
        {
            if (p.Equals(pStart))
            {
                pStart = null;
            }

            if (p.Equals(pEnd))
            {
                pEnd = null;
            }

            p.Disconnect(this);
        }
Esempio n. 6
0
        private dynConnectorModel(dynNodeModel start, dynNodeModel end, int startIndex, int endIndex, int portType )
        {
            Stopwatch sw = new Stopwatch();
            sw.Start();
            pStart = start.OutPorts[startIndex];

            dynPortModel endPort = null;

            if (portType == 0)
                endPort = end.InPorts[endIndex];

            pStart.Connect(this);
            this.Connect(endPort);
            sw.Stop();
            Debug.WriteLine(string.Format("{0} elapsed for constructing connector.", sw.Elapsed));
        }
Esempio n. 7
0
        //construct a view and start drawing.
        public dynConnectorViewModel(dynPortModel port)
        {
            ConnectCommand = new DelegateCommand<object>(Connect, CanConnect);
            RedrawCommand = new DelegateCommand(Redraw, CanRedraw);
            HighlightCommand = new DelegateCommand(Highlight, CanHighlight);
            UnHighlightCommand = new DelegateCommand(Unhighlight, CanUnHighlight);

            var bc = new BrushConverter();
            StrokeBrush = (Brush)bc.ConvertFrom("#777");

            IsConnecting = true;
            _activeStartPort = port;

            // makes sure that all of the positions on the curve path are
            // set
            this.Redraw(port.Center);
        }
        //construct a view and start drawing.
        public dynConnectorViewModel(dynPortModel port)
        {
            ConnectCommand     = new DelegateCommand <object>(Connect, CanConnect);
            RedrawCommand      = new DelegateCommand(Redraw, CanRedraw);
            HighlightCommand   = new DelegateCommand(Highlight, CanHighlight);
            UnHighlightCommand = new DelegateCommand(Unhighlight, CanUnHighlight);

            var bc = new BrushConverter();

            StrokeBrush = (Brush)bc.ConvertFrom("#777");

            IsConnecting     = true;
            _activeStartPort = port;

            // makes sure that all of the positions on the curve path are
            // set
            this.Redraw(port.Center);
        }
Esempio n. 9
0
        private dynConnectorModel(dynNodeModel start, dynNodeModel end, int startIndex, int endIndex, int portType)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            pStart = start.OutPorts[startIndex];

            dynPortModel endPort = null;

            if (portType == 0)
            {
                endPort = end.InPorts[endIndex];
            }

            pStart.Connect(this);
            this.Connect(endPort);
            sw.Stop();
            Debug.WriteLine(string.Format("{0} elapsed for constructing connector.", sw.Elapsed));
        }
Esempio n. 10
0
        public dynConnectorModel(dynNodeModel start, dynNodeModel end, int startIndex, int endIndex, int portType, bool visible)
        {
            //don't try to create a connector with a bad start,
            //end, or if we're trying to connector the same
            //port to itself.
            if (start == null || end == null || start == end)
            {
                throw new Exception("Attempting to create connector with invalid start or end nodes.");
            }

            pStart = start.OutPorts[startIndex];

            dynPortModel endPort = null;

            if (portType == 0)
                endPort = end.InPorts[endIndex];

            pStart.Connect(this);
            this.Connect(endPort);
        }
Esempio n. 11
0
        public void Disconnect(dynPortModel p)
        {
            if (p.Equals(pStart))
            {
                pStart = null;
            }

            if (p.Equals(pEnd))
            {
                pEnd = null;
            }

            p.Disconnect(this);
        }
Esempio n. 12
0
        public bool Connect(dynPortModel p)
        {
            //test if the port that you are connecting too is not the start port or the end port
            //of the current connector
            if (p.Equals(pStart) || p.Equals(pEnd))
            {
                return false;
            }

            //if the selected connector is also an output connector, return false
            //output ports can't be connected to eachother
            if (p.PortType == PortType.OUTPUT)
            {
                return false;
            }

            //test if the port that you are connecting to is an input and
            //already has other connectors
            if (p.PortType == PortType.INPUT && p.Connectors.Count > 0)
            {
                return false;
            }

            //turn the line solid
            pEnd = p;

            if (pEnd != null)
            {
                //set the start and end values to equal so this
                //starts evaulating immediately
                //pEnd.Owner.InPortData[p.Index].Object = pStart.Owner.OutPortData.Object;
                p.Connect(this);

                Debug.WriteLine("Ports no longer call update....is it still working?");
                //pEnd.Update();
            }

            return true;
        }
Esempio n. 13
0
        /// <summary>
        /// Add a port to this node. If the port already exists, return that port.
        /// </summary>
        /// <param name="portType"></param>
        /// <param name="name"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public dynPortModel AddPort(PortType portType, string name, int index)
        {
            dynPortModel p;
            switch (portType)
            {
                case PortType.INPUT:
                    if (inPorts.Count > index)
                    {
                        p = inPorts[index];

                        //update the name on the node
                        //e.x. when the node is being re-registered during a custom
                        //node save
                        p.PortName = name;

                        return p;
                    }

                    p = new dynPortModel(index, portType, this, name);

                    InPorts.Add(p);

                    //register listeners on the port
                    p.PortConnected += new PortConnectedHandler(p_PortConnected);
                    p.PortDisconnected += new PortConnectedHandler(p_PortDisconnected);

                    return p;

                case PortType.OUTPUT:
                    if (outPorts.Count > index)
                    {
                        return outPorts[index];
                    }

                    p = new dynPortModel(index, portType, this, name);

                    OutPorts.Add(p);

                    //register listeners on the port
                    p.PortConnected += p_PortConnected;
                    p.PortDisconnected += p_PortDisconnected;

                    return p;
                default:
                    return null;
            }
        }
Esempio n. 14
0
 private void RemovePort(dynPortModel inport)
 {
     while (inport.Connectors.Any())
     {
         var connector = inport.Connectors[0];
         dynSettings.Controller.DynamoModel.CurrentSpace.Connectors.Remove(connector);
         connector.NotifyConnectedPortsOfDeletion();
     }
 }
Esempio n. 15
0
        public bool Connect(dynPortModel p)
        {
            //test if the port that you are connecting too is not the start port or the end port
            //of the current connector
            if (p.Equals(pStart) || p.Equals(pEnd))
            {
                return false;
            }

            //if the selected connector is also an output connector, return false
            //output ports can't be connected to eachother
            if (p.PortType == PortType.OUTPUT)
            {
                return false;
            }

            //test if the port that you are connecting to is an input and
            //already has other connectors
            if (p.PortType == PortType.INPUT && p.Connectors.Count > 0)
            {
                p.Disconnect(p.Connectors[0]);
            }

            //turn the line solid
            pEnd = p;

            if (pEnd != null)
            {
                p.Connect(this);
            }

            return true;
        }