Creates a new undo node in this AnnAutomation object.
public virtual void BeginUndo()
Public Overridable Sub BeginUndo()
public:
virtual void BeginUndo();
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:
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 WPF Automation Operations.
This example will manually add a new rectangle object to an automation object and then start editing it.
Imports Leadtools.Windows.Controls
Imports Leadtools.Windows.Annotations
Private 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.Rect = New Rect(100, 100, 200, 200)
rectObj.Stroke = Colors.Blue
rectObj.StrokeThickness = 2.0
rectObj.Fill = Colors.Yellow
automation.Container.Children.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.Windows.Controls;
using Leadtools.Windows.Annotations;
using Leadtools.Demos;
using Leadtools.Help;
private void AnnAutomation_BeginUndo(AnnAutomation automation)
{
// first create a new undo node
automation.BeginUndo();
try
{
// add a new rectangle object
AnnRectangleObject rectObj = new AnnRectangleObject();
rectObj.Rect = new Rect(100, 100, 200, 200);
rectObj.Stroke = Colors.Blue;
rectObj.Fill = Colors.Yellow;
rectObj.StrokeThickness = 2.0;
automation.Container.Children.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");
}
using Leadtools.Windows.Controls;
using Leadtools.Windows.Annotations;
using Leadtools.Examples;
using Leadtools.Silverlight.Demos;
private void AnnAutomation_BeginUndo(AnnAutomation automation)
{
// first create a new undo node
automation.BeginUndo();
try
{
// add a new rectangle object
AnnRectangleObject rectObj = new AnnRectangleObject();
rectObj.Rect = new Rect(100, 100, 200, 200);
rectObj.Stroke = Colors.Blue;
rectObj.Fill = Colors.Yellow;
rectObj.StrokeThickness = 2.0;
automation.Container.Children.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");
}
Imports Leadtools.Windows.Controls
Imports Leadtools.Windows.Annotations
Imports Leadtools.Silverlight.Demos
Private 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.Rect = New Rect(100, 100, 200, 200)
rectObj.Stroke = Colors.Blue
rectObj.Fill = Colors.Yellow
rectObj.StrokeThickness = 2.0
automation.Container.Children.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
Products |
Support |
Feedback: BeginUndo Method - Leadtools.Windows.Annotations |
Introduction |
Help Version 19.0.2017.3.22
|
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.