コード例 #1
0
        public GlobalKeyForm(ShadowsocksController controller)
        {
            InitializeComponent();

            this.controller = controller;


            h.Regist(this.Handle, (int)HotKeys.HotkeyModifiers.Control, Keys.F12, CallBack);
            //MessageBox.Show("注册成功");
        }
コード例 #2
0
        private bool TryRegHotkey(TextBox tb)
        {
            var hotkey = HotKeys.Str2HotKey(tb.Text);

            if (hotkey == null)
            {
                MessageBox.Show(string.Format(I18N.GetString("Cannot parse hotkey: {0}"), tb.Text));
                tb.Clear();
                return(false);
            }

            HotKeys.HotKeyCallBackHandler callBack;
            Label lb;

            PrepareForHotkey(tb, out callBack, out lb);

            UnregPrevHotkey(callBack);

            // try to register keys
            // if already registered by other progs
            // notify to change

            // use the corresponding label color to indicate
            // reg result.
            // Green: not occupied by others and operation succeed
            // Yellow: already registered by other program and need action: disable by clear the content
            //         or change to another one
            // Transparent without color: first run or empty config

            bool regResult = HotKeys.Regist(hotkey, callBack);

            lb.BackColor = regResult ? Color.Green : Color.Yellow;
            return(regResult);
        }