Undoing Annotation Automation Operations

The LEADTOOLS annotation features include an Undo engine for undoing annotation automation operations. The undo depth determines the number of operations that can be undone.

LEADTOOLS provides a number of methods and properties for handling undo capabilities. Whenever an object inside the Container changes either by user interaction through the user interface or by code, the undo/redo buffer changes and the UndoRedoChanged event is fired.

Use the UndoCapacity property to get or set the number of user actions that can be reversed using the Undo method, or re-applied using the Redo method. The default for the UndoCapacity property is 10 actions.

Use the CanUndo and the CanRedo properties to determine whether you can undo or redo an operation. If the CanUndo property returns true you can call the Undo method to undo the last automation operation performed, including changes made to object properties. Likewise, if the CanRedo property returns true you can call the Redo method to redo the last automation operation performed, including changes made to object properties.

When you call a method directly from the AnnAutomation object, the AnnAutomation object internally adds a node to the undo stack it maintains. For example, when you call the DeleteSelectedObjects method to delete the object(s) currently being edited, the AnnAutomation object will internally add the undo node to the undo stack. You can programmatically add a node to the undo stack maintained by this AnnAutomation object by using the BeginUndo method along with the EndUndo method and the CancelUndo method. To do so, perform the following steps:

  1. Call the BeginUndo method before you make any changes to create a new node.
  2. Perform any changes to the AnnAutomation object.
  3. Call the EndUndo method to commit this undo node into the undo stack of the AnnAutomation object.
  4. In case of errors (typically in a catch statement), call the CancelUndo method to remove the node and cancel the operation. Generally, operations are undone one operation at a time. If the last operation performed cut several objects from a container, undoing that operation would return the objects to the container. Please note that Undo does not work for a Realize operation that has been performed using the AnnRedactObject.Realize method.
Help Version 20.0.2018.1.19
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Imaging, Medical, and Document