private void btnRun_Click(object sender, EventArgs e) { Dictionary <char, char> charDictionary = new Dictionary <char, char>(); StringBuilder sb = new StringBuilder(""); if (!string.IsNullOrEmpty(textBox1.Text)) { if (string.IsNullOrEmpty(textBox2.Text)) { sb.Append($"The new character which will replace the '{textBox1.Text}' character was not indicated.\r\n"); } else if (!charDictionary.ContainsKey(char.Parse(textBox1.Text))) { charDictionary.Add(char.Parse(textBox1.Text), char.Parse(textBox2.Text)); } } if (!string.IsNullOrEmpty(textBox3.Text)) { if (string.IsNullOrEmpty(textBox4.Text)) { sb.Append($"The new character which will replace the '{textBox3.Text}' character was not indicated.\r\n"); } else if (!charDictionary.ContainsKey(char.Parse(textBox3.Text))) { charDictionary.Add(char.Parse(textBox3.Text), char.Parse(textBox4.Text)); } } if (!string.IsNullOrEmpty(textBox5.Text)) { if (string.IsNullOrEmpty(textBox6.Text)) { sb.Append($"The new character which will replace the '{textBox5.Text}' character was not indicated.\r\n"); } else if (!charDictionary.ContainsKey(char.Parse(textBox5.Text))) { charDictionary.Add(char.Parse(textBox5.Text), char.Parse(textBox6.Text)); } } if (sb.Length > 0) { MessageBox.Show(sb.ToString()); } if (IMF.ValidateInputFile()) { Processor.ReadText(); Processor.ReplaceCharacters(charDictionary); CountWordsResultForm resultForm = new CountWordsResultForm(); resultForm.ShowDialog(); } }
private void btnRun_Click(object sender, EventArgs e) { char space = ' '; List <string> wordsList = new List <string> { textBox1.Text.Trim(space), textBox2.Text.Trim(space), textBox3.Text.Trim(space), textBox4.Text.Trim(space), textBox5.Text.Trim(space), textBox6.Text.Trim(space) }; wordsList.RemoveAll(item => item == null || item == ""); bool caseSensitive = checkBoxCaseSensitive.Checked; if (IMF.ValidateInputFile()) { Processor.ReadText(); Processor.GetWordsCount(wordsList, caseSensitive); CountWordsResultForm resultForm = new CountWordsResultForm(); resultForm.ShowDialog(); } }