示例#1
0
        public static IEnumerable <ViewLine> GetVisibleMessagesIterator(DrawContext drawContext, IPresentationDataAccess presentationDataAccess, Rectangle viewRect)
        {
            var vl = DrawingUtils.GetVisibleMessages(drawContext, presentationDataAccess, viewRect);

            return(presentationDataAccess.GetViewLines(vl.begin, vl.end));
        }
示例#2
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();
            }
        }