private void btnNew_Click(object sender, EventArgs e) { string name; while (true) { // Check name name = performTextInputDialog("_NEWPRESETNAME", ""); if (name == null) { return; } else if (name.Length < 1) { continue; } else if (name == "Default") { MsgBox.notice("_CANTUSEDEFAULT"); continue; } // Check for existing presets with the same name PresetData existingPreset = presets.presets.Find(s => s.name == name); if (existingPreset != null) { if (MsgBox.confirm("_OVERWRITEPRESET", name) != DialogResult.OK) { continue; } presets.remove(existingPreset); } break; } PresetData newPreset = new PresetData(currentSettings); newPreset.name = name; // Add new preset presets.add(newPreset); presets.save(); // Select the new preset PresetData p = presets.presets.Find(s => s.name == name); if (p != null) { cmbPresets.SelectedItem = p; } reloadExportList(); }
// Save a preset private void btnPresetSave_Click(object sender, EventArgs e) { // Credits: // Uwe Tanger (Set preset name by typing directly into presets box instead of a popup window) // Check name string name = cmbPresets.Text; if (name.Length < 1) { return; } else if (name == "Default") { MsgBox.notice("Can't change 'Default'"); return; } // Remove old preset with same name PresetData p = presets.presets.Find(s => s.name == name); if (p != null) { presets.remove(p); } // Add new preset presets.add(name); presets.save(); presets.setDataSource(cmbPresets, cmbPresets_SelectedIndexChanged); // Select the new preset p = presets.presets.Find(s => s.name == name); if (p != null) { cmbPresets.SelectedItem = (object)p; } }
private void btnExport_Click(object sender, EventArgs e) { if (saveFileDialog1.ShowDialog() == DialogResult.OK) { Presets export = new Presets(saveFileDialog1.FileName, true); for (int i = 0; i < clbExport.Items.Count; i++) { if (clbExport.GetItemChecked(i)) { PresetData p = (PresetData)clbExport.Items[i]; if (p != null) { export.add(p); Util.consoleWriteLine("_EXPORTINGPRESETS", p.name); } } } export.save(); Util.consoleWriteLine("_EXPORTCOMPLETE"); } }