示例#1
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            try
            {
                KeyItemInfo newItem = new KeyItemInfo();

                newItem.FuncKey = (KeyFlags)cbxFuncKey.SelectedIndex;
                if (string.IsNullOrEmpty(cbxCharKey.Text) == false)
                {
                    if (cbxCharKey.Text.Length >= 2)
                    {
                        newItem.CharKey = (Keys)Enum.Parse(typeof(Keys), cbxCharKey.Text);
                    }
                    else
                    {
                        newItem.CharKey = (Keys)((int)cbxCharKey.Text.ToCharArray()[0]);
                    }
                }

                if (newItem.FuncKey != KeyFlags.MOD_NONE)
                {
                    newItem.Alias = GetFuncKeyAlias(newItem.FuncKey) + "+" + GetCharKeyAlias(newItem.CharKey);
                }
                else
                {
                    newItem.Alias = GetCharKeyAlias(newItem.CharKey);
                }

                AddItemToList(newItem);
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
 private void OnHotKey(KeyItemInfo keyInfo)
 {
     try
     {
         DoBindActions(_designEvents[keyInfo.Alias], this);
     }
     catch (Exception ex)
     {
         MsgBox.ShowException(ex, this);
     }
 }
示例#3
0
        private void AddItemToList(KeyItemInfo keyInfo)
        {
            ListViewItem itemNew = new ListViewItem(new string[] { keyInfo.Alias,
                                                                   GetFuncKeyAlias(keyInfo.FuncKey),
                                                                   GetCharKeyAlias(keyInfo.CharKey), }, 0);

            itemNew.Tag  = keyInfo;
            itemNew.Name = keyInfo.Alias;


            listView1.Items.Add(itemNew);
        }
示例#4
0
        public int RegisterHotkey(KeyItemInfo keyItem)
        {
            UInt32 hotkeyid = GlobalAddAtom(System.Guid.NewGuid().ToString());

            RegisterHotKey((IntPtr)hWnd, hotkeyid, (UInt32)keyItem.FuncKey, (UInt32)keyItem.CharKey);

            if (_regHotkeys == null)
            {
                _regHotkeys = new Dictionary <uint, KeyItemInfo>();
            }

            keyItem.RegInstanceID = hotkeyid;
            _regHotkeys.Add(hotkeyid, keyItem);

            return((int)hotkeyid);
        }
示例#5
0
        public void UnregisterHotkeys()
        {
            System.Windows.Forms.Application.RemoveMessageFilter(this);

            if (_regHotkeys == null)
            {
                return;
            }

            for (int i = _regHotkeys.Count - 1; i >= 0; i--)
            {
                KeyValuePair <uint, KeyItemInfo> kv = _regHotkeys.ElementAt(i);

                KeyItemInfo delKeyItem = kv.Value;

                UnregisterHotKey(hWnd, delKeyItem.RegInstanceID);
                GlobalDeleteAtom(delKeyItem.RegInstanceID);

                _regHotkeys.Remove(kv.Key);
            }
        }