public Command GetCommand(CommandDefinition commandDefinition) { Command command; if (!_commands.TryGetValue(commandDefinition, out command)) command = _commands[commandDefinition] = new Command(commandDefinition); return command; }
public Command(CommandDefinition commandDefinition) { _commandDefinition = commandDefinition; Text = commandDefinition.Text; ToolTip = commandDefinition.ToolTip; IconSource = commandDefinition.IconSource; _keyGesture = commandDefinition.KeyGesture; }
public CommandHandler GetCommandHandler(CommandDefinition commandDefinition, IInputElement target) { // TODO: We could look at the currently focused element, and iterate up through // the tree, giving each DataContext a chance to handle for the command. // For now, there are only global handlers. var globalHandler = _commandHandlers.FirstOrDefault(x => x.Metadata.CommandDefinitionType == commandDefinition.GetType()); if (globalHandler == null) return null; return globalHandler.Value; }