/// <summary> /// Triggers when a checkbox is toggled /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CheckboxToggle(object sender, EventArgs e) { //On checkbox toggle, save to the config CustomCheckBox box = (sender as CustomCheckBox); box.StartRotate(); ScreenToConfig(box); }
/// <summary> /// Save the screen to the config and then write to the file /// </summary> /// <param name="box">The checkbox that was updated</param> private void ScreenToConfig(CustomCheckBox box = null) { if (box == null) { //Run through each checkbox on the page List <CustomCheckBox> boxes = MainForm.FindControls <CustomCheckBox>("", this); foreach (CustomCheckBox c in boxes) { int number = int.Parse(Regex.Match(c.Name, @"\d+").Value); //Sort by the type of category it's in and store it into the config if (number < config.debuffs.Length) { config.debuffs[number] = c.Checked ? 1 : -1; } else if (number < config.debuffs.Length + config.others.Length) { config.others[number - config.debuffs.Length] = c.Checked ? 1 : -1; } } } else { int number = int.Parse(Regex.Match(box.Name, @"\d+").Value); //Sort by the type of category it's in and store it into the config if (number < config.debuffs.Length) { config.debuffs[number] = box.Checked ? 1 : -1; } else if (number < config.debuffs.Length + config.others.Length) { config.others[number - config.debuffs.Length] = box.Checked ? 1 : -1; } } //Just in case it's not there yet, put it into the rushConfigs Data.rushConfigs[globalIndex - offset] = config; //Re-write RushConfigs to the file Data.Save("rushconfigs.dat", Data.rushConfigs); }