/** * Метод для поиска и исправления ошибок в тексте * * @param sender - базовый класс * @param e - класс, предназначенный для других классов, содержащих данные событий * */ private void FindFixErrorsButton_Click(object sender, EventArgs e) { int pos = 0; String text = textAreaEdit.Text; String findText = ErrorsFinder.FindErrors(text); if (findText.Equals("")) { textAreaEdit.SelectAll(); textAreaEdit.SelectionColor = Color.Black; MessageBox.Show( _ERRTEXT_NO_FOUND_MSG_TEXT, _COMPLETE_FIX_ERRTEXT_MSG_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Information ); return; } while (!findText.Equals("")) { findText = ErrorsFinder.FindErrors(text); pos = text.IndexOf(findText + findText.Replace(" ", "")); text = text.Remove(pos, findText.Length); } textAreaEdit.Text = text; MessageBox.Show( _COMPLETE_FIX_ERRTEXT_MSG_TEXT, _COMPLETE_FIX_ERRTEXT_MSG_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Information ); }
//Здесь расположен код для управления содержимым текстового поля /** * Метод для поиска ошибок в тексте - выделяет слова красным цветом * * @param sender - базовый класс * @param e - класс, предназначенный для других классов, содержащих данные событий * */ private void FindErrorsButton_Click(object sender, EventArgs e) { int pos = 0; String text = textAreaEdit.Text; String findText = ErrorsFinder.FindErrors(text); int posTF = 0; while (!findText.Equals("")) { findText = ErrorsFinder.FindErrors(text); pos = text.IndexOf(findText); if (posTF == 0) { posTF = textAreaEdit.Text.IndexOf(findText + findText.Replace(" ", ""), posTF); } else { posTF = textAreaEdit.Text.IndexOf(" " + findText + findText.Replace(" ", ""), posTF) + 1; } textAreaEdit.Select(posTF, findText.Length - 1); textAreaEdit.SelectionColor = Color.Red; text = text.Remove(pos, findText.Length); } }