Example #1
0
        private void AddConnectionFromXml(XMLConnection xmlConnection)
        {
            // Find node endpoints for the connection
            var        canvasModules = Children.OfType <CanvasModule>();
            RenderNode start         = null;
            RenderNode end           = null;

            foreach (var canvasModule in canvasModules)
            {
                if (canvasModule.TextBoxDisplayName.Text == xmlConnection.Output.ModuleName)
                {
                    start = canvasModule.OutputNodes.Where(t => t.Node.Identity == xmlConnection.Output.Identity).FirstOrDefault();
                }
                else if (canvasModule.TextBoxDisplayName.Text == xmlConnection.Input.ModuleName)
                {
                    end = canvasModule.InputNodes.Where(t => t.Node.Identity == xmlConnection.Input.Identity).FirstOrDefault();
                }

                if (start != null && end != null)
                {
                    break;
                }
            }

            if (start == null || end == null)
            {
                throw new XmlException("Cannot re-establish module connection:" +
                                       " one of the endpoints were not found");
            }

            // Finalize connection
            StartConnection(start);
            FinishConnection(end);
        }
Example #2
0
        internal static XMLConnection ReadXml(XmlReader reader)
        {
            reader.MoveToContent();
            reader.ReadStartElement(); // OutputNode
            XMLConnection.XMLNode output = ReadXmlNode(reader);
            XMLConnection.XMLNode input  = ReadXmlNode(reader);

            XMLConnection connection = new XMLConnection();

            connection.Output = output;
            connection.Input  = input;
            return(connection);
        }