←Select platform

BeginUndo Method

Summary
Creates a new undo node in this一个nnAutomationobject.
Syntax
C#
VB
Objective-C
C++
Java
publicvirtualvoidBeginUndo()
PublicOverridableSubBeginUndo()
-(void) beginUndo;
publicvoidbeginUndo()
public:virtualvoidBeginUndo()
Remarks

UseBeginUndo,EndUndoandCancelUndoto programmatically add a node to the undo stack maintained by this一个nnAutomation. Typically, you add an undo node as follows:

  1. Call theBeginUndomethod before you make any changes to create a new node.

  2. Perform any changes to the一个nnAutomationobject.

  3. Call theEndUndomethod to commit this undo node into the undo stack of the一个nnAutomationobject.

  4. In case of errors (typically in a catch statement), call theCancelUndomethod to remove the node and cancel the operation.

You do not need to manually callBeginUndo,EndUndoorCancelUndowhen calling methods from this一个nnAutomationobject. The一个nnAutomationobject will internally do this for you. For example, when you call theDeleteSelectedObjectsmethod to delete the object(s) currently being edited, the一个nnAutomationobject will perform the above sequence internally to add the undo node.

Use theUndoCapacityproperty to get or set the number of user actions that can be reversed using theUndomethod, or re-applied using theRedomethod. The default for theUndoCapacityproperty is 10 actions.

For information on undoing or redoing automation operations, refer toUndoing Annotation Automation Operations.

Example

This example will manually add a new rectangle object to an automation object and then start editing it.

C#
usingLeadtools.Annotations.Automation;usingLeadtools.Annotations.Engine;usingLeadtools.Codecs;usingLeadtools.Controls;usingLeadtools.Annotations.Rendering;usingLeadtools.Annotations.WinForms;publicvoid一个nnAutomation_BeginUndo(){// first create a new undo node_automation.BeginUndo();try{// add a new rectangle object一个nnRectangleObject rectObj =new一个nnRectangleObject();rectObj.Rect = LeadRectD.Create(100, 100, 800, 800);rectObj.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), LeadLengthD.Create(1));rectObj.Fill = AnnSolidColorBrush.Create("Yellow");_automation.Container.Children.Add(rectObj);// Invalidate it_automation.Invalidate(LeadRectD.Empty);// Select this object_automation.SelectObject(rectObj);// commit the undo node_automation.EndUndo();}catch(Exception ex){// in case of errors, cancel the undo node_automation.CancelUndo();Debug.WriteLine(ex.Message);return;}Debug.WriteLine("Object has been added as is now selected. Next will call //Undo// to undo the operation");_automation.Undo();Debug.WriteLine("Operation has been undone. Next will call //Redo// to redo the operation");_automation.Redo();Debug.WriteLine("Object should be back and selected");}
Requirements

Target Platforms

Leadtools.Annotations.Automation Assembly
188金宝搏的网址客服|Support|Contact Us|Intellectual Property Notices
© 1991-2021LEAD Technologies, Inc.一个ll Rights Reserved.