//resets to defaults void Reset() { //set keys upkey.SetKey(Keys.Up); downkey.SetKey(Keys.Down); mutekey.SetKey(Keys.M); //set default modifier List <string> modList = new List <string>() { "CTRL" }; upkey.SetModifiers(modList); downkey.SetModifiers(modList); //minimize to tray sendtotraycheckbox.Checked = false; extraSettingObject.SetSendToTray(false); SyncVisuals(); SaveLoad.Save(upkey, downkey, mutekey, extraSettingObject); }
//Modifier Selection private void modselectbox_SelectedIndexChanged_1(object sender, EventArgs e) { if (upkey == null || downkey == null || loading) { return; } //convert to List List <string> convertedList = new List <string>(); foreach (string item in modselectbox.SelectedItems) { convertedList.Add(item); } //send list to keyhandlers upkey.SetModifiers(convertedList); downkey.SetModifiers(convertedList); mutekey.SetModifiers(convertedList); }
public static bool Load(KeyHandler upKey, KeyHandler downKey, KeyHandler muteKey, Settings extraSettings) { if (!File.Exists(saveFilePath) || downKey == null || upKey == null) { return(false); } //get array of lines from the save file string[] lines = File.ReadAllLines(saveFilePath); //on off bool on = true; bool.TryParse(lines[0], out on); //up int savedupKey = 0; if (!int.TryParse(lines[1], out savedupKey)) { return(false); } //down int saveddownKey = 0; if (!int.TryParse(lines[2], out saveddownKey)) { return(false); } //mods string[] mods = lines[3].Split(','); //minimize to tray bool minimizeToTray = false; if (lines.Count() > 4) { bool.TryParse(lines[4], out minimizeToTray); } //mute key int savedmuteKey = 0; if (lines.Count() > 5) { int.TryParse(lines[5], out savedmuteKey); } //set variables //**note that this should eventually be moved to changing the Settings object and then the caller //would change the KeyHandlers like what happens with minimizeToTray upKey.SetKey(savedupKey); downKey.SetKey(saveddownKey); if (lines.Count() > 5) //make sure mute key was saved { muteKey.SetKey(savedmuteKey); } //set mods upKey.SetModifiers(new List <string>(mods)); downKey.SetModifiers(new List <string>(mods)); muteKey.SetModifiers(new List <string>(mods)); if (on) { upKey.Register(); downKey.Register(); } extraSettings.SetSendToTray(minimizeToTray); return(true); }