コード例 #1
0
        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);
        }
コード例 #2
0
 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);
         }
     }
 }