Example #1
0
        public void StartDialog(Utilities.GlobalKeyboardHook hook, Action CloseEvent, int Index = -1)
        {
            _hook       = hook;
            _CloseEvent = CloseEvent;

            KeyDownHandler = new KeyEventHandler(Menu_KeyDown);
            KeyUpHandler   = new KeyEventHandler(Menu_KeyUp);

            mapData = KeyCombinationManager.Instance[Index];
            if (mapData == null)
            {
                mapData = new KeyCombinationData();
            }
            for (int i = 0; i < KeyDataManager.Instance.Count; ++i)
            {
                KeyData keyData = KeyDataManager.Instance[i];
                if (keyData != null)
                {
                    _hook.HookedKeys.Add((Keys)keyData.NumbericValue);
                }
            }
            _hook.KeyDown += KeyDownHandler;
            _hook.KeyUp   += KeyUpHandler;
            _hook.hook();
            ShowDialog();
        }
Example #2
0
 void CheckKeyData(ref List <KeyData> keyDatas)
 {
     keyDatas.Clear();
     foreach (KeyValuePair <int, bool> keyValuePair in KeyboardPressState)
     {
         KeyData keyData = KeyDataManager.Instance.Find(keyValuePair.Key);
         keyDatas.Add(keyData);
     }
 }
Example #3
0
 public static bool CheckDuplication(ref List <KeyData> keyDatas, KeyData keyData)
 {
     foreach (KeyData data in keyDatas)
     {
         if (data == keyData)
         {
             return(true);
         }
     }
     return(false);
 }
Example #4
0
 private void MenuPopup_FormClosing(object sender, FormClosingEventArgs e)
 {
     for (int i = 0; i < KeyDataManager.Instance.Count; ++i)
     {
         KeyData keyData = KeyDataManager.Instance[i];
         if (keyData != null)
         {
             _hook.HookedKeys.Remove((Keys)keyData.NumbericValue);
         }
     }
     _hook.KeyDown -= KeyDownHandler;
     _hook.KeyUp   -= KeyUpHandler;
     _hook.unhook();
     if (mapData.KeyCode.Count > 0)
     {
         KeyCombinationManager.Instance.Add(mapData);
     }
     _CloseEvent?.Invoke();
 }
Example #5
0
        void Menu_KeyDown(object sender, KeyEventArgs e)
        {
            if (KeyboardPressState.ContainsKey(e.KeyValue) == false)
            {
                KeyboardPressState.Add(e.KeyValue, false);
            }
            KeyData data = KeyDataManager.Instance.Find(e.KeyValue);

            if (textBox1.Focused)
            {
                e.Handled = true;
                CheckKeyData(ref mapData.KeyCode);
                textBox1.Text = DataManager.MakeKeyDescriptions(ref mapData.KeyCode);
            }
            if (textBox2.Focused)
            {
                e.Handled = true;
                CheckKeyData(ref mapData.mappingDataList);
                textBox2.Text = DataManager.MakeKeyDescriptions(ref mapData.mappingDataList);
            }
        }