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); }
public AutoreplacePhrase[] GetAutoreplacePhrases() { AutoreplacePhrase[] phrases = new AutoreplacePhrase[_autoReplacePhrases.Keys.Count]; int i = 0; foreach (string phrase in _autoReplacePhrases.Keys) { phrases[i] = new AutoreplacePhrase(phrase, (string)_autoReplacePhrases[phrase]); i++; } return phrases; }
public AutoreplacePhrase[] GetAutoreplacePhrases() { AutoreplacePhrase[] phrases = new AutoreplacePhrase[_autoReplacePhrases.Keys.Count]; int i = 0; foreach (string phrase in _autoReplacePhrases.Keys) { phrases[i] = new AutoreplacePhrase(phrase, (string)_autoReplacePhrases[phrase]); i++; } return(phrases); }
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); } } }