private void ButtonNew_Click(object sender, EventArgs e) { var formCreateRepertoire = new RepertoireInfoForm(); if (formCreateRepertoire.ShowDialog() == DialogResult.OK) { var newRepertoire = formCreateRepertoire.Repertoire; repertoiresListBox.Items.Add(newRepertoire.ToShortString()); repertoires.Add(newRepertoire.ToShortString(), newRepertoire); } }
private void ButtonEditSelected_Click(object sender, EventArgs e) { if (repertoiresListBox.SelectedIndices.Count > 1) { MessageBox.Show("Виберіть рівно один репертуар"); return; } var selectedItem = repertoiresListBox.SelectedItem; var id = selectedItem.ToString(); repertoires.TryGetValue(id, out Repertoire selectedRepertoire); var formEditRepertoire = new RepertoireInfoForm(selectedRepertoire); if (formEditRepertoire.ShowDialog() == DialogResult.OK) { var editedRepertoire = formEditRepertoire.Repertoire; repertoires.Remove(id); repertoiresListBox.Items.Remove(id); repertoires.Add(editedRepertoire.ToShortString(), editedRepertoire); repertoiresListBox.Items.Add(editedRepertoire.ToShortString()); } }