Class UndoRedoSystem
- Namespace
- CADability
- Assembly
- CADability.dll
The undo/redo sytem usually exists as a member in the Project and is accessed via Undo. The project handles the menu commands "MenuId.Edit.Undo" and ""MenuId.Edit.Redo" and calls UndoLastStep() rsp. RedoLastStep(). To add a step to the undo system call AddUndoStep(ReversibleChange)
public class UndoRedoSystem
- Inheritance
-
UndoRedoSystem
- Inherited Members
Fields
isRedoing
public bool isRedoing
Field Value
Properties
MaxUndoSteps
Set or get the maximum number of undo steps that will be kept in the undo stack. When setting this value the undo stack will be cleared.
public int MaxUndoSteps { get; set; }
Property Value
UndoFrame
Opens an undo frame, which means that all subsequent calls to AddUndoStep will be considered as a single undo step. Calling UndoLastStep or selecting Undo from the Menu will undo all this steps as a single step. Use the C# "using" construct, since this property supports the IDisposable interface, which closes the undoframe when Dispose is called.
public IDisposable UndoFrame { get; }
Property Value
Methods
AddUndoStep(ReversibleChange)
Adds an undo step to the undo stack.
public void AddUndoStep(ReversibleChange step)
Parameters
stepReversibleChangethe step
CanRedo()
Returns true, if there is a step on the redo stack
public bool CanRedo()
Returns
CanUndo()
Returns true, if there is a step on the undo stack
public bool CanUndo()
Returns
Clear()
Remove all undo and redo actions from the action stack.
public void Clear()
ClearContext()
After several changes "using contextFrame" you can reset the context so that the following changes with the same context generate a new undo step.
public void ClearContext()
CloseUndoFrame(object)
Closes the previously opened undo frame. See OpenUndoFrame().
public void CloseUndoFrame(object UndoFrame)
Parameters
UndoFrameobjectthe result from OpenUndoFrame
ContextFrame(object)
All calls to AddUndoStep(ReversibleChange) that appeare inside the same context are considered to belong to the same action and override the previous call from the same context. So only the last call will be saved in the undo stack. Use ContextFrame with the C# "using" schema or call IDisposable.Dispose() to close the frame.
public IDisposable ContextFrame(object context)
Parameters
contextobjectany kind of object
Returns
- IDisposable
the IDisposable interface for the using schema
IgnoreLastStep()
The top undostep on the undo stack will be ignored.
public bool IgnoreLastStep()
Returns
- bool
success: true, failure: false
OpenUndoFrame()
Opens an undo frame: all subsequent calls to AddUndoStep(ReversibleChange) are considered as a single undo step until CloseUndoFrame(object) is being called. You can use the property UndoFrame instead. UndoFrames may be nested.
public object OpenUndoFrame()
Returns
- object
an object that will be needed for the corresponding CloseUndoFrame call.
PeekLastRedoStep()
Returns the next redo command if there are any. This will be either a ReversibleChange object or a untyped ArrayList. Returns null if there are no redosteps available
public object PeekLastRedoStep()
Returns
- object
The next undo command
PeekLastUndoStep()
Returns the next undo command if there are any. This will be either a ReversibleChange object or a untyped ArrayList. Returns null if there are no undosteps available
public object PeekLastUndoStep()
Returns
- object
The next undo command
RedoLastStep()
Executes the redo of the last step. Ususlly called by the project when handling the "MenuId.Edit.Redo" command.
public bool RedoLastStep()
Returns
- bool
success: true, failure: false
UndoLastStep()
Executes the undo of the last step. Ususlly called by the project when handling the "MenuId.Edit.Undo" command.
public bool UndoLastStep()
Returns
- bool
success: true, failure: false
Events
BeginContinousChangesEvent
public event UndoRedoSystem.BeginContinousChangesDelegate BeginContinousChangesEvent
Event Type
ClosingUndoFrameEvent
public event UndoRedoSystem.ClosingUndoFrameDelegate ClosingUndoFrameEvent
Event Type
EndContinousChangesEvent
public event UndoRedoSystem.EndContinousChangesDelegate EndContinousChangesEvent
Event Type
OpeningUndoFrameEvent
public event UndoRedoSystem.OpeningUndoFrameDelegate OpeningUndoFrameEvent