private void Onbutton_Click(object sender, EventArgs e) { switch (((Button)sender).Name) { case "buttonCancel": DialogResult = DialogResult.Cancel; Close(); break; case "buttonOk": switch (_action) { case fad3GearEditAction.addGearVariation: _parentForm.UsageGearVariation(textBox.Text); break; case fad3GearEditAction.addGearCode: _parentForm.UsageGearCode($"{labelCode.Text}{textBox.Text}", checkBox.Checked); break; case fad3GearEditAction.addAOI: var AOIGuid = ((KeyValuePair <string, string>)comboBox.SelectedItem).Key; _parentForm.UsageTargetArea(AOIGuid, comboBox.Text); break; case fad3GearEditAction.addLocalName: var localNameGuid = ((KeyValuePair <string, string>)comboBox.SelectedItem).Key; _parentForm.UsageLocalName(localNameGuid, comboBox.Text); break; case fad3GearEditAction.editGearVariation: if (Gears.EditGearVariationName(textBox.Text, GearVariationName)) { GearVariationName = textBox.Text; DialogResult = DialogResult.OK; } else { MessageBox.Show("Editing gear variation name was not successful", "Editing not successful", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case fad3GearEditAction.editLocalName: if (Gears.EditGearLocalName(textBox.Text, GearLocalName)) { GearLocalName = textBox.Text; DialogResult = DialogResult.OK; } break; } Close(); break; } }