Ejemplo n.º 1
0
 /// <summary>
 /// This is used in the Undo / Redo System
 /// </summary>
 /// <param name="n"></param>
 /// <param name="connection"></param>
 public void SetConnection(Node n, NodeConnection connection)
 {
     if (connection.index < n.Inputs.Count)
     {
         var inp = n.Inputs[connection.index];
         if (connection.outIndex >= 0 && connection.outIndex < Outputs.Count)
         {
             Outputs[connection.outIndex].InsertAt(connection.order, inp, false);
         }
     }
     else
     {
         //log to console the fact that we could not connect the node
         Log.Warn("Could not restore a node connections on: " + n.name);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// This is used in the Undo / Redo System
        /// </summary>
        /// <returns></returns>
        public List <NodeConnection> GetParentConnections()
        {
            List <NodeConnection> connections = new List <NodeConnection>();
            int i = 0;

            foreach (NodeInput n in Inputs)
            {
                if (n.HasInput)
                {
                    int idx = n.Input.Node.Outputs.IndexOf(n.Input);
                    if (idx > -1)
                    {
                        NodeOutput     no  = n.Input.Node.Outputs[idx];
                        int            ord = no.To.IndexOf(n);
                        NodeConnection nc  = new NodeConnection(n.Input.Node.Id, Id, idx, i, ord);
                        connections.Add(nc);
                    }
                }
                i++;
            }

            return(connections);
        }