RadiantQ WPF Gantt
Creating Custom Undo Actions
Previous Topic  Next Topic 

Creating Custom Undoable Actions is very easy. Create a custom type like the following:


    public class YourCustomAction : AbstractAction

    {

        public DeleteDependencyAction(..)

        {

        }

        protected override void ExecuteCore()

        {

            // Code to execute (redo) the action

        }


        protected override void UnExecuteCore()

        {

            // Code to undo the action.

        }

    }


And create a new action and add it to the ActionManager as follows:


YourCustomAction yourAction = new YourCustomAction(this.ganttControl, activity, ...whatever else...);

this.ganttControl.ActionManager.RecordAction(yourAction);


Note that when you create a custom action type, remember not to cache any objects that could technically become deleted from the gantt model or view and would become obsolete by the time undo happens. For example, do not cache IActivity instances, instead cache the id of the activity using which you can look up an IActivity instance whenever necessary.




� RadiantQ 2009 - 2019. All Rights Reserved.