A SERVICE OF

logo

Chapter 7: Creating an Operation 151
iTool Developer’s Guide Operations and the Undo/Redo System
Generalized Operations
To provide undo/redo functionality, generalized operations (those based on the
IDLitOperation class) must provide methods that record the initial and final values of
the item being modified, along with methods that use the recorded values to undo or
redo the operation. The following things happen when the user requests an operation:
The DoAction method creates an IDLitCommandSet object to hold the initial
and final values.
The RecordInitialValues method records the original values of the specified
target objects. Values are stored as data items in IDLitCommand objects,
which are in turn stored in the IDLitCommandSet object.
The RecordFinalValues method retrieves the IDLitCommand objects created
by the RecordInitialValues method from the IDLitCommandSet object, and
records the new values of the target objects as additional items in those
IDLitCommand objects.
If the user undoes the operation, the UndoOperation method retrieves the
IDLitCommand objects from the IDLitCommandSet object, selects the
relevant data items from each, and restores the values.
If the user redoes the operation, the RedoOperation method retrieves the
IDLitCommand objects from the IDLitCommandSet object, selects the
relevant data items from each, and restores the values.