예제 #1
0
        void TextBox_KeyDown(object sender, KeyEventArgs e)
        {
            ++keyPressCount;

            var tempModKey = HotKeyStringConverter.GetModifierKey(e.SystemKey, e.Key);

            if (tempModKey != ModifierKeys.None)
            {
                modKey = tempModKey;
            }
            else
            {
                if (e.Key == Key.System)
                {
                    regKey = e.SystemKey;
                }
                else
                {
                    regKey = e.Key;
                }
            }

            RebuildHotkeyText();

            e.Handled = true;
        }
예제 #2
0
        /**
         * Reads the hotkey string from settings and registers the hotkey combo with windows
         */
        void InitHotkey()
        {
            if (keyHook != null)
            {
                keyHook.UnregisterHotKey();
                keyHook = null;
            }

            var          hotKeyString = QuickCutsUI.Properties.Settings.Default.HotKeyString;
            ModifierKeys modKey;
            Key          regKey;

            if (HotKeyStringConverter.FromString(hotKeyString, out modKey, out regKey))
            {
                try
                {
                    keyHook = new WpfApplicationHotKey.HotKey(modKey, regKey, this);
                    keyHook.HotKeyPressed += new Action <WpfApplicationHotKey.HotKey>(keyHook2_HotKeyPressed);
                }
                catch (Exception ex)
                {
                    var button = MessageBoxButton.OK;
                    var icon   = MessageBoxImage.Warning;
                    MessageBox.Show(this, String.Format("Could not register hotkey '{0}'. {1}", hotKeyString, ex.Message), "Error", button, icon);
                }
            }
            else
            {
                var button = MessageBoxButton.OK;
                var icon   = MessageBoxImage.Warning;
                MessageBox.Show(this, String.Format("Could not load hotkey '{0}'.", hotKeyString), "Error", button, icon);
            }
        }
예제 #3
0
        public OptionsWindow()
        {
            InitializeComponent();

            HotKeyStringConverter.FromString(QuickCutsUI.Properties.Settings.Default.HotKeyString, out modKey, out regKey);

            RebuildHotkeyText();
        }
예제 #4
0
        void RebuildHotkeyText()
        {
            hotkeyString = HotKeyStringConverter.ToString(modKey, regKey);

            TextHotKey.Text = hotkeyString;
        }