private void btnSubEdit_Click(object sender, EventArgs e) { using (Forms.SubstitutionForm sf = new Forms.SubstitutionForm()) { DataGridViewRow r = dgvSubstitutions.SelectedRows[0]; Configuration.Substitution sub = subs[r.Index]; sf.SettingsFromSubstitution(sub); sf.Text = I18n.Translate("internal/UserInterface/editsubstitution", "Edit substitution '{0}'", sub.SearchFor); sf.btnOk.Text = I18n.Translate("internal/UserInterface/savechanges", "Save changes"); if (sf.ShowDialog() == DialogResult.OK) { sf.SettingsToSubstitution(sub); subs.Sort(); dgvSubstitutions.Refresh(); for (int i = 0; i < subs.Count; i++) { if (subs[i].CompareTo(sub) == 0) { dgvSubstitutions.ClearSelection(); dgvSubstitutions.Rows[i].Selected = true; break; } } } } }
private void btnSubAdd_Click(object sender, EventArgs e) { using (Forms.SubstitutionForm sf = new Forms.SubstitutionForm()) { sf.SettingsFromSubstitution(null); sf.Text = I18n.Translate("internal/UserInterface/addsubstitution", "Add new substitution"); sf.btnOk.Text = I18n.Translate("internal/UserInterface/add", "Add"); if (sf.ShowDialog() == DialogResult.OK) { Configuration.Substitution sub = new Configuration.Substitution(); sf.SettingsToSubstitution(sub); subs.Add(sub); subs.Sort(); dgvSubstitutions.RowCount = subs.Count; dgvSubstitutions.Refresh(); for (int i = 0; i < subs.Count; i++) { if (subs[i].CompareTo(sub) == 0) { dgvSubstitutions.ClearSelection(); dgvSubstitutions.Rows[i].Selected = true; break; } } } } }