|Using Undo Redo|
How Undo and Redo works
BCF encapsulates data updates in transactions. BcfTransaction has already a capability to rollback and repeat data updates. To support undo and redo the processed transactions will be stored in a repository. The repository has two stacks. Processed transactions for undo and 'Undone' transactions for redo. When a transaction was committed it will be pushed on the undo-stack and the redo-stack will be cleared. When undoing last transaction from undo-stack will be rolled back and the transaction will be moved to redo-stack.
Choose a repository
An undo-repository is always a BcfDataSetBehaviorItem. Add a repositiory to your model by adding it as DataSetBehavior using BCF Editor - or - modify your BcfDataSetSetup before it is used in BcfDataSet constructor:
var dss = new MyTestDataSetSetup(); // add undo-repository dss.BehaviorItems.Add(new BcfDataSetUndoRepository()); var ds = new MyTestDataSet(dss);
Enable at runtime
After creating a BcfDataSet undo is disabled by default. To enable call EnableChangeTracking.
Most important undo redo related members
BcfDataSet.EnableChangeTracking() activates processed transactions storing.
BcfDataSet.DisableChangeTracking() disables transactions storing and clears repository.
BcfDataSet.ChangeTracking indicates whether processed transactions will be stored or not.
IBcfDataSetUndoRepository.CanUndo() indicates whether undo repository is not empty.
IBcfDataSetUndoRepository.CanRedo() indicates whether redo repository is not empty.
BcfDataSet.CanUndo() indicates whether an undo operation is possible or not.
BcfDataSet.CanRedo() indicates whether an redo operation is possible or not.
BcfDataSet.Undo() Undo last transaction.
BcfDataSet.Redo() Redo last undone transaction.