/// <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);
}