예제 #1
0
        public void AddHotKey(HotKey hotkey)
        {

            if (hotkey == null)
                return;

            RemoveHotkey(hotkey);
            Keys.Add(hotkey);

            if (OnChange != null)
                OnChange(this, EventArgs.Empty);
        }
예제 #2
0
        public void UpdateHotKey(HotKey key)
        {

            if( _settings.hotKeys.Keys.ToList().Exists( hk => hk.Title == key.Title ))
            {

                var i = _settings.hotKeys.Keys.IndexOf((HotKey)listHotKeys.SelectedItem);
                if (i >= 0)
                {
                    _settings.hotKeys.Keys[i] = key;
                }
                else
                {
                    _settings.hotKeys.Keys.Add(key);
                }
                _hotkeyBindingSrc = null;
                SetupHotkeyList();
            }
            checkBoxHotKey.Checked = false;
            checkBoxHotKey.Enabled = true;
            listHotKeys.Enabled = true;
            checkBoxHold.Enabled = true;
        }
예제 #3
0
 public void RemoveHotkey(HotKey hotkey)
 {
     var todelete = Keys.FirstOrDefault(hk => hk.Title == hotkey.Title);
     if (todelete != null)
         Keys.Remove(todelete);
 }
예제 #4
0
 public HotKeyArgs(HotKey hotkey)
 {
     HotKey = hotkey;
 }
예제 #5
0
        public HotKey GetHotKey(HotKey key)
        {
            if (key == null)
            {
                _currentHotkey = null;
                return null;
            }

            _currentHotkey = key;

            foreach (var joy in Joysticks.Where(d => d.Type == DeviceType.Physical))
                joy.OnButtonDown += new EventHandler<CustomEventArgs<DirectInputData>>(hotkey_OnButton);
            
            Keyboards.ForEach(keyboard => keyboard.OnKeyUp += new EventHandler<CustomEventArgs<DirectInputData>>(hotkey_OnButton));
            Mouses.ForEach(mouse => mouse.OnButtonDown += new EventHandler<CustomEventArgs<DirectInputData>>(hotkey_OnButton));
            _currentHotkey.Key = null;
            while (_currentHotkey.Key == null)
            {
                Thread.Sleep(50);
            }
            return _currentHotkey;
        }