Ejemplo n.º 1
0
        private void CreateNodeInternal(VisualNode node, double x, double y)
        {
            if (null == node)
                throw new ArgumentNullException("node");

            if (CoreComponent.Instance.StudioSettings.SuppressPreview)
                node.SetNodeState(States.PreviewHidden);

            node.X = x;
            node.Y = y;
            node.Compose(); // Just to compute the dimension.

            DeltaNodes deltaNodes = new DeltaNodes();
            deltaNodes.AppendToAddedNodes(node);

            if (node.VisualType != NodeType.CodeBlock)
            {
                bool visualOnlyNode = (node.VisualType == NodeType.Condensed ||
                    (node.VisualType == NodeType.Render));

                this.undoRedoRecorder.BeginGroup();
                this.undoRedoRecorder.RecordRuntimeStatesForUndo(this.graphProperties.RuntimeStates);
                this.undoRedoRecorder.RecordNodeCreationForUndo(deltaNodes.AddedNodes);
                this.graphProperties.RuntimeStates.AddVariablesDefinedInNode(node, false);

                if (false == visualOnlyNode)
                {
                    List<IVisualNode> modifiedNodes = new List<IVisualNode>();
                    EstablishImplicitConnections(modifiedNodes);
                    deltaNodes.AppendToModifiedNodes(modifiedNodes);
                }

                this.undoRedoRecorder.EndGroup();

                if (false == visualOnlyNode)
                    this.SynchronizeToLiveRunner(deltaNodes);
            }

            this.UpdateDirtyNodes();
            node.PositionAtCenter(node.NodeId);
        }