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.GetTextSubstringBounds( dc.Canvas, m.MessageRect, line.Value + '*', lineCharIdx, lineCharIdx + 1, dc.Font, m.OffsetTextRect.X + textXPos, ctx.TextFormat); dc.Canvas.DrawLine(dc.CursorPen, tmp.X, tmp.Top, tmp.X, tmp.Bottom); }
public static Metrics GetMetrics(ViewLine line, DrawContext dc) { Point offset = dc.GetTextOffset(line.Message.Level, line.LineIndex); Metrics m; m.MessageRect = new Rectangle( 0, offset.Y, dc.ViewWidth, dc.LineHeight ); m.TimePos = new Point( dc.CollapseBoxesAreaSize - dc.ScrollPos.X, m.MessageRect.Y ); int charCount = dc.GetTextToDisplay(line.Message).GetNthTextLine(line.TextLineIndex).Length; m.OffsetTextRect = new Rectangle( offset.X, m.MessageRect.Y, (int)((double)charCount * dc.CharWidthDblPrecision), m.MessageRect.Height ); m.OulineBoxCenter = new Point( line.IsBookmarked ? dc.OutlineBoxSize / 2 + 1 : dc.CollapseBoxesAreaSize / 2, m.MessageRect.Y + dc.LineHeight / 2 ); m.OulineBox = new Rectangle( m.OulineBoxCenter.X - dc.OutlineBoxSize / 2, m.OulineBoxCenter.Y - dc.OutlineBoxSize / 2, dc.OutlineBoxSize, dc.OutlineBoxSize ); return(m); }
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(); } }