Example #1
0
        /// <summary>
        ///     Deletes all the connections and saves their data (the start and end port)
        ///     so that they can be recreated if needed.
        /// </summary>
        /// <param name="inportConnections">A list of connections that will be destroyed</param>
        /// <param name="outportConnections"></param>
        private void SaveAndDeleteConnectors(IDictionary inportConnections, IDictionary outportConnections)
        {
            //----------------------------Inputs---------------------------------
            foreach (var portModel in InPorts)
            {
                var portName = portModel.ToolTipContent;
                if (portModel.Connectors.Count != 0)
                {
                    inportConnections.Add(portName, new List <PortModel>());
                    foreach (var connector in portModel.Connectors)
                    {
                        (inportConnections[portName] as List <PortModel>).Add(connector.Start);
                    }
                }
                else
                {
                    inportConnections.Add(portName, null);
                }
            }

            //Delete the connectors
            foreach (PortModel inport in InPorts)
            {
                inport.DestroyConnectors();
            }

            //Clear out all the port models
            for (int i = InPorts.Count - 1; i >= 0; i--)
            {
                InPorts.RemoveAt(i);
            }


            //----------------------------Outputs---------------------------------
            for (int i = 0; i < OutPorts.Count; i++)
            {
                PortModel portModel = OutPorts[i];
                string    portName  = portModel.ToolTipContent;
                if (portModel.ToolTipContent.Equals(Formatting.TOOL_TIP_FOR_TEMP_VARIABLE))
                {
                    portName += i.ToString(CultureInfo.InvariantCulture);
                }
                if (portModel.Connectors.Count != 0)
                {
                    outportConnections.Add(portName, new List <PortModel>());
                    foreach (ConnectorModel connector in portModel.Connectors)
                    {
                        (outportConnections[portName] as List <PortModel>).Add(connector.End);
                    }
                }
                else
                {
                    outportConnections.Add(portName, null);
                }
            }

            //Delete the connectors
            foreach (PortModel outport in OutPorts)
            {
                outport.DestroyConnectors();
            }

            //Clear out all the port models
            for (int i = OutPorts.Count - 1; i >= 0; i--)
            {
                OutPorts.RemoveAt(i);
            }
        }
Example #2
0
        /// <summary>
        ///     Deletes all the connections and saves their data (the start and end port)
        ///     so that they can be recreated if needed.
        /// </summary>
        /// <param name="portConnections">A list of connections that will be destroyed</param>
        private void SaveAndDeleteConnectors(OrderedDictionary inportConnections, OrderedDictionary outportConnections)
        {
            //----------------------------Inputs---------------------------------
            for (int i = 0; i < InPorts.Count; i++)
            {
                PortModel portModel = InPorts[i];
                string    portName  = portModel.ToolTipContent;
                if (portModel.Connectors.Count != 0)
                {
                    inportConnections.Add(portName, new List <PortModel>());
                    foreach (ConnectorModel connector in portModel.Connectors)
                    {
                        (inportConnections[portName] as List <PortModel>).Add(connector.Start);
                        Workspace.UndoRecorder.RecordDeletionForUndo(connector);
                    }
                }
                else
                {
                    inportConnections.Add(portName, null);
                }
            }

            //Delete the connectors
            foreach (PortModel inport in InPorts)
            {
                inport.DestroyConnectors();
            }

            //Clear out all the port models
            for (int i = InPorts.Count - 1; i >= 0; i--)
            {
                InPorts.RemoveAt(i);
            }


            //----------------------------Outputs---------------------------------
            for (int i = 0; i < OutPorts.Count; i++)
            {
                PortModel portModel = OutPorts[i];
                string    portName  = portModel.ToolTipContent;
                if (portModel.ToolTipContent.Equals(Formatting.ToolTipForTempVariable))
                {
                    portName += i.ToString(CultureInfo.InvariantCulture);
                }
                if (portModel.Connectors.Count != 0)
                {
                    outportConnections.Add(portName, new List <PortModel>());
                    foreach (ConnectorModel connector in portModel.Connectors)
                    {
                        (outportConnections[portName] as List <PortModel>).Add(connector.End);
                        Workspace.UndoRecorder.RecordDeletionForUndo(connector);
                    }
                }
                else
                {
                    outportConnections.Add(portName, null);
                }
            }

            //Delete the connectors
            foreach (PortModel outport in OutPorts)
            {
                outport.DestroyConnectors();
            }

            //Clear out all the port models
            for (int i = OutPorts.Count - 1; i >= 0; i--)
            {
                OutPorts.RemoveAt(i);
            }
        }