private async void Hotkey_KeyDown(int key)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                KeyEventHandler(key, true, key);

                c.Keys = internalSettings.GetKeysList();

                if (internalSettings.GetKeysList().Count == 0)
                {
                    // Empty, disable save button
                    shortcutDialog.IsPrimaryButtonEnabled = false;
                }
                else if (internalSettings.GetKeysList().Count == 1)
                {
                    // 1 key, disable save button
                    shortcutDialog.IsPrimaryButtonEnabled = false;

                    // Check if the one key is a hotkey
                    if (internalSettings.Shift || internalSettings.Win || internalSettings.Alt || internalSettings.Ctrl)
                    {
                        c.IsError = false;
                    }
                    else
                    {
                        c.IsError = true;
                    }
                }

                // Tab and Shift+Tab are accessible keys and should not be displayed in the hotkey control.
                if (internalSettings.Code > 0 && !internalSettings.IsAccessibleShortcut())
                {
                    lastValidSettings = internalSettings.Clone();

                    if (!ComboIsValid(lastValidSettings))
                    {
                        DisableKeys();
                    }
                    else
                    {
                        EnableKeys();
                    }
                }
            });
        }
Пример #2
0
#pragma warning disable CA1801 // Review unused parameters
        private void ShortcutDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
#pragma warning restore CA1801 // Review unused parameters
        {
            if (ComboIsValid(lastValidSettings))
            {
                HotkeySettings = lastValidSettings.Clone();
            }

            PreviewKeysControl.ItemsSource = hotkeySettings.GetKeysList();
            AutomationProperties.SetHelpText(EditButton, HotkeySettings.ToString());
            shortcutDialog.Hide();
        }