public ITextRangeProvider[] GetVisibleRanges() { int start_line = -1, end_line = -1; Document.GetVisibleLineIndexes(TextBoxBase.Bounds, out start_line, out end_line); ITextRangeProvider range = DocumentRange.Clone(); range.MoveEndpointByUnit(TextPatternRangeEndpoint.Start, TextUnit.Line, start_line); range.MoveEndpointByUnit(TextPatternRangeEndpoint.End, TextUnit.Line, end_line - start_line); return(new ITextRangeProvider[] { range }); }