// make Undo, i.e. revert the object to its previous state public bool Undo(bool storeSateteBeforOperation = false) { if (undoList.Count > 0) { // get the object state from the undo list ObjectPropertyValuePair undoObject = undoList[0]; // suspend the object from notification // otherwise we will be notified for an action which we perform and should be inserted in any list undoObject.O.SuspendListener = true; // revert to the state var prevState = undoObject.SetState(); // after we execute the operation we won to resume the notifications undoObject.O.SuspendListener = false; // remove this state from undo list undoList.Remove(undoObject); // IF WE WANT TO SAVE CURRENT STATE if (storeSateteBeforOperation) { this.AddToRedo(prevState); } // add this state to the redo list this.AddToRedo(undoObject); return(true); } return(false); }
public bool Redo(bool storeSateteBeforOperation = false) { if (redoList.Count > 0) { ObjectPropertyValuePair redoObject = redoList[0]; redoObject.O.SuspendListener = true; var prevState = redoObject.SetState(); redoObject.O.SuspendListener = false; redoList.Remove(redoObject); // IF WE WANT TO SAVE CURRENT STATE if (storeSateteBeforOperation) { this.AddToUndo(prevState); } this.AddToUndo(redoObject); return(true); } return(false); }