private void CommandEntered(object obj, ACommandArgs args) { try { bool[] undoRedoPossible = new bool[2]; if (args.CommandName == "undo") { _cm.Undo(); } else if (args.CommandName == "redo") { _cm.Redo(); } else { var cmd = CommandRepository.AllocateCommand(args.CommandName, args); if (cmd == null) { throw new Exception($"Комманда {args.CommandName} не зарегистрирована"); } _cm.CommandExecute(cmd); } undoRedoPossible = _cm.CheckPosiible(); _ui.CheckUndoRedo(undoRedoPossible[0], undoRedoPossible[1]); } catch (Exception ex) { _ui.PostErrorMessage(ex.StackTrace); } }
public static ICommand AllocateCommand(string name, ACommandArgs args) { ICommand command; repos.TryGetValue(name, out command); if (command != null) { return(command.Clone(args)); } else { return(null); } }