private void buttonEditSelectedTemplate_Click(object sender, EventArgs e) { int selectedIndex = listBoxSavedTemplates.SelectedIndex; Template template = GetSelectedTemplate(); if (template != null) { while (true) { Manipulate manipulate = new Manipulate(template); manipulate.ShowDialog(); if (UpdateTemplate(template)) { break; } if ( MessageBox.Show("Do you want to reopen your last template?", "Reopen Template?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { break; } } } listBoxSavedTemplates.SelectedIndex = selectedIndex; }
private void buttonCreateTemplate_Click(object sender, EventArgs e) { Template template = new Template(); while (true) { Manipulate manipulate = new Manipulate(template); manipulate.ShowDialog(); if (manipulate.Template != null) { if (AddTemplate(manipulate.Template)) { break; } if ( MessageBox.Show("Do you want to reopen your last template?", "Reopen Template?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { break; } } } }