NanoByte.Common 2.10.6
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 (T target, string? path=null)
 Creates a new command manager. More...
 
void Execute (IUndoCommand command)
 Executes an IUndoCommand and stores it for later undo-operations. More...
 
void Undo ()
 Undoes the last action performed by ICommandExecutor.Execute. More...
 
void Redo ()
 Redoes the last action undone by Undo. More...
 
virtual void Save (string path)
 Saves the Target to an XML file More...
 

Static Public Member Functions

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

Protected Member Functions

void ClearUndo ()
 Clears the undo/redo stacks.
 

Properties

T? Target [getset]
 
string? Path [getset]
 The path of the file the Target was loaded from. null if none.
 
bool UndoEnabled [get]
 
bool RedoEnabled [get]
 
- Properties inherited from NanoByte.Common.Undo.ICommandManager< T >
T? Target [getset]
 The object being edited.
 
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.
 
- 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.
 

Events

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

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 ( target,
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

◆ Execute()

void NanoByte.Common.Undo.CommandManager< T >.Execute ( IUndoCommand  command)
inline

Executes an IUndoCommand and stores it for later undo-operations.

Implements NanoByte.Common.Undo.ICommandExecutor.

◆ For< T >()

static ICommandManager< T > NanoByte.Common.Undo.CommandManager< T >.For< T > ( target,
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 ( 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.

◆ Redo()

void NanoByte.Common.Undo.CommandManager< T >.Redo ( )
inline

Redoes the last action undone by Undo.

Implements NanoByte.Common.Undo.ICommandManager< T >.

◆ Save()

virtual void NanoByte.Common.Undo.CommandManager< T >.Save ( string  path)
inlinevirtual

Saves the Target to an XML file

Implements NanoByte.Common.Undo.ICommandManager< T >.

◆ Undo()

void NanoByte.Common.Undo.CommandManager< T >.Undo ( )
inline

Undoes the last action performed by ICommandExecutor.Execute.

Implements NanoByte.Common.Undo.ICommandManager< T >.


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