How to implement undo / redo of files displayed in tree view
3 answers
Consider the implementation of the Command Pattern (GoF):
- Place your action logic in classes that implement the generic ICommand {Do (); Undo ();}.
- In each custom action, you create the requested command object and initialize it with context parameters such as the new and old filename.
- Calling Do (), push the object onto the completed command stack.
- Each command is provided with a context, so by calling Undo () it can modify changes.
- Consider moving the files to a temporary folder instead of deleting them.
+7
source to share