Namespace NanoByte.Common.Undo
framework for adding undo/redo functionality to your applications, based on the Command pattern.
Commands
Commands that can be executed and also undone are represented using the IUndoCommand interface.
This library provides a number of implementations for common use cases such as SetValueCommand and AddToCollection, but you can also implement your own.
Executors
Methods that want to execute IUndoCommands should take an ICommandExecutor as an input parameter.
To execute an IUndoCommand, pass it to the ICommandExecutor.Execute() method. This will then internally call IUndoCommand.Execute() and record the command for later undo operations.
The class CommandManager<T> implements the ICommandExecutor interface. You can expose the .Undo() and .Redo() methods of this class to your users in your GUI.
API
Classes
- AddToCollection
Factory methods for AddToCollection<T>.
- AddToCollection<T>
An undo command that adds an element to a collection.
- CollectionCommand<T>
An undo command that adds or removes an element from a collection.
- CommandCollector
Executes IUndoCommands and collects them into a CompositeCommand allowing a combined undo later on.
- CommandManager
Factory methods for ICommandManager<T>.
- CommandManager<T>
Executes IUndoCommands for editing a specific object and allows undo/redo operations.
- CompositeCommand
Combines multiple IUndoCommands into a single atomic transaction.
- ConcurrentCommandExecutor
Decorator for ICommandExecutor that adds locking for thread-safety.
- FirstExecuteCommand
An undo command that does something different on the first call to Execute() than on subsequent redo calls.
- MultiPropertyChangedCommand
An undo command that handles multiple changed properties - usually used with a PropertyGrid.
- MultiPropertyTracker
Tracks values in PropertyGrids in order to be able to generate MultiPropertyChangedCommands after a property was changed.
- PreExecutedCommand
An undo command that does nothing on the first Execute() call, because the action was already performed beforehand
- PreExecutedCompositeCommand
Combines multiple already executed IUndoCommands into a single atomic transaction.
- PropertyChangedCommand
An undo command that handles a changed property - usually used with a PropertyGrid.
- RemoveFromCollection
Factory methods for RemoveFromCollection<T>.
- RemoveFromCollection<T>
An undo command that removes an element from a collection.
- ReplaceInList
Factory methods for ReplaceInList<T>.
- ReplaceInList<T>
An undo command that replaces an element in a list with a new one.
- SetInList
Factory methods for SetInList<T>.
- SetInList<T>
Replaces an entry in a IList<T> with a new one.
- SetLocalizableString
An undo command that sets a LocalizableString in a LocalizableStringCollection.
- SetValueCommand
Factory methods for SetValueCommand<T>.
- SetValueCommand<T>
An undo command that uses a delegates for getting and setting values from a backing model.
- SimpleCommand
An undo command that automatically tracks when Execute() and Undo() can be called.
- SimpleCommandExecutor
Executes IUndoCommands without any additional handling.
Interfaces
- ICommandExecutor
Executes IUndoCommands.
- ICommandManager<T>
Executes IUndoCommands for editing a specific object and allows undo/redo operations.
- IUndoCommand
A executable command with an undo function.
- IValueCommand
A command that exposes the value it will set.