Table of Contents

Class BackwardForwardProvider

Namespace
ExControls.Providers
Assembly
ExControls.dll

Provides backward-forward capability.

[ToolboxBitmap(typeof(ToolboxIcons), "Toolbox.BackwardForwardProvider.ico")]
public class BackwardForwardProvider : Component, IComponent, IDisposable
Inheritance
BackwardForwardProvider
Implements
Inherited Members

Constructors

BackwardForwardProvider()

Initializes a new instance of the BackwardForwardProvider class with an empty history; commands are added only after ManagerEnabled is turned on.

public BackwardForwardProvider()

Properties

CanBackward

Check if there is something to undo. Use this method to decide whether your application's "Back" menu item should be enabled or disabled.

[Browsable(false)]
public bool CanBackward { get; }

Property Value

bool

CanForward

Check if there is something to redo. Use this method to decide whether your application's "Forward" menu item should be enabled or disabled.

[Browsable(false)]
public bool CanForward { get; }

Property Value

bool

CurrentCommand

Gets the current command - the last added one or the one the history moved to; null before the first command is added.

[Browsable(false)]
public IBackwardForwardCommand? CurrentCommand { get; protected set; }

Property Value

IBackwardForwardCommand

ManagerEnabled

Enables or disables manager to add commands to stacks. Default is false.

public bool ManagerEnabled { get; set; }

Property Value

bool

NextBackwardCommand

Get the next (or newest) undo command. This is like a "Peek" method. It does not remove the command from the undo list.

[Browsable(false)]
public IBackwardForwardCommand NextBackwardCommand { get; }

Property Value

IBackwardForwardCommand

NextForwardCommand

Get the next redo command. This is like a "Peek" method. It does not remove the command from the redo stack.

[Browsable(false)]
public IBackwardForwardCommand NextForwardCommand { get; }

Property Value

IBackwardForwardCommand

Methods

AddCommand(IBackwardForwardCommand)

Register a new back action command. Use this method after your application has performed an operation/command that is undoable.

public void AddCommand(IBackwardForwardCommand cmd)

Parameters

cmd IBackwardForwardCommand

command to add to the history

Backward()

Moves one step back: the previous command becomes the current one and is asked to perform the move.

public void Backward()

Exceptions

InvalidOperationException

when the manager is disabled, the backward history is empty or there is no current command.

Backward(IBackwardForwardCommand)

Moves back to finalCmd: it becomes the current command and is asked to perform the move, the skipped commands go to the forward history.

public void Backward(IBackwardForwardCommand finalCmd)

Parameters

finalCmd IBackwardForwardCommand

command in the backward history to move back to

Exceptions

InvalidOperationException

when the manager is disabled, the backward history is empty or there is no current command.

ArgumentNullException

when finalCmd is null.

ArgumentException

when finalCmd is the current command or is not in the backward history.

Clear()

Clear the internal back/forward data structures. Use this method when your application performs an operation that cannot be undone. For example, when the user "saves" or "commits" all the changes in the application, or when a form is closed.

public void Clear()

Forward()

Moves one step forward: the next command becomes the current one and is asked to perform the move.

public void Forward()

Exceptions

InvalidOperationException

when the manager is disabled, the forward history is empty or there is no current command.

Forward(IBackwardForwardCommand)

Moves forward to finalCmd: it becomes the current command and is asked to perform the move, the skipped commands go to the backward history.

public void Forward(IBackwardForwardCommand finalCmd)

Parameters

finalCmd IBackwardForwardCommand

command in the forward history to move forward to

Exceptions

InvalidOperationException

when the manager is disabled, the forward history is empty or there is no current command.

ArgumentNullException

when finalCmd is null.

ArgumentException

when finalCmd is the current command or is not in the forward history.

GetBackwardHistory()

Returns the history of commands to which the provider can move backward.

public IEnumerable<IBackwardForwardCommand> GetBackwardHistory()

Returns

IEnumerable<IBackwardForwardCommand>

The backward commands, the nearest one first.

GetBackwardText()

Get the text value of the next back command. Use this method to update the Text property of your "Back" menu item if desired. For example, the text value for a command might be "Draw Circle".

public string GetBackwardText()

Returns

string

GetForwardHistory()

Returns the history of commands to which the provider can move forward.

public IEnumerable<IBackwardForwardCommand> GetForwardHistory()

Returns

IEnumerable<IBackwardForwardCommand>

The forward commands, the nearest one first.

GetForwardText()

Get the text value of the next forward command. Use this method to update the Text property of your "Forward" menu item if desired. For example, the text value for a command might be "Draw Line".

public string GetForwardText()

Returns

string

OnBackwardForwardStateChanged(UndoRedoStateEventArgs)

Raises the BackwardForwardStateChanged event.

protected virtual void OnBackwardForwardStateChanged(UndoRedoStateEventArgs e)

Parameters

e UndoRedoStateEventArgs

The event data.

OnCommandAdded(BackwardForwardAddedCommandEventArgs)

Raises the CommandAdded event.

protected virtual void OnCommandAdded(BackwardForwardAddedCommandEventArgs e)

Parameters

e BackwardForwardAddedCommandEventArgs

The event data.

Events

BackwardForwardStateChanged

Occurs when the provider moved backward or forward in the history, or when the history was cleared.

public event EventHandler<UndoRedoStateEventArgs>? BackwardForwardStateChanged

Event Type

EventHandler<UndoRedoStateEventArgs>

CommandAdded

Occurs when a new command was added and became the current command.

public event EventHandler<BackwardForwardAddedCommandEventArgs>? CommandAdded

Event Type

EventHandler<BackwardForwardAddedCommandEventArgs>