private void deleteButton_Click(object sender, EventArgs e) { if (SFMessage.Show(Messages.deleteDictionary) == DialogResult.Yes) { DeleteDictionary(); } }
bool OpenFileAndDo(pathsOperation Operation) { //If encodingText is not empty and either we can not parse it //or it's less then zero or it's more then 65 535 if (encodingTextBox.Text != string.Empty && !int.TryParse(encodingTextBox.Text, out encoding) || encoding < 0 || encoding > 65535) { SFMessage.Show(Messages.codepageParse); } else { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.Multiselect = true; ofd.Filter = "text files (*.txt)|*.txt"; ofd.InitialDirectory = Path.Combine( (new DirectoryInfo(Application.StartupPath)). Parent.Parent.FullName, "SampleTexts"); if (ofd.ShowDialog() == DialogResult.OK) { Operation(ofd.FileNames); return(true); } } } return(false); }
private void sortRadioButtons_CheckedChanged(object sender, EventArgs e) { if (sortByFreqRadioButton.Checked) { SFMessage.Show(Messages.sortingNotImplemented); sortByABCRadioButton.Checked = !(sortByFreqRadioButton.Checked = false); } }
//Event handlers private void createButton_Click(object sender, EventArgs e) { if (!Dictionary.IsEmpty) { if (SFMessage.Show(Messages.replaceDictionary) == DialogResult.No) { return; } } if (OpenFileAndDo(CreateDictionary)) { deleteButton.Enabled = true; } }
//Event handlers private void fixItButton_Click(object sender, EventArgs e) { try { outputTextBox.Text = Fixer.FixString(inputTextBox.Text); } catch (ArgumentException ex) { if (ex.ParamName == "keys") { SFMessage.Show(Messages.canNotFix); } else { throw; } } }
//Event handlers private void showDictionaryButton_Click(object sender, EventArgs e) { if (!Dictionary.IsEmpty) { sortByABCRadioButton.Enabled = sortByFreqRadioButton.Enabled = true; showDictionaryTextBox.Text = "Total amount of words in processed text is " + $"{Dictionary.TotalWordsCount}."; foreach (string word in Dictionary.Words) { showDictionaryTextBox.AppendText( $"{Environment.NewLine}{word}" + $" ({Dictionary.Frequency(word)})"); } } else { SFMessage.Show(Messages.noDictionary); } }