예제 #1
0
 private void deleteButton_Click(object sender, EventArgs e)
 {
     if (SFMessage.Show(Messages.deleteDictionary) == DialogResult.Yes)
     {
         DeleteDictionary();
     }
 }
예제 #2
0
 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);
 }
예제 #3
0
 private void sortRadioButtons_CheckedChanged(object sender, EventArgs e)
 {
     if (sortByFreqRadioButton.Checked)
     {
         SFMessage.Show(Messages.sortingNotImplemented);
         sortByABCRadioButton.Checked =
             !(sortByFreqRadioButton.Checked = false);
     }
 }
예제 #4
0
 //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;
     }
 }
예제 #5
0
 //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;
         }
     }
 }
예제 #6
0
 //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);
     }
 }