コード例 #1
0
 private void alphabetListBox_DoubleClick(Object sender, EventArgs e)
 {
     if (alphabetListBox.SelectedIndex != -1)
     {
         var form   = new AddAlphabetForm((string)alphabetListBox.Items[alphabetListBox.SelectedIndex]);
         var result = form.ShowDialog();
         if (result == DialogResult.OK)
         {
             if (form.Result != (string)alphabetListBox.Items[alphabetListBox.SelectedIndex])
             {
                 alphabet.RemoveAt(alphabetListBox.SelectedIndex);
                 alphabetListBox.Items.RemoveAt(alphabetListBox.SelectedIndex);
                 if (form.Result.Contains(".."))
                 {
                     try
                     {
                         alphabet.Add(DirtyWork.CharRange(form.Result[0], form.Result[3]));
                     }
                     catch (ArgumentOutOfRangeException)
                     {
                         MessageBox.Show("Выбрано неправильное множество символов!");
                     }
                 }
                 else
                 {
                     alphabet.Add(form.Result);
                 }
                 alphabetListBox.Items.Add(form.Result);
             }
         }
     }
 }
コード例 #2
0
        private void addAlphabetButton_Click(object sender, EventArgs e)
        {
            var form   = new AddAlphabetForm();
            var result = form.ShowDialog();

            if (result == DialogResult.OK)
            {
                if (form.Result.Contains(".."))
                {
                    try
                    {
                        alphabet.Add(DirtyWork.CharRange(form.Result[0], form.Result[3]));
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        MessageBox.Show("Выбрано неправильное множество символов!");
                    }
                }
                else
                {
                    alphabet.Add(form.Result);
                }
                alphabetListBox.Items.Add(form.Result);
            }
        }