Exemple #1
0
        public void CloneNode(string id)
        {
            Node oldNode = GetNode(id);

            if (oldNode is PanelNode)
            {
                string json = NodesEngineSerializer.SerializePanel(id, this);

                List <Node> newNodes;
                List <Link> newLinks;
                NodesEngineSerializer.DeserializePanel(json, out newNodes, out newLinks);

                newNodes[0].Position = new Position {
                    X = oldNode.Position.X + 5, Y = oldNode.Position.Y + 20
                };

                GenerateNewIds(ref newNodes, ref newLinks);

                AddNodes(newNodes);
                AddLinks(newLinks);

                newNodes[0].ResetInputs();
            }
            else
            {
                string json    = NodesEngineSerializer.SerializeNode(oldNode);
                Node   newNode = NodesEngineSerializer.DeserializeNode(json);

                GenerateNewIds(newNode);

                newNode.Position = new Position {
                    X = oldNode.Position.X + 5, Y = oldNode.Position.Y + 20
                };
                AddNode(newNode, true);
                newNode.ResetInputs();
            }
        }
 public Node GetDeserializedNode()
 {
     return(NodesEngineSerializer.DeserializeNode(JsonData));
 }
 public SerializedNode(Node node)
 {
     Id       = node.Id;
     JsonData = NodesEngineSerializer.SerializeNode(node);
 }