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); } } } } }
protected override void HandleMessageText(IMessage msg, float textXPos) { DrawContext dc = ctx; var line = dc.GetTextToDisplay(msg).GetNthTextLine(pos.TextLineIndex); var lineCharIdx = pos.LineCharIndex; if (lineCharIdx > line.Value.Length) { return; // defensive measure to avoid crash in UI thread } RectangleF tmp = DrawingUtils.GetLineSubstringBounds( line.Value + '*', lineCharIdx, lineCharIdx + 1, dc.Canvas, dc.Font, ctx.TextFormat, m.MessageRect, m.OffsetTextRect.X + textXPos ); dc.Canvas.DrawLine(dc.CursorPen, tmp.X, tmp.Top, tmp.X, tmp.Bottom); }
void DrawMessageBackground(IMessage msg, float textXPos) { DrawContext dc = ctx; Rectangle r = m.MessageRect; r.Offset(ctx.CollapseBoxesAreaSize, 0); Brush b = null; Brush tmpBrush = null; if (msg.Thread != null) { var coloring = dc.Coloring; if (coloring == Settings.Appearance.ColoringMode.None) { b = dc.DefaultBackgroundBrush; } else if (msg.Thread.IsDisposed) { b = dc.DefaultBackgroundBrush; } else if (coloring == Settings.Appearance.ColoringMode.Threads) { b = tmpBrush = new Brush(msg.Thread.ThreadColor.ToColor()); } else if (coloring == Settings.Appearance.ColoringMode.Sources) { b = (msg.LogSource == null || msg.LogSource.IsDisposed) ? dc.DefaultBackgroundBrush : (tmpBrush = new Brush(msg.LogSource.Color.ToColor())); } } if (b == null) { b = dc.DefaultBackgroundBrush; } dc.Canvas.FillRectangle(b, r); var normalizedSelection = dc.NormalizedSelection; if (!normalizedSelection.IsEmpty && DisplayIndex >= normalizedSelection.First.DisplayIndex && DisplayIndex <= normalizedSelection.Last.DisplayIndex) { int selectionStartIdx; int selectionEndIdx; var line = dc.GetTextToDisplay(msg).GetNthTextLine(TextLineIdx); if (DisplayIndex == normalizedSelection.First.DisplayIndex) { selectionStartIdx = normalizedSelection.First.LineCharIndex; } else { selectionStartIdx = 0; } if (DisplayIndex == normalizedSelection.Last.DisplayIndex) { selectionEndIdx = normalizedSelection.Last.LineCharIndex; } else { selectionEndIdx = line.Length; } if (selectionStartIdx < selectionEndIdx && selectionStartIdx >= 0 && selectionEndIdx <= line.Value.Length) { RectangleF tmp = DrawingUtils.GetLineSubstringBounds( line.Value, selectionStartIdx, selectionEndIdx, ctx.Canvas, dc.Font, ctx.TextFormat, m.MessageRect, m.OffsetTextRect.X + textXPos); dc.Canvas.FillRectangle(dc.SelectedBkBrush, tmp); } } if (ctx.ShowTime) { float x = ctx.CollapseBoxesAreaSize + ctx.TimeAreaSize - ctx.ScrollPos.X - 2; if (x > ctx.CollapseBoxesAreaSize) { ctx.Canvas.DrawLine(ctx.TimeSeparatorLine, x, m.MessageRect.Y, x, m.MessageRect.Bottom); } } if (tmpBrush != null) { tmpBrush.Dispose(); } }