private StringFinder search(int startIndex, string src, bool downSearch) { StringFinder sf = new StringFinder(); sf.DownSearch = downSearch; sf.Src = src; sf.FindStr = txtBefore.Text; sf.ReplaceStr = txtAfter.Text; sf.IgnoreCase = !chkIgnoreCase.Checked; sf.UseRegex = chkRegex.Checked; sf.Search(); if (startIndex != -1) { if (sf.ResultIndex == -1) { System.Media.SystemSounds.Beep.Play(); } else { textBox.Select(startIndex + sf.ResultIndex, sf.ResultLength); textBox.ScrollToCaretDelg(); } } return(sf); }
private void replace() { StringFinder sf = search(-1, textBox.SelectedText, true); if (sf.ResultIndex != -1) { textBox.ChangeSelectedText(sf.ResultReplaceStr); } else { textBox.Select(textBox.SelectionStart, 0); textBox.ScrollToCaretDelg(); } btnSearchDown_Click(null, null); }