Table of Contents

Class UndoRedoActionChooser

Namespace
ExControls
Assembly
ExControls.dll

List of Undo/Redo actions like the drop-down of the Undo button in Visual Studio or Office: moving the mouse selects the actions up to the one under the cursor, a click chooses them (FinalCommand, CommandChosen). The line under the list shows the number of selected actions (CountText).

[ToolboxBitmap(typeof(ToolboxIcons), "Toolbox.UndoRedoActionChooser.ico")]
public class UndoRedoActionChooser : UserControl, IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, IComponent, IDisposable, IContainerControl, IThemeable
Inheritance
UndoRedoActionChooser
Implements
Inherited Members
Extension Methods

Remarks

Fill the list with SetCommands(IEnumerable<IUndoRedoCommand>) before it is shown, the newest action first (as GetUndoHistory() returns them), and pass FinalCommand to Undo(IUndoRedoCommand), which undoes all actions up to and including it. ToolStripUndoRedoActionChooser shows the list as a drop-down of a tool strip button.

Constructors

UndoRedoActionChooser()

Initializes a new instance of the UndoRedoActionChooser class.

public UndoRedoActionChooser()

Properties

CountText

Gets or sets the text under the list for the number of selected actions, for example count => $"Undo {count} actions". The library has no UI texts of its own language, the default is "1 action" or "{count} actions".

[Browsable(false)]
public Func<int, string> CountText { get; set; }

Property Value

Func<int, string>

FinalCommand

The last chosen action - the actions from the first one up to it are to be undone or redone; null until the user chooses an action.

[Browsable(false)]
public IUndoRedoCommand? FinalCommand { get; }

Property Value

IUndoRedoCommand

Methods

ApplyTheme(ExTheme)

Sets the colors and appearance of the control by the theme.

public void ApplyTheme(ExTheme theme)

Parameters

theme ExTheme

Dispose(bool)

Clean up any resources being used.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true if managed resources should be disposed; otherwise, false.

OnCommandChosen(EventArgs)

Raises the CommandChosen event.

protected virtual void OnCommandChosen(EventArgs e)

Parameters

e EventArgs

data of the event

OnShown()

Clears the chosen action and selects the first one; call it whenever the list is shown (ToolStripUndoRedoActionChooser does it when it opens).

public void OnShown()

SetCommands(IEnumerable<IUndoRedoCommand>)

Replaces the actions in the list, the newest first, and selects the first one.

public void SetCommands(IEnumerable<IUndoRedoCommand> commands)

Parameters

commands IEnumerable<IUndoRedoCommand>

actions to show, for example GetUndoHistory()

Events

CommandChosen

Occurs when the user chooses an action with a click; FinalCommand is the chosen action.

public event EventHandler? CommandChosen

Event Type

EventHandler