Skip to content
Robert B Colton edited this page Aug 12, 2016 · 1 revision

Screenshot

Provides a framework for adding undo/redo support to your application. An undo/redo stack is maintained separately for each document. The screenshot above shows the history tool window. You can drag the slider to move forward or backward in the document's history.

Provides

  • IHistoryTool tool window
  • IUndoableAction interface
  • UndoRedoToolbarItems utility class

NuGet package

Dependencies

  • None

Usage

First, define an action. The action needs to implement IUndoableAction:

public class MyAction : IUndoableAction
{
    public string Name
    {
        get { return "My Action"; }
    }

    public void Execute()
    {
        // Do something
    }

    public void Undo()
    {
        // Put it back
    }
}

Then execute the action:

var undoRedoManager = IoC.Get<IShell>().ActiveItem.UndoRedoManager;
undoRedoManager.ExecuteAction(new MyAction());

Now the action will be shown in the history tool window. If you are using the Undo or Redo menu items or toolbar buttons, they will also react appropriately to the action.

Clone this wiki locally