private void HotKeyTextBox_KeyDown(object sender, KeyEventArgs e) { Keys key = e.KeyCode; Hotkey pressedKeys = new Hotkey(); if (e.Modifiers.ToString().Contains(Keys.Control.ToString())) { pressedKeys.Add(Keys.Control); } if (e.Modifiers.ToString().Contains(Keys.Shift.ToString())) { pressedKeys.Add(Keys.Shift); } if (e.Modifiers.ToString().Contains(Keys.Alt.ToString())) { pressedKeys.Add(Keys.Alt); } bool doNotAdd = false; if (key.ToString().Contains(Keys.Control.ToString())) { doNotAdd = true; } if (key.ToString().Contains(Keys.Shift.ToString())) { doNotAdd = true; } if (key.ToString().Contains(Keys.Alt.ToString())) { doNotAdd = true; } if (!doNotAdd) { pressedKeys.Add(key); } String name = ((TextBox)sender).Name; int hossz = "keyCodeTextB".Length; name = name.Substring(hossz); int id = 0; int.TryParse(name, out id); id--; if (id >= 0 && id <= SoundClass.HotkeyCount) { SoundClass.SetHotkey(id, pressedKeys); ((TextBox)sender).Text = SoundClass.GetHotkey(id).ToString(); } ChangeTextboxTexts(); }
public static void PushedButtons(int keyCode) { if (Program.debugmode) { String realPressed = ""; realPressed += "vkCode: " + keyCode + " \n"; realPressed += "Key: " + (Keys)keyCode + " \n"; realPressed += "ModifierKeys: " + Control.ModifierKeys + " \n"; Console.WriteLine(realPressed); } Keys key = (Keys)keyCode; Hotkey pressedKeys = new Hotkey(); if (Control.ModifierKeys.ToString().Contains(Keys.Control.ToString())) { pressedKeys.Add(Keys.Control); } if (Control.ModifierKeys.ToString().Contains(Keys.Shift.ToString())) { pressedKeys.Add(Keys.Shift); } if (Control.ModifierKeys.ToString().Contains(Keys.Alt.ToString())) { pressedKeys.Add(Keys.Alt); } bool doNotAdd = false; if (key.ToString().Contains(Keys.Control.ToString())) { doNotAdd = true; } if (key.ToString().Contains(Keys.Shift.ToString())) { doNotAdd = true; } if (key.ToString().Contains(Keys.Alt.ToString())) { doNotAdd = true; } if (!doNotAdd) { pressedKeys.Add(key); } /* HARD CODED EXIT COMBO */ Hotkey exitCombo = new Hotkey("Control + Shift + Alt + Delete"); if (pressedKeys.Equals(exitCombo)) { SettingsForm.forceClose = true; Application.Exit(); } /* HARD CODED EXIT COMBO */ ButtonPushed(pressedKeys); for (int i = 0; i < SoundClass.HotkeyCount; i++) { if (pressedKeys.Equals(SoundClass.GetHotkey(i))) { if (SettingsForm.ToNetwork) { NetworkClass.Send(i.ToString()); } else { if (NetworkClass.hardPlay && Program.godmode) { SoundClass.HardPlay(i); } else { SoundClass.Play(i); } } } } if (Program.debugmode) { Console.WriteLine(pressedKeys.ToString()); } }