public override void Redo() { if (redoCommand.Count <= 0) { return; } INavigationCommand command = redoCommand.Pop(); undoCommand.Push(command); command.Redo(); }
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(); }
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; }
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); } } }
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); }
public void Command(INavigationCommand newCommand) { this.command = newCommand; }
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); }
public static IEnumerable <INavigationCommand> Then(this INavigationCommand command, INavigationCommand appendCommand) { var commands = command.AsEnumerable(); return(Then(commands, appendCommand)); }
public void AddNavigationCommand(INavigationCommand navigationCommand) { _navigationCommands.Add(navigationCommand); }
public static IEnumerable<INavigationCommand> Then(this INavigationCommand command, INavigationCommand appendCommand) { var commands = command.AsEnumerable(); return Then(commands, appendCommand); }