private bool ValidateForm() { if (_newReplaceValue) { if (String.IsNullOrEmpty(Phrase)) { DisplayMessage.Show(MessageId.AutoreplacePhraseRequired); textBoxPhrase.Focus(); return(false); } if (String.IsNullOrEmpty(ReplaceValue)) { DisplayMessage.Show(MessageId.AutoreplaceReplacementRequired); textBoxReplace.Focus(); return(false); } AutoreplacePhrase phrase = _preferences.GetPhrase(Phrase); if (phrase != null && phrase.ReplaceValue != null) { DialogResult result = DisplayMessage.Show(MessageId.AutoreplaceAlreadyExists); if (result == DialogResult.No) { textBoxPhrase.Focus(); return(false); } } } return(true); }
private void buttonEdit_Click(object sender, EventArgs e) { using (AutoreplaceEditForm form = new AutoreplaceEditForm(_preferences)) { AutoreplacePhrase phrase = _preferences.GetPhrase(listViewItems.SelectedItems[0].Text); form.Phrase = phrase.Phrase; form.ReplaceValue = phrase.ReplaceValue; DialogResult result = form.ShowDialog(this); if (result == DialogResult.OK) { _preferences.SetAutoreplacePhrase(form.Phrase, form.ReplaceValue); RefreshEntries(); SelectItem(form.Phrase); } } }