public Main() { // Run in the background Visibility = Visibility.Hidden; ShowInTaskbar = false; SetupTaskTrayIcon(); // Load the current config _config = new PlainTextConfig(true); _eventListener = new EventListener(_config); }
public EventListener(PlainTextConfig config) { // Read in the config _config = config; // Hardcode the keys _key = Key.V; _keyMod1 = "WIN"; _keyMod2 = ""; _keyMod3 = ""; // Add key to listen for _gkh.HookedKeys.Add(_key); // Listen for keyboard events _gkh.KeyDown += new KeyEventHandler(gkh_KeyDown); }
public OptionsWindow(EventListener eventListener, PlainTextConfig config) { InitializeComponent(); ShowInTaskbar = false; _eventListener = eventListener; _config = config; if (_config.RunAtStatup) { RunAtStartupCheckbox.IsChecked = true; } if (_config.PlaySound) { PlaySoundCheckbox.IsChecked = true; } }
public void UpdateFromNewConfig(PlainTextConfig newconfig) { if (RunAtStatup != newconfig.RunAtStatup) { RunAtStatup = newconfig.RunAtStatup; if (newconfig.RunAtStatup) { RegistryKey key = Registry.CurrentUser.OpenSubKey(RunAtStatupKeyPath, true); key.SetValue("PlainTexter", Assembly.GetExecutingAssembly().Location, RegistryValueKind.String); } else { RegistryKey key = Registry.CurrentUser.OpenSubKey(RunAtStatupKeyPath, true); key.DeleteValue("PlainTexter"); } } if (PlaySound != newconfig.PlaySound) { PlaySound = newconfig.PlaySound; EnsureAppKeyExists(); if (newconfig.PlaySound) { RegistryKey key = Registry.CurrentUser.OpenSubKey(AppKeyPath, true); key.SetValue("PlaySound", "true", RegistryValueKind.String); } else { RegistryKey key = Registry.CurrentUser.OpenSubKey(AppKeyPath, true); key.SetValue("PlaySound", "false", RegistryValueKind.String); } } }
private void SaveSettingshButton_Click(object sender, RoutedEventArgs e) { PlainTextConfig newconfig = new PlainTextConfig(); if ((bool)RunAtStartupCheckbox.IsChecked) { newconfig.RunAtStatup = true; } else { newconfig.RunAtStatup = false; } if ((bool)PlaySoundCheckbox.IsChecked) { newconfig.PlaySound = true; } else { newconfig.PlaySound = false; } _config.UpdateFromNewConfig(newconfig); }