Exemplo n.º 1
0
        public static bool ProcessInput(Key key, ModifierKeys modifiers)
        {
            string shortcut = GetShortcut(key, modifiers);

            InputMapping mapping = CommandMappings.FirstOrDefault(c => c.KeyboardShortcut == shortcut);

            if (mapping == null)
            {
                return(false);
            }

            if (!Commands.ContainsKey(mapping.CommandId))
            {
                return(false);
            }

            ScriptplayerCommand command = Commands[mapping.CommandId];

            if (!command.CanExecute(null))
            {
                return(false);
            }

            command.Execute(null);
            return(true);
        }
Exemplo n.º 2
0
        private static bool ProcessInput(string shortcut, bool isGlobal)
        {
            if (!IsEnabled)
            {
                return(false);
            }

            InputMapping mapping = CommandMappings.FirstOrDefault(
                c => c.KeyboardShortcut == shortcut &&
                c.IsGlobal == isGlobal);

            if (mapping == null)
            {
                return(false);
            }

            Debug.WriteLine($"Processing '{shortcut}' (global = {isGlobal}) => {mapping.CommandId}");

            if (!Commands.ContainsKey(mapping.CommandId))
            {
                return(false);
            }

            ScriptplayerCommand command = Commands[mapping.CommandId];

            if (!command.CanExecute(null))
            {
                return(false);
            }

            command.Execute(null);
            return(true);
        }
Exemplo n.º 3
0
        private static bool ExecuteCommand(string commandId)
        {
            if (!Commands.ContainsKey(commandId))
            {
                return(false);
            }

            ScriptplayerCommand command = Commands[commandId];

            if (!command.CanExecute(null))
            {
                return(false);
            }

            command.Execute(null);
            return(true);
        }
Exemplo n.º 4
0
        public static bool ProcessInput(Key key, ModifierKeys modifiers, KeySource source)
        {
            if (OnPreviewKeyReceived(key, modifiers))
            {
                return(true);
            }

            if (!IsEnabled)
            {
                return(false);
            }

            bool   isGlobal = source == KeySource.Global;
            string shortcut = GetShortcut(key, modifiers);

            InputMapping mapping = CommandMappings.FirstOrDefault(
                c => c.KeyboardShortcut == shortcut &&
                c.IsGlobal == isGlobal);

            if (mapping == null)
            {
                return(false);
            }

            Debug.WriteLine($"Processing '{shortcut}' from {source} => {mapping.CommandId}");

            if (!Commands.ContainsKey(mapping.CommandId))
            {
                return(false);
            }

            ScriptplayerCommand command = Commands[mapping.CommandId];

            if (!command.CanExecute(null))
            {
                return(false);
            }

            command.Execute(null);
            return(true);
        }
Exemplo n.º 5
0
 public static void RegisterCommand(ScriptplayerCommand command)
 {
     Commands.Add(command.CommandId, command);
 }
Exemplo n.º 6
0
 public static ScriptplayerCommand RegisterCommand(ScriptplayerCommand command)
 {
     Commands.Add(command.CommandId, command);
     return(command);
 }