Leadtools.Windows.Annotations Namespace > AnnAutomation Class : BeginUndo Method |
public virtual void BeginUndo()
'Declaration Public Overridable Sub BeginUndo()
'Usage Dim instance As AnnAutomation instance.BeginUndo()
public virtual void BeginUndo()
function Leadtools.Windows.Annotations.AnnAutomation.BeginUndo()
public: virtual void BeginUndo();
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.
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
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"); }
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"); }
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
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2