예제 #1
0
 public override void redo()
 {
     for (int i = 0; i < _list.Count; i++)
     {
         AbstractCommand cmd = (AbstractCommand)_list[i];
         cmd.redo();
     }
 }
예제 #2
0
 public override void undo()
 {
     for (int i = _list.Count - 1; i >= 0; i--)
     {
         AbstractCommand cmd = (AbstractCommand)_list[i];
         cmd.undo();
     }
 }
예제 #3
0
        public void doCmd(AbstractCommand cmd)
        {
            cmd.doit();
            _doneStack.Push(cmd);
            _undoneStack.Clear();

            if (_doneStack.Count == _maxStackSize)
            {
                _doneStack = this.reduceStackSize(_doneStack);
            }

            setUnReButtonState();
        }
예제 #4
0
        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);
        }
예제 #5
0
        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();
            }
        }
예제 #6
0
 public void emptyAllStacks()
 {
     _undoneStack.Clear();
     _doneStack.Clear();
     _lastSavedCmd = null;
 }
예제 #7
0
 public void setLastSavedCmd(AbstractCommand lsCmd)
 {
     _lastSavedCmd = lsCmd;
 }
예제 #8
0
 public void removeFromList(AbstractCommand command)
 {
     _list.Remove(command);
 }
예제 #9
0
 public void addInList(AbstractCommand command)
 {
     _list.Add(command);
 }