Пример #1
0
 private void DoInplaceHighlighting(
     IMessage msg,
     Font font,
     PointF location,
     StringFormat format,
     StringSlice text,
     int lineBegin, int lineEnd,
     Func <IMessage, IEnumerable <Tuple <int, int> > > handler,
     Brush brush)
 {
     if (handler != null)
     {
         foreach (var hlRange in handler(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.GetTextSubstringBounds(
                     ctx.Canvas, m.MessageRect, text.Value, hlBegin.GetValueOrDefault(lineBegin), hlEnd.GetValueOrDefault(lineEnd),
                     font, location.X, format);
                 tmp.Inflate(0, -1);
                 FillInplaceHightlightRectangle(ctx, tmp, brush);
             }
         }
     }
 }
Пример #2
0
        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);
        }
Пример #3
0
        void DrawMessageBackground(IMessage msg, float textXPos)
        {
            DrawContext dc = ctx;
            Rectangle   r  = m.MessageRect;

            r.Offset(ctx.CollapseBoxesAreaSize, 0);
            Brush b        = null;
            Brush tmpBrush = null;
            var   hlcl     = msg.FilteringResult.GetBackgroundColor();

            if (hlcl != null)
            {
                b = tmpBrush = new Brush(hlcl.Value.ToColor());
            }
            else 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.GetTextSubstringBounds(
                        ctx.Canvas, m.MessageRect, line.Value,
                        selectionStartIdx, selectionEndIdx, dc.Font,
                        m.OffsetTextRect.X + textXPos, ctx.TextFormat);
                    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();
            }
        }