Beispiel #1
0
 public Command GetCommand(CommandDefinition commandDefinition)
 {
     Command command;
     if (!_commands.TryGetValue(commandDefinition, out command))
         command = _commands[commandDefinition] = new Command(commandDefinition);
     return command;
 }
Beispiel #2
0
 public Command(CommandDefinition commandDefinition)
 {
     _commandDefinition = commandDefinition;
     Text = commandDefinition.Text;
     ToolTip = commandDefinition.ToolTip;
     IconSource = commandDefinition.IconSource;
     _keyGesture = commandDefinition.KeyGesture;
 }
Beispiel #3
0
        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;
        }