private void TextBox_KeyDown(object sender, KeyEventArgs e)
 {
     //按退格键就可以清空数据啦!
     if (e.KeyCode == Keys.Back)
     {
         textBox.Text      = "";
         registerKey       = Keys.None;
         registerModifiers = KeyModifiers.None;
         return;
     }
     e.SuppressKeyPress = true;
     //没有修饰符也算热键?你特么在逗我!
     if (e.Modifiers != Keys.None)
     {
         Keys         key       = Keys.None;
         KeyModifiers modifiers = HotKeyRegister.GetModifiers(e.KeyData, out key);
         //只按了修饰符可不行!
         if (key != Keys.None)
         {
             //输入有效!显示输入的热键!
             registerKey       = key;
             registerModifiers = modifiers;
             textBox.Text      = string.Format("{0}+{1}",
                                               registerModifiers, GetKeysString(registerKey));
         }
     }
 }
Beispiel #2
0
 private void UnregisterBossKey()
 {
     if (hotKeyToRegister != null)
     {
         hotKeyToRegister.Dispose();
         hotKeyToRegister = null;
     }
 }
Beispiel #3
0
 private void RegisterBossKey()
 {
     if (HotKeyRegister.IsCombineKey(Config.RegisterModifiers, Config.RegisterKey))
     {
         UnregisterBossKey();
         hotKeyToRegister = new HotKeyRegister(mainForm.Handle, 100,
                                               Config.RegisterModifiers, Config.RegisterKey);
         hotKeyToRegister.HotKeyPressed += new EventHandler(BossKeyPressed);
     }
 }
        private void Settings_Load(object sender, EventArgs e)
        {
            Config config = plugin.Config;

            enableTrayIcon.Checked        = config.EnableTrayIcon;
            hideWhenClickTrayIcon.Checked = config.HideWhenClickTrayIcon;
            hideWhenMinimized.Checked     = config.HideWhenMinimized;

            enableBossKey.Checked            = config.EnableBossKey;
            hideTrayIconWhenBossCome.Checked = config.HideTrayIconWhenBossCome;
            muteWhenBossCome.Checked         = config.MuteWhenBossCome;

            registerKey       = config.RegisterKey;
            registerModifiers = config.RegisterModifiers;

            activateWhenShow.Checked = config.ActivateWhenShow;

            //显示之前保存的热键!
            if (HotKeyRegister.IsCombineKey(registerModifiers, registerKey))
            {
                textBox.Text = string.Format("{0}+{1}",
                                             registerModifiers, GetKeysString(registerKey));
            }
        }