Dynamo.Graph.Workspaces.WorkspaceModel.RecordModelsForModification C# (CSharp) Method

RecordModelsForModification() public method

Implement recording node modification for undo/redo.
public RecordModelsForModification ( IEnumerable models ) : void
models IEnumerable Collection of objects to record.
return void
        public void RecordModelsForModification(IEnumerable<ModelBase> models)
        {
            RecordModelsForModification(models.ToList(), undoRecorder);
        }

Same methods

WorkspaceModel::RecordModelsForModification ( List models, Dynamo.Core.UndoRedoRecorder recorder ) : void

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// This method adds relevant models to the undo recorder.
        /// </summary>
        /// <param name="workspace">A <see cref="WorkspaceModel"/>.</param>
        /// <param name="isGroupLayout">True if all the selected models are groups.</param>
        private static void RecordUndoGraphLayout(this WorkspaceModel workspace, bool isGroupLayout)
        {
            List <ModelBase> undoItems = new List <ModelBase>();

            if (!isGroupLayout)
            {
                // Add all selected items to the undo recorder
                undoItems.AddRange(workspace.Nodes);
                undoItems.AddRange(workspace.Notes);
                if (DynamoSelection.Instance.Selection.Count > 0)
                {
                    undoItems = undoItems.Where(x => x.IsSelected).ToList();
                }
            }
            else
            {
                // Add all models inside selected groups
                foreach (var group in workspace.Annotations)
                {
                    if (group.IsSelected)
                    {
                        group.Nodes.OfType <NodeModel>().ToList().ForEach(x => x.IsSelected = false);
                        undoItems.AddRange(group.Nodes);
                    }
                }
            }

            WorkspaceModel.RecordModelsForModification(undoItems, workspace.UndoRecorder);
        }
WorkspaceModel