Пример #1
0
        public void doCommand(Command cmd)
        {
            int     index = CommandQueue.Instance.Count, i = 1;
            Command newCmd = CommandQueue.Instance[index - i];

            switch (newCmd.type)
            {
            case "dec":
                if (newCmd.Undo == false)
                {
                    actual.dec(newCmd);
                }
                else
                {
                    actual.inc(newCmd);
                }
                break;

            case "inc":
                if (newCmd.Undo == false)
                {
                    actual.inc(newCmd);
                }
                else
                {
                    actual.dec(newCmd);
                }
                break;

            default:
                break;
            }

            Command obj = (Command)CommandQueue.Instance[CommandQueue.Instance.Count - 1].Clone();

            if (obj.Undo == true)
            {
                if (obj.type == "inc")
                {
                    obj.type = "dec";
                }
                else
                {
                    obj.type = "inc";
                }
            }

            CommandQueue.Instance.Add(obj);
        }
Пример #2
0
        public void undoCommand(Command cmd)
        {
            actual.dec(cmd);

            /*int i = 1;
             *
             * while (CommandQueue.getQueue[CommandQueue.getQueue.Count - i].Undo == true)
             * {
             *  i++;
             * }
             *
             * switch (CommandQueue.getQueue[CommandQueue.getQueue.Count - i].type)
             * {
             *  case "inc":
             *      actual.dec(CommandQueue.getQueue[CommandQueue.getQueue.Count - i]);
             *      break;
             *  case "dec":
             *      actual.inc(CommandQueue.getQueue[CommandQueue.getQueue.Count - i]);
             *      break;
             *  default:
             *      break;
             * }*/
        }
Пример #3
0
 public void doCommand(Command cmd)
 {
     actual.dec(cmd);
     CommandQueue.Instance.Add(cmd);
 }