Class UndoContext
Gives access to a state based undo mechanism for ProjectObjects. Each Project has its own undo context. The undo context makes it possible to group changes to ProjectObjects. All changes in the group can then be undone and redone.
Namespace: ABB.Robotics.RobotStudio
Assembly: ABB.Robotics.RobotStudio.dll
Syntax
public sealed class UndoContext
Properties
View SourceCanRedo
Returns true if there are entries in the Redo queue, otherwise false.
Declaration
public bool CanRedo { get; }
Property Value
| Type | Description |
|---|---|
| bool |
CanUndo
Returns true if there are entries in the Undo queue, otherwise false.
Declaration
public bool CanUndo { get; }
Property Value
| Type | Description |
|---|---|
| bool |
CurrentUndoStepName
Gets or sets the name of the current undo step
Declaration
public string CurrentUndoStepName { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
IsAppending
Returns true if the active undo step has been opened using AppendToUndoStep()
Declaration
public bool IsAppending { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsInUndoStep
Returns true if the application is currently inside an undo step.
Declaration
public bool IsInUndoStep { get; }
Property Value
| Type | Description |
|---|---|
| bool |
NumRedoSteps
Returns the number of available Redo steps
Declaration
public int NumRedoSteps { get; }
Property Value
| Type | Description |
|---|---|
| int |
NumUndoSteps
Returns the number of available Undo steps
Declaration
public int NumUndoSteps { get; }
Property Value
| Type | Description |
|---|---|
| int |
QueueSize
Gets or sets the maximum size for the Undo and Redo queues.
Declaration
public int QueueSize { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
View SourceAddChange(IChange)
Adds an undoable operation (see IChange).
Declaration
public void AddChange(IChange change)
Parameters
| Type | Name | Description |
|---|---|---|
| IChange | change |
Remarks
If an undo step is not currently open, the change will be added to the previous undo step.
AppendToUndoStep(string)
Similar to BeginUndoStep(string), but tries to append changes to the previous undo step, instead of creating a new one.
Declaration
public void AppendToUndoStep(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name |
Remarks
The name must match the name of the previous undo step. Otherwise a new undo step one will be created.
AppendToUndoStep(string, bool)
Similar to BeginUndoStep(string), but tries to append changes to the previous undo step, instead of creating a new one.
Declaration
public void AppendToUndoStep(string name, bool forceAppend)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of undo step, if a new one is created. |
| bool | forceAppend | If true, changes are appended to the previous undostep (if one exists) even if the names do not match. |
BeginUndoStep()
Starts a new unnamed undo step.
Declaration
public void BeginUndoStep()
Remarks
It is not recommended to make unnamed undo steps. Use BeginUndoStep(string name) instead.
BeginUndoStep(string)
Begins a new undo step.
Declaration
public void BeginUndoStep(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the undo step. |
Remarks
The name should be localized, since it will be displayed in the user interface.
CancelUndoStep(CancelUndoStepType)
Marks the current undo step as canceled.
Declaration
public void CancelUndoStep(CancelUndoStepType cancelType)
Parameters
| Type | Name | Description |
|---|---|---|
| CancelUndoStepType | cancelType |
Remarks
When the canceled undo step is closed by EndUndoStep(), either all changes will be undone ("rollback"), or the undo/redo queues will be cleared, depending on the value of 'cancelType'.
Clear()
Clears the Undo and Redo queues.
Declaration
public void Clear()
EndUndoStep()
Ends the current undo step.
Declaration
public void EndUndoStep()
Remarks
It is legal to make nested calls to Begin/EndUndoStep(). Only the outermost EndUndoStep() call will actually close the undo step.
ExecuteAppendUndoStep(string, Action)
Creates or appends to an undo step and executes the code in the passed in delegate inside it.
Declaration
public bool ExecuteAppendUndoStep(string undoStepName, Action action)
Parameters
| Type | Name | Description |
|---|---|---|
| string | undoStepName | |
| Action | action |
Returns
| Type | Description |
|---|---|
| bool | True if the operation succeeded, false if an exception was thrown. |
Remarks
The name must match the name of the previous undo step. Otherwise a new undo step one will be created. In case of an exception, the undo step will be rolled back and the error will be logged to the RobotStudio output window.
ExecuteUndoStep(string, Action)
Creates an undo step and executes the code in the passed in delegate inside it.
Declaration
public bool ExecuteUndoStep(string undoStepName, Action action)
Parameters
| Type | Name | Description |
|---|---|---|
| string | undoStepName | |
| Action | action |
Returns
| Type | Description |
|---|---|
| bool | True if the operation succeeded, false if an exception was thrown. |
Remarks
In case of an exception, the undo step will be rolled back and the error will be logged to the RobotStudio output window.
ExecuteUndoStep(string, Action, Action<Exception>)
Creates an undo step and executes the code in the passed in delegate inside it.
Declaration
public bool ExecuteUndoStep(string undoStepName, Action action, Action<Exception> errorHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| string | undoStepName | |
| Action | action | |
| Action<Exception> | errorHandler |
Returns
| Type | Description |
|---|---|
| bool | True if the operation succeeded, false if an exception was thrown. |
Remarks
In case of an exception, the passed in errorHandler delegate will be executed.
GetRedoNames()
Returns an array of the names of all redo steps in the redo queue
Declaration
public string[] GetRedoNames()
Returns
| Type | Description |
|---|---|
| string[] |
GetUndoNames()
Returns an array of the names of all undo steps in the undo queue
Declaration
public string[] GetUndoNames()
Returns
| Type | Description |
|---|---|
| string[] |
Redo()
Redoes the changes undone by the last call to Undo()
Declaration
public void Redo()
Remarks
It is not legal to call this method while inside an undo step.
ResumeUndoStep()
Resumes collection of undoable changes.
Declaration
public void ResumeUndoStep()
SuspendUndoStep()
Temporarily disables collection of undoable changes.
Declaration
public void SuspendUndoStep()
Undo()
Undoes the operations made during the last undo step.
Declaration
public void Undo()
Remarks
It is not legal to call this method while inside an undo step.
Events
View SourceRedoing
Occurs before a redo operation.
Declaration
public event EventHandler Redoing
Event Type
| Type | Description |
|---|---|
| EventHandler |
Redone
Occurs after a redo operation.
Declaration
public event EventHandler Redone
Event Type
| Type | Description |
|---|---|
| EventHandler |
Undoing
Occurs before an undo operation.
Declaration
public event EventHandler Undoing
Event Type
| Type | Description |
|---|---|
| EventHandler |
Undone
Occurs after an undo operation.
Declaration
public event EventHandler Undone
Event Type
| Type | Description |
|---|---|
| EventHandler |