internal static void RecordModelsForUndo(Dictionary<ModelBase, UndoRedoRecorder.UserAction> models, UndoRedoRecorder recorder) { if (null == recorder) return; if (!ShouldProceedWithRecording(models)) return; using (recorder.BeginActionGroup()) { foreach (var modelPair in models) { switch (modelPair.Value) { case UndoRedoRecorder.UserAction.Creation: recorder.RecordCreationForUndo(modelPair.Key); break; case UndoRedoRecorder.UserAction.Deletion: recorder.RecordDeletionForUndo(modelPair.Key); break; case UndoRedoRecorder.UserAction.Modification: recorder.RecordModificationForUndo(modelPair.Key); break; } } } }
/// <summary> /// TODO(Ben): This method is exposed this way for external codes (e.g. /// the DragCanvas) to record models before they are modified. This is /// by no means ideal. The ideal case of course is for ALL codes that /// end up modifying models to be folded back into WorkspaceViewModel in /// the form of commands. These commands then internally record those /// affected models before updating them. We need this method to be gone /// sooner than later. /// </summary> /// <param name="models">The models to be recorded for undo.</param> /// <param name="recorder"></param> internal static void RecordModelsForModification(List<ModelBase> models, UndoRedoRecorder recorder) { if (null == recorder) return; if (!ShouldProceedWithRecording(models)) return; using (recorder.BeginActionGroup()) { foreach (var model in models) recorder.RecordModificationForUndo(model); } }