private void DoInplaceHighlighting( IMessage msg, PointF location, StringSlice text, int lineBegin, int lineEnd, IHighlightingHandler handler, Brush brush) { if (handler != null) { foreach (var hlRange in handler.GetHighlightingRanges(msg)) { int?hlBegin = null; int?hlEnd = null; if (hlRange.Item1 >= lineBegin && hlRange.Item1 <= lineEnd) { hlBegin = hlRange.Item1; } if (hlRange.Item2 >= lineBegin && hlRange.Item2 <= lineEnd) { hlEnd = hlRange.Item2; } if (hlBegin != null || hlEnd != null) { var tmp = DrawingUtils.GetLineSubstringBounds( text.SubString(lineBegin, lineEnd - lineBegin).Value, hlBegin.GetValueOrDefault(lineBegin) - lineBegin, hlEnd.GetValueOrDefault(lineEnd) - lineBegin, ctx.Canvas, ctx.Font, ctx.TextFormat, m.MessageRect, location.X); tmp.Inflate(0, -1); if (brush == null) { var cl = hlRange.Item3.GetBackgroundColor(); if (cl != null) { using (var tmpBrush = new Brush(cl.Value.ToColor())) { FillInplaceHightlightRectangle(ctx, tmp, tmpBrush); } } } else { FillInplaceHightlightRectangle(ctx, tmp, brush); } } } } }