private void HotkeyTextBox_LosingFocus(object sender, RoutedEventArgs e)
        {
            if (lastValidSettings != null && (lastValidSettings.IsValid() || lastValidSettings.IsEmpty()))
            {
                HotkeySettings = lastValidSettings.Clone();
            }

            HotkeyTextBox.Text = hotkeySettings.ToString();
            if (AutomationPeer.ListenerExists(AutomationEvents.PropertyChanged))
            {
                TextBoxAutomationPeer peer =
                    FrameworkElementAutomationPeer.FromElement(HotkeyTextBox) as TextBoxAutomationPeer;
                string textBoxChangeActivityId = "textBoxChangedOnLosingFocus";

                if (peer != null)
                {
                    peer.RaiseNotificationEvent(
                        AutomationNotificationKind.ActionCompleted,
                        AutomationNotificationProcessing.ImportantMostRecent,
                        HotkeyTextBox.Text,
                        textBoxChangeActivityId);
                }
            }

            _isActive = false;
        }
        private void HotkeyTextBox_LosingFocus(object sender, RoutedEventArgs e)
        {
            if (lastValidSettings != null && (lastValidSettings.IsValid() || lastValidSettings.IsEmpty()))
            {
                HotkeySettings = lastValidSettings.Clone();
            }

            HotkeyTextBox.Text = hotkeySettings.ToString();
            _isActive          = false;
        }
Esempio n. 3
0
 private async void Hotkey_KeyDown(int key)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         KeyEventHandler(key, true, key, Lib.Utilities.Helper.GetKeyName((uint)key));
         if (internalSettings.Code > 0)
         {
             lastValidSettings  = internalSettings.Clone();
             HotkeyTextBox.Text = lastValidSettings.ToString();
         }
     });
 }
Esempio n. 4
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();
        }
        private async void Hotkey_KeyDown(int key)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                KeyEventHandler(key, true, key, Library.Utilities.Helper.GetKeyName((uint)key));

                // Tab and Shift+Tab are accessible keys and should not be displayed in the hotkey control.
                if (internalSettings.Code > 0 && !internalSettings.IsAccessibleShortcut())
                {
                    HotkeyTextBox.Text = internalSettings.ToString();
                    lastValidSettings  = internalSettings.Clone();
                }
            });
        }
        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();
                    }
                }
            });
        }