private void OpenShortcutWindow(object sender, RoutedEventArgs e)
        {
            Keyboard.ClearFocus();

            ShortcutSelector shortcutSelector = new ShortcutSelector();

            if (shortcutSelector.ShowDialog().Value)
            {
                try
                {
                    HotkeyManager.Current.AddOrReplace("FocusSearchBox",
                                                       shortcutSelector.Key,
                                                       shortcutSelector.Modifiers,
                                                       FocusSearchBox);
                    Properties.Settings.Default.shortcutKey       = (int)shortcutSelector.Key;
                    Properties.Settings.Default.shortcutModifiers = (int)shortcutSelector.Modifiers;
                    Properties.Settings.Default.Save();
                }
                catch (Exception ex)
                {
                    ToolbarLogger.GetLogger("EverythingToolbar").Error(ex, "Hotkey could not be registered.");
                    MessageBox.Show("Failed to register hotkey. It might be in use by another application.",
                                    "Error",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
        }
        private void OpenShortcutWindow(object sender, RoutedEventArgs e)
        {
            EverythingSearch.Instance.Reset();

            ShortcutSelector shortcutSelector = new ShortcutSelector();

            if (shortcutSelector.ShowDialog().Value)
            {
                if (ShortcutManager.Instance.AddOrReplace("FocusSearchBox",
                                                          shortcutSelector.Key,
                                                          shortcutSelector.Modifiers))
                {
                    Properties.Settings.Default.shortcutKey       = (int)shortcutSelector.Key;
                    Properties.Settings.Default.shortcutModifiers = (int)shortcutSelector.Modifiers;
                    Properties.Settings.Default.Save();
                }
                else
                {
                    MessageBox.Show(Properties.Resources.MessageBoxFailedToRegisterHotkey,
                                    Properties.Resources.MessageBoxErrorTitle,
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
        }
Example #3
0
        private void OpenShortcutWindow(object sender, RoutedEventArgs e)
        {
            EverythingSearch.Instance.Reset();

            ShortcutSelector shortcutSelector = new ShortcutSelector();

            if (shortcutSelector.ShowDialog().Value)
            {
                if (shortcutSelector.Modifiers == ModifierKeys.Windows)
                {
                    ShortcutManager.Instance.SetShortcut(shortcutSelector.Key, shortcutSelector.Modifiers);
                    foreach (Process exe in Process.GetProcesses())
                    {
                        if (exe.ProcessName == "explorer")
                        {
                            exe.Kill();
                        }
                    }
                }

                if (ShortcutManager.Instance.AddOrReplace("FocusSearchBox",
                                                          shortcutSelector.Key,
                                                          shortcutSelector.Modifiers))
                {
                    ShortcutManager.Instance.SetShortcut(shortcutSelector.Key, shortcutSelector.Modifiers);
                }
                else
                {
                    MessageBox.Show(Properties.Resources.MessageBoxFailedToRegisterHotkey,
                                    Properties.Resources.MessageBoxErrorTitle,
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
        }
        private void OpenShortcutWindow(object sender, RoutedEventArgs e)
        {
            EverythingSearch.Instance.Reset();

            ShortcutSelector shortcutSelector = new ShortcutSelector();

            if (shortcutSelector.ShowDialog().Value)
            {
                if (ShortcutManager.Instance.AddOrReplace("FocusSearchBox",
                                                          shortcutSelector.Key,
                                                          shortcutSelector.Modifiers))
                {
                    Properties.Settings.Default.shortcutKey       = (int)shortcutSelector.Key;
                    Properties.Settings.Default.shortcutModifiers = (int)shortcutSelector.Modifiers;
                    Properties.Settings.Default.Save();
                }
                else
                {
                    MessageBox.Show("Failed to register hotkey. It might be in use by another application.",
                                    "Error",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
        }