예제 #1
0
        public override void Redo()
        {
            if (redoCommand.Count <= 0)
            {
                return;
            }
            INavigationCommand command = redoCommand.Pop();

            undoCommand.Push(command);
            command.Redo();
        }
예제 #2
0
        public override void Undo()
        {
            // kiểm tra danh sách những lần di chuyển trước đó
            if (undoCommand.Count <= 0)
            {
                return;
            }

            INavigationCommand command = undoCommand.Pop();

            redoCommand.Push(command);
            command.Undo();
        }
예제 #3
0
        public static IEnumerable<INavigationCommand> Then(this IEnumerable<INavigationCommand> commands, INavigationCommand appendCommand)
        {
            var newCommands = new NavigationCommands();

            foreach (var navigationCommand in commands)
            {
                newCommands.Add(navigationCommand);
            }

            newCommands.Add(appendCommand);

            return commands;
        }
예제 #4
0
 protected override void Command(string argument)
 {
     if (argument.StartsWith("Navigate"))
     {
         String type  = argument.Substring(9);
         int    split = type.IndexOf(' ');
         String args  = type.Substring(split);
         type = type.Substring(0, split);
         if (commandFactoryList.ContainsKey(type))
         {
             command = commandFactoryList[type](args);
             program.logMessages.Enqueue("New nav command received");
         }
         else
         {
             program.logMessages.Enqueue("Invalid command for Navigation module: " + type + " | " + args);
         }
     }
 }
예제 #5
0
        public static byte[] Build(this INavigationCommand command)
        {
            var buffer = new byte[7];

            int idx = 0;

            buffer[idx++] = 0xff;
            buffer[idx++] = command.DestinationAddress;

            command.CommandCode.CopyTo(buffer, idx);
            idx += command.CommandCode.Length;
            command.CommandData.CopyTo(buffer, idx);
            idx += command.CommandData.Length;
            //
            var checksum = (byte)(buffer.Skip(1).Sum(b => b) % 256);

            //var checksum = (byte)(buffer.Sum(b => b) % 256);
            buffer[idx++] = checksum;

            return(buffer);
        }
예제 #6
0
 public void Command(INavigationCommand newCommand)
 {
     this.command = newCommand;
 }
예제 #7
0
        public static IEnumerable <INavigationCommand> Then(this IEnumerable <INavigationCommand> commands, INavigationCommand appendCommand)
        {
            var newCommands = new NavigationCommands();

            foreach (var navigationCommand in commands)
            {
                newCommands.Add(navigationCommand);
            }

            newCommands.Add(appendCommand);

            return(commands);
        }
예제 #8
0
        public static IEnumerable <INavigationCommand> Then(this INavigationCommand command, INavigationCommand appendCommand)
        {
            var commands = command.AsEnumerable();

            return(Then(commands, appendCommand));
        }
예제 #9
0
 public void AddNavigationCommand(INavigationCommand navigationCommand)
 {
     _navigationCommands.Add(navigationCommand);
 }
예제 #10
0
 public static IEnumerable<INavigationCommand> Then(this INavigationCommand command, INavigationCommand appendCommand)
 {
     var commands = command.AsEnumerable();
     return Then(commands, appendCommand);
 }