Пример #1
0
        private void Connect(PortModel 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(Start) || p.Equals(End))
            {
                return;
            }

            //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;
            }

            //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
            End = p;

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

            return;
        }
Пример #2
0
        protected override void DeserializeCore(XmlElement element, SaveContext context)
        {
            XmlElementHelper helper = new XmlElementHelper(element);

            // Restore some information from the node attributes.
            this.GUID = helper.ReadGuid("guid", this.GUID);
            Guid     startNodeId = helper.ReadGuid("start");
            int      startIndex  = helper.ReadInteger("start_index");
            Guid     endNodeId   = helper.ReadGuid("end");
            int      endIndex    = helper.ReadInteger("end_index");
            PortType portType    = ((PortType)helper.ReadInteger("portType"));

            // Get to the start and end nodes that this connector connects to.
            NodeModel startNode = workspaceModel.GetModelInternal(startNodeId) as NodeModel;
            NodeModel endNode   = workspaceModel.GetModelInternal(endNodeId) as NodeModel;

            pStart = startNode.OutPorts[startIndex];
            PortModel endPort = null;

            if (portType == PortType.INPUT)
            {
                endPort = endNode.InPorts[endIndex];
            }

            pStart.Connect(this);
            this.Connect(endPort);
        }
Пример #3
0
        private ConnectorModel(WorkspaceModel workspaceModel, NodeModel start, NodeModel end, int startIndex, int endIndex, PortType portType)
        {
            this.workspaceModel = workspaceModel;

            pStart = start.OutPorts[startIndex];

            PortModel endPort = null;

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

            pStart.Connect(this);
            this.Connect(endPort);
        }
Пример #4
0
        private ConnectorModel(NodeModel start, NodeModel end, int startIndex, int endIndex, PortType portType)
        {
            //Stopwatch sw = new Stopwatch();
            //sw.Start();
            pStart = start.OutPorts[startIndex];

            PortModel endPort = null;

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

            pStart.Connect(this);
            this.Connect(endPort);
            //sw.Stop();
            //Debug.WriteLine(string.Format("{0} elapsed for constructing connector.", sw.Elapsed));
        }
Пример #5
0
        private ConnectorModel(WorkspaceModel workspaceModel, NodeModel start, NodeModel end, int startIndex, int endIndex, PortType portType)
        {
            this.workspaceModel = workspaceModel;

            pStart = start.OutPorts[startIndex];

            PortModel endPort = null;

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

            pStart.Connect(this);
            this.Connect(endPort);
        }
Пример #6
0
        private ConnectorModel(NodeModel start, NodeModel end, int startIndex, int endIndex, PortType portType)
        {
            //Stopwatch sw = new Stopwatch();
            //sw.Start();
            pStart = start.OutPorts[startIndex];

            PortModel endPort = null;

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

            pStart.Connect(this);
            this.Connect(endPort);
            //sw.Stop();
            //Debug.WriteLine(string.Format("{0} elapsed for constructing connector.", sw.Elapsed));
        }
Пример #7
0
        public bool Connect(PortModel 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;
        }
Пример #8
0
        protected override void DeserializeCore(XmlElement element, SaveContext context)
        {
            XmlElementHelper helper = new XmlElementHelper(element);

            // Restore some information from the node attributes.
            this.GUID = helper.ReadGuid("guid", this.GUID);
            Guid startNodeId = helper.ReadGuid("start");
            int startIndex = helper.ReadInteger("start_index");
            Guid endNodeId = helper.ReadGuid("end");
            int endIndex = helper.ReadInteger("end_index");
            PortType portType = ((PortType)helper.ReadInteger("portType"));

            // Get to the start and end nodes that this connector connects to.
            WorkspaceModel workspace = dynSettings.Controller.DynamoModel.CurrentWorkspace;
            NodeModel startNode = workspace.GetModelInternal(startNodeId) as NodeModel;
            NodeModel endNode = workspace.GetModelInternal(endNodeId) as NodeModel;

            pStart = startNode.OutPorts[startIndex];
            PortModel endPort = null;
            if (portType == PortType.INPUT)
                endPort = endNode.InPorts[endIndex];

            pStart.Connect(this);
            this.Connect(endPort);
        }