private void HotKeyTextBox_TextChanged(object sender, EventArgs e) { 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) { ((TextBox)sender).Text = SoundClass.GetHotkey(id).ToString(); } textChanged = true; if (AutoSaveCb.Checked) { SaveSettings(true); textChanged = false; } }
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(); }
private void ChangeTextboxTexts() { keyCodeTextB1.Text = SoundClass.GetHotkey(0).ToString(); keyCodeTextB2.Text = SoundClass.GetHotkey(1).ToString(); keyCodeTextB3.Text = SoundClass.GetHotkey(2).ToString(); keyCodeTextB4.Text = SoundClass.GetHotkey(3).ToString(); keyCodeTextB5.Text = SoundClass.GetHotkey(4).ToString(); keyCodeTextB6.Text = SoundClass.GetHotkey(5).ToString(); keyCodeTextB7.Text = SoundClass.GetHotkey(6).ToString(); keyCodeTextB8.Text = SoundClass.GetHotkey(7).ToString(); keyCodeTextB9.Text = SoundClass.GetHotkey(8).ToString(); keyCodeTextB10.Text = SoundClass.GetHotkey(9).ToString(); keyCodeTextB11.Text = SoundClass.GetHotkey(10).ToString(); keyCodeTextB12.Text = SoundClass.GetHotkey(11).ToString(); }
private void SaveSettings(bool soundSave) { if (!Initialized) { return; } #region Sounds mentés if (soundSave) { try { Registry.CurrentUser.DeleteSubKey(regSoundsPath); } catch { } RegistryKey rSoundskey = Registry.CurrentUser.CreateSubKey(regSoundsPath); if (rSoundskey != null) { try { SoundClass.ClearSounds(); SoundClass.SetPath(this.SoundTextBox1.Text); SoundClass.SetPath(this.SoundTextBox2.Text); SoundClass.SetPath(this.SoundTextBox3.Text); SoundClass.SetPath(this.SoundTextBox4.Text); SoundClass.SetPath(this.SoundTextBox5.Text); SoundClass.SetPath(this.SoundTextBox6.Text); SoundClass.SetPath(this.SoundTextBox7.Text); SoundClass.SetPath(this.SoundTextBox8.Text); SoundClass.SetPath(this.SoundTextBox9.Text); SoundClass.SetPath(this.SoundTextBox10.Text); SoundClass.SetPath(this.SoundTextBox11.Text); SoundClass.SetPath(this.SoundTextBox12.Text); for (int i = 0; i < SoundClass.SoundsCount; i++) { rSoundskey.SetValue("Sound_" + (i + 1), SoundClass.GetPath(i)); } textChanged = false; } catch (Exception ex) { String message = ""; message += "Error during saving!\n"; message += "Exception caught! Exception Type: : \t" + ex.GetType().ToString() + "\n"; message += "Exception message:\n"; message += ex.Message; if (ex.InnerException != null) { message += "Inner Exception Type: : \t" + ex.InnerException.GetType().ToString() + "\n"; message += "Inner Exception message:\n"; message += ex.InnerException.Message; } MessageBox.Show(message); } } } #endregion #region Settings mentés try { Registry.CurrentUser.DeleteSubKey(regSettingsPath); } catch { } RegistryKey rSettingskey = Registry.CurrentUser.CreateSubKey(regSettingsPath); if (rSettingskey != null) { try { justMinimize = this.justMinimizeCb.Checked; autosave = this.AutoSaveCb.Checked; animate = this.AnimateCb.Checked; remoteControl = this.remoteControlCB.Checked; ignoreBroadcast = this.ignoreBroadcastCB.Checked; rSettingskey.SetValue("justMinimize", this.justMinimizeCb.Checked); rSettingskey.SetValue("AutoSave", this.AutoSaveCb.Checked); rSettingskey.SetValue("AutoStart", this.startupCb.Checked); rSettingskey.SetValue("AnimateSystemTray", this.AnimateCb.Checked); rSettingskey.SetValue("RemoteControl", this.remoteControlCB.Checked); rSettingskey.SetValue("IgnoreBroadcast", this.ignoreBroadcastCB.Checked); SoundClass.ClearHotkeys(); SoundClass.SetHotkey(new Hotkey(keyCodeTextB1.Text)); SoundClass.SetHotkey(new Hotkey(keyCodeTextB2.Text)); SoundClass.SetHotkey(new Hotkey(keyCodeTextB3.Text)); SoundClass.SetHotkey(new Hotkey(keyCodeTextB4.Text)); SoundClass.SetHotkey(new Hotkey(keyCodeTextB5.Text)); SoundClass.SetHotkey(new Hotkey(keyCodeTextB6.Text)); SoundClass.SetHotkey(new Hotkey(keyCodeTextB7.Text)); SoundClass.SetHotkey(new Hotkey(keyCodeTextB8.Text)); SoundClass.SetHotkey(new Hotkey(keyCodeTextB9.Text)); SoundClass.SetHotkey(new Hotkey(keyCodeTextB10.Text)); SoundClass.SetHotkey(new Hotkey(keyCodeTextB11.Text)); SoundClass.SetHotkey(new Hotkey(keyCodeTextB12.Text)); for (int i = 0; i < SoundClass.HotkeyCount; i++) { rSettingskey.SetValue("ShortcutKey_" + i, SoundClass.GetHotkey(i)); } } catch (Exception ex) { String message = ""; message += "Error during saving!\n"; message += "Exception caught! Exception Type: : \t" + ex.GetType().ToString() + "\n"; message += "Exception message:\n"; message += ex.Message; if (ex.InnerException != null) { message += "Inner Exception Type: : \t" + ex.InnerException.GetType().ToString() + "\n"; message += "Inner Exception message:\n"; message += ex.InnerException.Message; } MessageBox.Show(message); } } #endregion }
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()); } }