LEADTOOLS Annotations (Leadtools.Annotations assembly)

BeginUndo Method

Show in webframe
Example 





Creates a new undo node in this AnnAutomation object.
Syntax
public virtual void BeginUndo()
'Declaration
 
Public Overridable Sub BeginUndo() 
'Usage
 
Dim instance As AnnAutomation
 
instance.BeginUndo()

            

            
public:
virtual void BeginUndo(); 
Remarks

Use this method along with the EndUndo and CancelUndo methods to programmatically add a node to the undo stack maintained by this AnnAutomation. Typically, you add an undo node as follows:

  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.

You do not need to manually call the BeginUndo, EndUndo or CancelUndo methods when calling methods from this AnnAutomation object directly. The AnnAutomation object will internally do this for you. For example, when you call the Delete 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 more information, refer to Undoing Automation Operations.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Annotations
Imports Leadtools.WinForms
Imports Leadtools.Drawing

Public Sub AnnAutomation_BeginUndo(ByVal automation As AnnAutomation)
   ' first create a new undo node
   automation.BeginUndo()
   Try
      ' add a new rectangle object
      Dim rectObj As AnnRectangleObject = New AnnRectangleObject()
      rectObj.Bounds = New AnnRectangle(100, 100, 200, 200, AnnUnit.Pixel)
      rectObj.Pen = New AnnPen(Color.Blue, New AnnLength(1, AnnUnit.Pixel))
      rectObj.Brush = New AnnSolidBrush(Color.Yellow)
      automation.Container.Objects.Add(rectObj)

      ' "select" this object
      automation.StartEditing(rectObj, False)

      ' commit the undo node
      automation.EndUndo()
   Catch ex As Exception
      ' in case of errors, cancel the undo node
      automation.CancelUndo()
      Throw ex
   End Try

   MessageBox.Show("Object has been added as is now selected.  Next will call //Undo// to undo the operation")
   automation.Undo()
   MessageBox.Show("Operation has been undone.  Next will call //Redo// to redo the operation")
   automation.Redo()
   MessageBox.Show("Object should be back and selected")
End Sub
using Leadtools;
using Leadtools.Annotations;
using Leadtools.WinForms;
using Leadtools.Drawing;

public void AnnAutomation_BeginUndo(AnnAutomation automation)
{
   // first create a new undo node
   automation.BeginUndo();
   try
   {
      // add a new rectangle object
      AnnRectangleObject rectObj = new AnnRectangleObject();
      rectObj.Bounds = new AnnRectangle(100, 100, 200, 200, AnnUnit.Pixel);
      rectObj.Pen = new AnnPen(Color.Blue, new AnnLength(1, AnnUnit.Pixel));
      rectObj.Brush = new AnnSolidBrush(Color.Yellow);
      automation.Container.Objects.Add(rectObj);

      // "select" this object
      automation.StartEditing(rectObj, false);

      // commit the undo node
      automation.EndUndo();
   }
   catch(Exception ex)
   {
      // in case of errors, cancel the undo node
      automation.CancelUndo();
      throw ex;
   }

   MessageBox.Show("Object has been added as is now selected.  Next will call //Undo// to undo the operation");
   automation.Undo();
   MessageBox.Show("Operation has been undone.  Next will call //Redo// to redo the operation");
   automation.Redo();
   MessageBox.Show("Object should be back and selected");
}
Requirements

Target Platforms

See Also

Reference

AnnAutomation Class
AnnAutomation Members

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.