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); } } } }
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); } }
private void DoWork() { MessageBox.Show("Результат: \"" + DirtyWork.DoWork(this, permuts) + "\""); Invoke(new InvokeWork(() => { addAlphabetButton.Enabled = addPermutsButton.Enabled = alphabetListBox.Enabled = permutsListBox.Enabled = inputTextBox.Enabled = true; deleteAlphabetButton.Enabled = alphabetListBox.SelectedIndex != -1; deletePermutsButton.Enabled = permutsListBox.SelectedIndex != -1; stopButton_Click(this, new EventArgs()); })); }
private void startButton_Click(Object sender, EventArgs e) { if (!DirtyWork.CheckByAlphabet(alphabet, permuts, inputTextBox.Text)) { return; } addAlphabetButton.Enabled = addPermutsButton.Enabled = deleteAlphabetButton.Enabled = deletePermutsButton.Enabled = alphabetListBox.Enabled = permutsListBox.Enabled = inputTextBox.Enabled = false; startButton.Text = "Стоп"; startButton.Click -= startButton_Click; startButton.Click += stopButton_Click; stepsDataGridView.Rows.Clear(); work = new Thread(DoWork); work.Start(); }