// Replace All public static void ReplaceAll() { Regex replaceRegex = GetRegExpression(); string replacedString; // get the current SelectionStart int selectedPos = CodeEdit.SelectionStart; // get the replaced string replacedString = replaceRegex.Replace (CodeEdit.Text, ReplaceControl.Text); // Is the text changed? if (CodeEdit.Text != replacedString) { // then replace it CodeEdit.Text = replacedString; MessageBox.Show(@"Replacements are made. ", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); // restore the SelectionStart CodeEdit.SelectionStart = selectedPos; } else // inform user if no replacements are made { MessageBox.Show($@"Cannot find '{Search.Text}'. ", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } CodeEdit.Focus(); }
// Update Editor public static void GetEditorInformation() { SelectionStart = CodeEdit.SelectionStart; SelectionLength = CodeEdit.SelectionLength; // Get the line. int index = CodeEdit.SelectionStart; int line = CodeEdit.GetLineFromCharIndex(index) + 1; // Get the column. int firstChar = CodeEdit.GetFirstCharIndexFromLine(line); int column = index - firstChar; // Custom Code Editor stats TextLength = CodeEdit.TextLength; Lines = CodeEdit.Lines.Count(); Line = line; Column = column; }