UndoEngine UndoEngine UndoEngine UndoEngine Class


Specifies generic undo/redo functionality at design time.

public ref class UndoEngine abstract : IDisposable
public abstract class UndoEngine : IDisposable
type UndoEngine = class
    interface IDisposable
Public MustInherit Class UndoEngine
Implements IDisposable


The UndoEngine abstract class provides a default implementation of undo functionality at design time. An undo unit represents a single unit of undoable work. This unit is added to a stack and the user can then walk the stack to undo each action. Undo units typically are designed to toggle, which means that calling undo twice returns the application to its starting state.

The UndoEngine class takes advantage of the following characteristics of objects running within the designer:

  • All interesting objects can be persisted to some format by the designer loader.

  • All objects raise property-change notifications when a property is changed.

  • IDesignerHost offers the idea of transactions, which can be used to fabricate an undo action that spans multiple smaller actions.

With these features, UndoEngine can fabricate any undo units it needs automatically.


Do not change property values directly. The UndoEngine class requires you to use the appropriate TypeDescriptor to change property values.

UndoEngine monitors for change notifications to create undo units, and the units themselves consist of serialized object states. The following table shows the services that must be available when UndoEngine is created.

Service Description
ComponentSerializationService Saves property and object values for a component before and after a change is made.
IComponentChangeService Notifies the undo engine of changes made to components.
IDesignerHost Used to track transactions.


Because the UndoEngine class requires ComponentSerializationService and IComponentChangeService, it is available only at design time.

The undo engine tracks transactions and creates a single undo unit that encompasses a transaction. As a result, the undo engine has control over the duration of an undoable action. Also, because transactions can be named, undoable actions inherit their names from the current transaction. If no transaction is available and a change is reported, the undo engine creates an undo name based on the type of change (for example, "Change property 'Text'").


UndoEngine(IServiceProvider) UndoEngine(IServiceProvider) UndoEngine(IServiceProvider) UndoEngine(IServiceProvider)

Initializes a new instance of the UndoEngine class.


Enabled Enabled Enabled Enabled

Enables or disables the UndoEngine.

UndoInProgress UndoInProgress UndoInProgress UndoInProgress

Indicates if an undo action is in progress.


AddUndoUnit(UndoEngine+UndoUnit) AddUndoUnit(UndoEngine+UndoUnit) AddUndoUnit(UndoEngine+UndoUnit) AddUndoUnit(UndoEngine+UndoUnit)

Adds an UndoEngine.UndoUnit to the undo stack.

CreateUndoUnit(String, Boolean) CreateUndoUnit(String, Boolean) CreateUndoUnit(String, Boolean) CreateUndoUnit(String, Boolean)

Creates a new UndoEngine.UndoUnit.

DiscardUndoUnit(UndoEngine+UndoUnit) DiscardUndoUnit(UndoEngine+UndoUnit) DiscardUndoUnit(UndoEngine+UndoUnit) DiscardUndoUnit(UndoEngine+UndoUnit)

Discards an UndoEngine.UndoUnit.

Dispose() Dispose() Dispose() Dispose()

Releases all resources used by the UndoEngine.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Releases the unmanaged resources used by the UndoEngine and optionally releases the managed resources.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetRequiredService(Type) GetRequiredService(Type) GetRequiredService(Type) GetRequiredService(Type)

Gets the requested service.

GetService(Type) GetService(Type) GetService(Type) GetService(Type)

Gets the requested service.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnUndoing(EventArgs) OnUndoing(EventArgs) OnUndoing(EventArgs) OnUndoing(EventArgs)

Raises the Undoing event.

OnUndone(EventArgs) OnUndone(EventArgs) OnUndone(EventArgs) OnUndone(EventArgs)

Raises the Undone event.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)


Undoing Undoing Undoing Undoing

Occurs immediately before an undo action is performed.

Undone Undone Undone Undone

Occurs immediately after an undo action is performed.

Applies to

See also