Exemplo n.º 1
0
        public OptionsWindow()
        {
            InitializeComponent();

            // Show what's already selected
            _hotkey = (HotKey)Application.Current.Properties["hotkey"];

            try
            {
                _hotkey.LoadSettings();
            }
            catch (HotkeyAlreadyInUseException)
            {
            }

            _hotkeyViewModel = new HotkeyViewModel
            {
                KeyCode = KeyInterop.KeyFromVirtualKey((int)_hotkey.KeyCode),
                Alt     = _hotkey.Alt,
                Ctrl    = _hotkey.Ctrl,
                Windows = _hotkey.WindowsKey,
                Shift   = _hotkey.Shift
            };

            HotkeyPreview.Text           = _hotkeyViewModel.ToString();
            AltTabCheckBox.IsChecked     = Settings.Default.AltTabHook;
            RunAsAdministrator.IsChecked = Settings.Default.RunAsAdmin;
        }
Exemplo n.º 2
0
        public OptionsWindow()
        {
            InitializeComponent();

            // Show what's already selected
            _hotkey = (HotKey) Application.Current.Properties["hotkey"];

            try
            {
                _hotkey.LoadSettings();
            }
            catch (HotkeyAlreadyInUseException)
            {
            }

            _hotkeyViewModel = new HotkeyViewModel
            {
                KeyCode = KeyInterop.KeyFromVirtualKey((int) _hotkey.KeyCode),
                Alt = _hotkey.Alt,
                Ctrl = _hotkey.Ctrl,
                Windows = _hotkey.WindowsKey,
                Shift = _hotkey.Shift
            };

            HotkeyPreview.Text = _hotkeyViewModel.ToString();
            AltTabCheckBox.IsChecked = Settings.Default.AltTabHook;
        }
Exemplo n.º 3
0
        public HotkeyTriggerViewModel(HotkeyTrigger trigger) : base(trigger)
        {
            _trigger = trigger;

            Hotkey = new HotkeyViewModel(trigger);
            Attach(Hotkey);
        }
Exemplo n.º 4
0
        private void HotkeyPreview_OnPreviewKeyDown(object sender, KeyEventArgs e)
        {
            // The text box grabs all input
            e.Handled = true;

            // Fetch the actual shortcut key
            var key = (e.Key == Key.System ? e.SystemKey : e.Key);

            // Ignore modifier keys
            if (key == Key.LeftShift || key == Key.RightShift ||
                key == Key.LeftCtrl || key == Key.RightCtrl ||
                key == Key.LeftAlt || key == Key.RightAlt ||
                key == Key.LWin || key == Key.RWin)
            {
                return;
            }

            var previewHotkeyModel = new HotkeyViewModel();

            previewHotkeyModel.Ctrl  = (Keyboard.Modifiers & ModifierKeys.Control) != 0;
            previewHotkeyModel.Shift = (Keyboard.Modifiers & ModifierKeys.Shift) != 0;
            previewHotkeyModel.Alt   = (Keyboard.Modifiers & ModifierKeys.Alt) != 0;

            var winLKey = new KeyboardKey(Keys.LWin);
            var winRKey = new KeyboardKey(Keys.RWin);

            previewHotkeyModel.Windows = (winLKey.State & 0x8000) == 0x8000 || (winRKey.State & 0x8000) == 0x8000;
            previewHotkeyModel.KeyCode = key;

            var previewText = previewHotkeyModel.ToString();

            // Jump to the next element if the user presses only the Tab key
            if (previewText == "Tab")
            {
                ((UIElement)sender).MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
                return;
            }

            HotkeyPreview.Text = previewText;
            _hotkeyViewModel   = previewHotkeyModel;
        }
Exemplo n.º 5
0
        public OptionsWindow()
        {
            InitializeComponent();

            // Show what's already selected
            _hotkey = (HotKey)Application.Current.Properties["hotkey"];

            try
            {
                _hotkey.LoadSettings();
            }
            catch (HotkeyAlreadyInUseException)
            {
            }

            _hotkeyViewModel = new HotkeyViewModel
            {
                KeyCode = KeyInterop.KeyFromVirtualKey((int)_hotkey.KeyCode),
                Alt     = _hotkey.Alt,
                Ctrl    = _hotkey.Ctrl,
                Windows = _hotkey.WindowsKey,
                Shift   = _hotkey.Shift
            };

            HotKeyCheckBox.IsChecked                  = Settings.Default.EnableHotKey;
            HotkeyPreview.Text                        = _hotkeyViewModel.ToString();
            HotkeyPreview.IsEnabled                   = Settings.Default.EnableHotKey;
            AltTabCheckBox.IsChecked                  = Settings.Default.AltTabHook;
            AutoSwitch.IsChecked                      = Settings.Default.AutoSwitch;
            AutoSwitch.IsEnabled                      = Settings.Default.AltTabHook;
            InstantReleaseSwitch.IsChecked            = Settings.Default.InstantReleaseSwitch;
            MaximumQueryResultCountCheckBox.IsChecked = Settings.Default.MaximumResultCountEnabled;
            MaximumQueryResultCount.IsEnabled         = (bool)MaximumQueryResultCountCheckBox.IsChecked;
            MaximumQueryResultCount.Text              = Settings.Default.MaximumResultCount.ToString();
            RunAsAdministrator.IsChecked              = Settings.Default.RunAsAdmin;
        }
Exemplo n.º 6
0
        private void HotkeyPreview_OnPreviewKeyDown(object sender, KeyEventArgs e)
        {
            // The text box grabs all input
            e.Handled = true;

            // Fetch the actual shortcut key
            var key = (e.Key == Key.System ? e.SystemKey : e.Key);

            // Ignore modifier keys
            if (key == Key.LeftShift || key == Key.RightShift
                || key == Key.LeftCtrl || key == Key.RightCtrl
                || key == Key.LeftAlt || key == Key.RightAlt
                || key == Key.LWin || key == Key.RWin)
            {
                return;
            }

            var previewHotkeyModel = new HotkeyViewModel();
            previewHotkeyModel.Ctrl = (Keyboard.Modifiers & ModifierKeys.Control) != 0;
            previewHotkeyModel.Shift = (Keyboard.Modifiers & ModifierKeys.Shift) != 0;
            previewHotkeyModel.Alt = (Keyboard.Modifiers & ModifierKeys.Alt) != 0;

            var winLKey = new KeyboardKey(Keys.LWin);
            var winRKey = new KeyboardKey(Keys.RWin);
            previewHotkeyModel.Windows = (winLKey.State & 0x8000) == 0x8000 || (winRKey.State & 0x8000) == 0x8000;
            previewHotkeyModel.KeyCode = key;

            var previewText = previewHotkeyModel.ToString();

            // Jump to the next element if the user presses only the Tab key
            if (previewText == "Tab")
            {
                ((UIElement)sender).MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
                return;
            }

            HotkeyPreview.Text = previewText;
            _hotkeyViewModel = previewHotkeyModel;
        }