Example #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);
        }
        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);
        }
Example #3
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}");

            return(ExecuteCommand(mapping.CommandId));
        }
        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);
        }