function Leadtools.Annotations.Automation.AnnAutomation.beginUndo()
Use BeginUndo, EndUndo and CancelUndo to programmatically add a node to the undo stack maintained by this AnnAutomation. Typically, you add an undo node as follows:
Call the BeginUndo method before you make any changes to create a new node.
Perform any changes to the AnnAutomation object.
Call the EndUndo method to commit this undo node into the undo stack of the AnnAutomation object.
In case of errors (typically in a catch statement), call the CancelUndo method to remove the node and cancel the operation.
You do not need to manually call BeginUndo, EndUndo or CancelUndo when calling methods from this AnnAutomation object. The AnnAutomation object will internally do this for you. For example, when you call the DeleteSelectedObjects method to delete the object(s) currently being edited, the AnnAutomation object will perform the above sequence internally to add the undo node.
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.
For information on undoing or redoing automation operations, refer to Undoing Annotation Automation Operations.
This example will manually add a new rectangle object to an automation object and then start editing it.
example: function SiteLibrary_DefaultPage$example() { var automation = this._automation; // first create a new undo node automation.beginUndo(); try { // add a new rectangle object var rectObj = new Leadtools.Annotations.Core.AnnRectangleObject(); rectObj.set_rect(Leadtools.LeadRectD.create(100, 100, 800, 800)); rectObj.set_stroke(Leadtools.Annotations.Core.AnnStroke.create( Leadtools.Annotations.Core.AnnSolidColorBrush.create("blue"), Leadtools.LeadLengthD.create(1))); rectObj.set_fill(Leadtools.Annotations.Core.AnnSolidColorBrush.create("yellow")); automation.get_container().get_children().add(rectObj); // Invalidate it automation.invalidate(Leadtools.LeadRectD.get_empty()); // Select this object automation.selectObject(rectObj); // commit the undo node automation.endUndo(); } catch (ex) { // in case of errors, cancel the undo node automation.cancelUndo(); alert(ex.message); return; } alert("Object has been added as is now selected. Next will call //Undo// to undo the operation"); automation.undo(); alert("Operation has been undone. Next will call //Redo// to redo the operation"); automation.redo(); alert("Object should be back and selected"); },