コード例 #1
0
ファイル: SettingsView.cs プロジェクト: brannow/ikaros
        private void Capture_KeyDown(object sender, KeyEventArgs e)
        {
            if ((int)e.KeyCode <= 6)
            {
                e.SuppressKeyPress = true;
                return;
            }

            TextBox tb = (TextBox)sender;

            tb.Text = "";
            Hotkey.Type id = (Hotkey.Type)Convert.ToInt32(tb.Tag);

            if (e.KeyCode == Keys.Escape)
            {
                Hotkey.SetHotkey(id, 0, 0);
                //this.del.UpdateHotkeySetup();
                e.SuppressKeyPress = true;
                return;
            }

            int modifier = 0;

            if (e.Alt)
            {
                modifier = (int)Keys.Alt;
            }
            else if (e.Control)
            {
                modifier = (int)Keys.Control;
            }
            else if (e.Shift)
            {
                modifier = (int)Keys.Shift;
            }

            HotkeyStruct ohk = Hotkey.GetHotkeyWithKey((int)e.KeyCode, modifier);
            HotkeyStruct nhk = Hotkey.SetHotkey(id, (int)e.KeyCode, modifier);

            UpdateTextBoxWithHotkey(nhk, tb, ohk.id);
            e.SuppressKeyPress = true;
        }
コード例 #2
0
ファイル: TrayMenu.cs プロジェクト: brannow/ikaros
        public void GlobalHookKeyPress(object sender, KeyEventArgs e)
        {
            if (settings.Visible || !Hotkey.HasHotkeys())
            {
                return;
            }

            HotkeyStruct hks = Hotkey.GetHotkeyWithKey((int)e.KeyCode, (int)e.Modifiers);

            if (hks.id != Hotkey.Type.None)
            {
                if (hks.id == Hotkey.Type.Next)
                {
                    CaptureNextHotkey();
                    return;
                }

                if (hks.id == Hotkey.Type.Prev)
                {
                    CapturePrevHotkey();
                    return;
                }

                if (hks.id == Hotkey.Type.show)
                {
                    CaptureShowHotkey();
                    return;
                }

                if (hks.id == Hotkey.Type.Lock)
                {
                    CaptureLockHotkey();
                    return;
                }
            }
        }