private void btnOverwrite_Click(object sender, EventArgs e) { PresetData selectedPreset = (PresetData)cmbPresets.SelectedItem; // Make sure a preset is selected if (selectedPreset != null) { // Make sure its not the default preset if (selectedPreset.name == "Default") { MsgBox.notice("_CANTOVERWRITEDEFAULT"); } else if (MsgBox.confirm("_PRESETOVERWRITE", selectedPreset.name) == DialogResult.OK) { string name = selectedPreset.name; selectedPreset.copyFrom(currentSettings); selectedPreset.name = name; presets.save(); // Select the new preset PresetData p = presets.presets.Find(s => s.name == selectedPreset.name); if (p != null) { cmbPresets.SelectedItem = p; } reloadExportList(); } } }
// Delete a preset private void btnPresetDelete_Click(object sender, EventArgs e) { // Credits: // Uwe Tanger (Delete selected preset in the presets box instead of a popup window) // Make sure a preset is selected if (cmbPresets.SelectedItem != null) { // Make sure its not the default preset if (((PresetData)cmbPresets.SelectedItem).name == "Default") { MsgBox.notice("Can't remove 'Default'"); return; } // Confirm preset deletion (too easy to accidentally delete) // Credits: // gl.tter if (MsgBox.confirm("Delete preset '" + ((PresetData)cmbPresets.SelectedItem).name + "'?") == DialogResult.OK) { // Remove the preset presets.remove((PresetData)cmbPresets.SelectedItem); presets.save(); presets.setDataSource(cmbPresets, cmbPresets_SelectedIndexChanged); // Load up default cmbPresets.SelectedItem = presets.presets.Find(s => s.name == "Default"); } } }
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(); }
private void btnRename_Click(object sender, EventArgs e) { PresetData selectedPreset = (PresetData)cmbPresets.SelectedItem; if (selectedPreset != null) { string name; PresetData p; while (true) { // Check name name = performTextInputDialog("_NEWPRESETNAME", selectedPreset.name); if (name == null) { return; } else if (name == ((PresetData)cmbPresets.SelectedItem).name) { return; } else if (name.Length < 1) { continue; } else if (name == "Default") { MsgBox.notice("_CANTUSEDEFAULT"); continue; } // Check for existing presets with the same name p = presets.presets.Find(s => s.name == name); if (p != null) { if (MsgBox.confirm("_PRESETALREADYEXISTS") != DialogResult.OK) { continue; } presets.remove(p); } break; } selectedPreset.name = name; presets.save(); 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; } }