NanoByte.Common
Public Member Functions | Static Public Member Functions | Protected Member Functions | Properties | Events | List of all members
NanoByte.Common.Undo.CommandManager< T > Class Template Reference

Executes IUndoCommands for editing a specific object and allows undo/redo operations. More...

Inheritance diagram for NanoByte.Common.Undo.CommandManager< T >:
NanoByte.Common.Undo.ICommandManager< T > NanoByte.Common.Undo.ICommandExecutor

Public Member Functions

 CommandManager ([NotNull] T target, [CanBeNull] string path=null)
 Creates a new command manager. More...
 
void Execute (IUndoCommand command)
 Executes an IUndoCommand and stores it for later undo-operations.
 
void Undo ()
 Undoes the last action performed by ICommandExecutor.Execute.
 
void Redo ()
 Redoes the last action undone by Undo.
 
virtual void Save (string path)
 Saves the Target to an XML file
 

Static Public Member Functions

static CommandManager< T > Load ([NotNull] string path)
 Loads an object from an XML file. More...
 
static ICommandManager< T > For< T > ([NotNull] T target, [CanBeNull] string path=null)
 Creates a new command manager. More...
 

Protected Member Functions

void ClearUndo ()
 Clears the undo/redo stacks. More...
 

Properties

Target [get, set]
 
string Path [get, set]
 The path of the file the Target was loaded from. null if none. More...
 
bool UndoEnabled [get]
 
bool RedoEnabled [get]
 
- Properties inherited from NanoByte.Common.Undo.ICommandManager< T >
Target [get, set]
 The object being edited. More...
 
bool UndoEnabled [get]
 Indicates whether there currently are operations that can be Undone. More...
 
bool RedoEnabled [get]
 Indicates whether there currently are operations that can be Redone. More...
 
- Properties inherited from NanoByte.Common.Undo.ICommandExecutor
string Path [get]
 The path of the file the data structure being modified was loaded from. null if none. More...
 

Events

Action TargetUpdated
 
Action UndoEnabledChanged
 
Action RedoEnabledChanged
 
- Events inherited from NanoByte.Common.Undo.ICommandManager< T >
Action TargetUpdated
 Is raised after Target has been updated. More...
 
Action UndoEnabledChanged
 Is raised when the value of UndoEnabled has changed. More...
 
Action RedoEnabledChanged
 Is raised when the value of RedoEnabled has changed. More...
 

Detailed Description

Executes IUndoCommands for editing a specific object and allows undo/redo operations.

Factory methods for ICommandManager<T>.

Template Parameters
TThe type of the object being edited.
Type Constraints
T :class 

Constructor & Destructor Documentation

◆ CommandManager()

NanoByte.Common.Undo.CommandManager< T >.CommandManager ( [NotNull] T  target,
[CanBeNull] string  path = null 
)
inline

Creates a new command manager.

Parameters
targetThe object being edited.
pathThe path of the file the target was loaded from. null if none.

Member Function Documentation

◆ ClearUndo()

void NanoByte.Common.Undo.CommandManager< T >.ClearUndo ( )
inlineprotected

Clears the undo/redo stacks.

◆ For< T >()

static ICommandManager<T> NanoByte.Common.Undo.CommandManager< T >.For< T > ( [NotNull] T  target,
[CanBeNull] string  path = null 
)
static

Creates a new command manager.

Parameters
targetThe object being edited.
pathThe path of the file the target was loaded from. null if none.
Type Constraints
T :class 
T :new 
T :CommandManager<T> 
T :target 
T :path 

◆ Load()

static CommandManager<T> NanoByte.Common.Undo.CommandManager< T >.Load ( [NotNull] string  path)
static

Loads an object from an XML file.

Parameters
pathThe file to load from.
Returns
An ICommandManager<T> containing the loaded object.
Exceptions
IOExceptionA problem occurs while reading the file.
UnauthorizedAccessExceptionRead access to the file is not permitted.
InvalidDataExceptionA problem occurs while deserializing the XML data.

Property Documentation

◆ Path

string NanoByte.Common.Undo.CommandManager< T >.Path
getset

The path of the file the Target was loaded from. null if none.


The documentation for this class was generated from the following file: