private bool TryFindNext(string pattern, RegexOptions opt, FindNextDirection direction, Range range, out Place foundMatchPlace)
{
if (direction == FindNextDirection.Next)
{
foreach (var r in range.GetRangesByLines(pattern, opt))
{
foundMatchPlace = r.Start;
tb.Selection = r;
tb.DoSelectionVisible();
tb.Invalidate();
return true; // always return on the first match
}
}
else // find previous
{
foreach (var r in range.GetRangesByLinesReversed(pattern, opt))
{
foundMatchPlace = r.Start;
tb.Selection = r;
tb.DoSelectionVisible();
tb.Invalidate();
return true; // always return on the first match
}
}
foundMatchPlace = Place.Empty;
return false;
}