RadiantQ WPF Gantt
Enabling Undo/Redo
Previous Topic  Next Topic 

Enabling Undo/Redo


The GanttControl has support for tracking user actions and building an undo/redo stack that the users can then operate on. You can turn on this feature as follows:


            this.ganttControl.ActionManager.EnableRecordingActions = true;


Once you turn on this feature all operations on the gantt done by the user now gets recorded:


- Moving, Resizing Tasks in the Gantt Chart.

- Connecting Tasks with a dependency in the Gantt Chart.

- Progress percent resize.

- All editing operations in the grid.

- Dragging tasks around in the grid, to change their order.

- Expand/Collapse of tasks in the view.

- etc.


Note that when you enable Undo in the gantt, all operations done on the gantt should go through this ActionManager, otherwise undo actions become unreliable. In other words, you should not make any changes on the gantt model programmatically without going through the ActionManager. Refer to this topic on how to add custom actions to the ActionManager.


Take a look at the sample ..\Samples\ProjectGantt\Misc\GanttControlUndoRedo where this feature is illustrated.


Undo and Redo


You can then allow users to Undo or Redo actions on the top of the stack using the following APIs:


// To Undo the action on top of the undo stack

this.ganttControl.ActionManager.Undo();


// To Redo the action on top of the redo stack

this.ganttControl.ActionManager.Redo();



Undo / Redo List


The list of Undo / Redo commands is exposed by the ActionManager in this list:

IEnumerable<IAction> undoList = this.ganttControl.ActionManager.EnumUndoableActions();

IEnumerable<IAction> redoList = this.ganttControl.ActionManager.EnumRedoableActions();


You can bind this to a UI list (ListControl, ComboBox, etc.) to show your users the list of actions in the undo/redo stack.



� RadiantQ 2009 - 2019. All Rights Reserved.