public override void redo() { for (int i = 0; i < _list.Count; i++) { AbstractCommand cmd = (AbstractCommand)_list[i]; cmd.redo(); } }
public override void undo() { for (int i = _list.Count - 1; i >= 0; i--) { AbstractCommand cmd = (AbstractCommand)_list[i]; cmd.undo(); } }
public void doCmd(AbstractCommand cmd) { cmd.doit(); _doneStack.Push(cmd); _undoneStack.Clear(); if (_doneStack.Count == _maxStackSize) { _doneStack = this.reduceStackSize(_doneStack); } setUnReButtonState(); }
private Stack reduceStackSize(Stack oldStack) { Stack newStack = new Stack(); int stackCount = oldStack.Count; for (int n = 1; n < stackCount; n++) { AbstractCommand ac = (AbstractCommand)oldStack.Pop(); newStack.Push(ac); } return(newStack); }
public void redoLastUndone() { if (_undoneStack.Count != 0) { AbstractCommand last_undone_cmd = (AbstractCommand)_undoneStack.Pop(); last_undone_cmd.redo(); _doneStack.Push(last_undone_cmd); if (_doneStack.Count == _maxStackSize) { _doneStack = this.reduceStackSize(_doneStack); } setUnReButtonState(); } }
public void emptyAllStacks() { _undoneStack.Clear(); _doneStack.Clear(); _lastSavedCmd = null; }
public void setLastSavedCmd(AbstractCommand lsCmd) { _lastSavedCmd = lsCmd; }
public void removeFromList(AbstractCommand command) { _list.Remove(command); }
public void addInList(AbstractCommand command) { _list.Add(command); }