UndoManager
The UndoManager class observes and records model changes and supports undo and redo operations.
Implements: IUndoManager
Constructors
public UndoManager()
undoManager = UndoManager()
Create a UndoManager that is ready to record model modifications, but that does not know about any models yet.
Properties
public bool ChecksTransactionLevel { get; set; }
value = undoManager.ChecksTransactionLevel
undoManager.ChecksTransactionLevel = value
Gets or sets whether this undo manager will output warnings to Trace listeners when model changes occur outside of a transaction.
public IList<IUndoableEdit> CompoundEdits { get; private set; }
value = undoManager.CompoundEdits
undoManager.CompoundEdits = value
Gets a list of all of the compound edits.
public CompoundEdit CurrentEdit { get; set; }
value = undoManager.CurrentEdit
undoManager.CurrentEdit = value
Gets the current compound edit for recording additional model change events.
public string CurrentTransactionName { get; }
value = undoManager.CurrentTransactionName
Gets the current transaction name given by String).
public IUndoableEdit EditToRedo { get; }
value = undoManager.EditToRedo
Gets the current IUndoableEdit to be redone, or null if there is none.
public IUndoableEdit EditToUndo { get; }
value = undoManager.EditToUndo
Gets the current IUndoableEdit to be undone, or null if there is none.
public bool IsUndoingRedoing { get; protected set; }
value = undoManager.IsUndoingRedoing
undoManager.IsUndoingRedoing = value
This property is true during a call to Undo or Redo.
public int MaximumEditCount { get; set; }
value = undoManager.MaximumEditCount
undoManager.MaximumEditCount = value
Gets or sets the maximum number of compound edits that this undo manager will remember.
public IEnumerable<IDiagramModel> Models { get; }
value = undoManager.Models
Gets a list of models for which this UndoManager is recording undo/redo information.
public IList<string> NestedTransactionNames { get; private set; }
value = undoManager.NestedTransactionNames
undoManager.NestedTransactionNames = value
Gets a stack of ongoing transaction names.
public int TransactionLevel { get; protected set; }
value = undoManager.TransactionLevel
undoManager.TransactionLevel = value
Gets the current transaction level.
public int UndoEditIndex { get; protected set; }
value = undoManager.UndoEditIndex
undoManager.UndoEditIndex = value
Gets the index into CompoundEdits for the current undoable edit.
Methods
public virtual void AddModel(IDiagramModel model)
undoManager.AddModel(model)
Make sure this undo manager knows about a IDiagramModel for which it is receiving model Changed event notifications.
- model
public virtual bool CanRedo()
result = undoManager.CanRedo()
This predicate is true when one can call Redo.
public virtual bool CanUndo()
result = undoManager.CanUndo()
This predicate is true when one can call Undo.
public virtual void Clear()
undoManager.Clear()
Clear all of the CompoundEdits and reset all other state.
protected virtual CompoundEdit CommitCompoundEdit(CompoundEdit cedit)
result = undoManager.CommitCompoundEdit(cedit)
This method is called by String) when committing a compound edit.
- cedit
- the CurrentEdit; this may be null if there had been no changes at commit time
Returns: By default, the unmodified .
public bool CommitTransaction(string tname)
result = undoManager.CommitTransaction(tname)
Just call String), committing the current transaction, with the presentation name for the transaction.
- tname
- the transaction name
Returns: the value of the call to String)
protected virtual bool EndTransaction(bool commit, string tname)
result = undoManager.EndTransaction(commit, tname)
Stop the current transaction, either rolling it back or committing it.
- commit
- true to terminate the transaction normally; false to abort it and rollback the existing edits
- tname
- the internal locale-neutral name for the transaction
Returns: true for a committed top-level transaction
public virtual object FindPrimaryObject(IUndoableEdit edit)
result = undoManager.FindPrimaryObject(edit)
Given an IUndoableEdit return an edited object that represents what was modified.
- edit
- an IUndoableEdit, usually either a ModelChangedEventArgs or a CompoundEdit
Returns: typically a Node or a Link, but this may be null if there is no such object, perhaps because a model property was modified, or because there were no real edits in the argument .
public virtual void HandleModelChanged(object sender, ModelChangedEventArgs e)
undoManager.HandleModelChanged(sender, e)
Create an IUndoableEdit for a Changed event.
- sender
- e
public virtual void Redo()
undoManager.Redo()
Restore the state of some models to after the current IUndoableEdit.
public virtual void RemoveModel(IDiagramModel model)
undoManager.RemoveModel(model)
Call this method to inform this undo manager that it no longer will be notified of model Changed events.
- model
public bool RollbackTransaction()
result = undoManager.RollbackTransaction()
Just call String), rolling back the current transaction.
Returns: the value of the call to String)
protected virtual bool SkipEvent(ModelChangedEventArgs evt)
result = undoManager.SkipEvent(evt)
This predicate is responsible for deciding if a ModelChangedEventArgs is not interesting enough to be recorded.
- evt
Returns: normally false, which causes the given event to be remembered; but true for negative valued enumerations of ModelChange.
public virtual bool StartTransaction(string tname)
result = undoManager.StartTransaction(tname)
Begin a transaction, where the changes are held by a CompoundEdit.
Returns: true if starting a top-level transaction
public virtual void Undo()
undoManager.Undo()
Restore the state of some models to before the current IUndoableEdit.