コード例 #1
0
        public static void DrawYAxes(LJD.Graphics g, Resources resources, PlotsDrawingData pdd, float yAxesAreaWidth, PlotsViewMetrics m)
        {
            float x    = yAxesAreaWidth;
            var   font = resources.AxesFont;

            foreach (var axis in pdd.YAxes)
            {
                float maxLabelWidth = 0;
                foreach (var p in axis.Points)
                {
                    var pt = new PointF(x - (p.IsMajorMark ? resources.MajorAxisMarkSize : resources.MinorAxisMarkSize), p.Position);
                    g.DrawLine(resources.AxesPen, pt, new PointF(x, p.Position));
                    if (p.Label != null)
                    {
                        g.DrawString(p.Label, font, resources.DataPointLabelBrush, pt, resources.YAxisPointLabelFormat);
                    }
                    maxLabelWidth = Math.Max(maxLabelWidth, g.MeasureString(p.Label ?? "", resources.AxesFont).Width);
                }
                x -= (resources.MajorAxisMarkSize + maxLabelWidth);
                g.PushState();
                g.TranslateTransform(x, m.Size.Height / 2);
                g.RotateTransform(-90);
                g.DrawString(axis.Label, resources.AxesFont, resources.DataPointLabelBrush, new PointF(0, 0), resources.YAxisLabelFormat);
                g.PopState();
                x -= (g.MeasureString(axis.Label, resources.AxesFont).Height + resources.YAxesPadding);
            }
        }
コード例 #2
0
        public IEnumerable <RoleCaptionMetrics> GetRoleCaptionsMetrics(LJD.Graphics g)
        {
            if (eventsHandler == null)
            {
                yield break;
            }

            foreach (var role in eventsHandler.RolesDrawInfo)
            {
                if (role.Bounds.Width < 2)
                {
                    continue;
                }
                var   sz      = g.MeasureString(role.DisplayName, resources.Font, resources.RoleCaptionFormat, role.Bounds.Size);
                float padding = 3;
                sz.Width = Math.Min(
                    Math.Max(sz.Width + padding, role.Bounds.Height),
                    role.Bounds.Width
                    );
                yield return(new RoleCaptionMetrics()
                {
                    DrawInfo = role,
                    Box = new Rectangle(
                        role.X - (int)sz.Width / 2,
                        role.Bounds.Y,
                        (int)sz.Width,
                        role.Bounds.Height
                        ),
                    IsLink = role.LogSourceTrigger != null,
                    IsFocused = role.ContainsFocusedMessage
                });
            }
        }
コード例 #3
0
ファイル: TimelineMetrics.cs プロジェクト: sabrogden/logjoint
        public CaptionsMarginMetrics ComputeCaptionsMarginMetrics(
            LJD.Graphics g,
            IViewModel eventsHandler
            )
        {
            var   viewMetrics  = this;
            float maxTextWidth = 0;
            bool  needsFolding = false;

            if (eventsHandler != null)
            {
                foreach (var a in eventsHandler.OnDrawActivities())
                {
                    if (!string.IsNullOrEmpty(a.SequenceDiagramText))
                    {
                        var w = g.MeasureString(a.SequenceDiagramText, res.ActivitesCaptionsFont).Width;
                        maxTextWidth = Math.Max(maxTextWidth, w);
                    }
                    if (a.IsFolded != null)
                    {
                        needsFolding = true;
                    }
                }
            }
            return(new CaptionsMarginMetrics()
            {
                SequenceDiagramAreaWidth = Math.Min((int)Math.Ceiling(maxTextWidth), viewMetrics.ActivitesCaptionsViewWidth / 2),
                FoldingAreaWidth = needsFolding ? 10 : 0
            });
        }
コード例 #4
0
        void IView.UpdateFontDependentData(string fontName, LogFontSize fontSize)
        {
            if (drawContext.Font != null)
            {
                drawContext.Font.Dispose();
            }

            var oldDpp = drawContext.LineHeight > 0 ? ((IView)this).DisplayLinesPerPage : 0;

            drawContext.Font = new LJD.Font(GetFontFamily(fontName).Name, ToFontEmSize(fontSize));

            using (var nativeGraphics = CreateGraphics())
                using (var tmp = new LJD.Graphics(nativeGraphics))
                {
                    int count = 8 * 1024;
                    drawContext.CharSize = tmp.MeasureString(new string('0', count), drawContext.Font);
                    drawContext.CharWidthDblPrecision = (double)drawContext.CharSize.Width / (double)count;
                    drawContext.CharSize.Width       /= (float)count;
                    drawContext.LineHeight            = (int)Math.Floor(drawContext.CharSize.Height);
                }

            UpdateTimeAreaSize();

            if (oldDpp != 0 && oldDpp != ((IView)this).DisplayLinesPerPage && viewEvents != null)
            {
                viewEvents.OnDisplayLinesPerPageChanged();
            }
        }
コード例 #5
0
 public static IEnumerable <YAxisMetrics> GetYAxesMetrics(LJD.Graphics g, Resources resources, PlotsDrawingData pdd)
 {
     foreach (var axis in pdd.YAxes)
     {
         float maxLabelWidth = 0;
         foreach (var p in axis.Points)
         {
             maxLabelWidth = Math.Max(maxLabelWidth, g.MeasureString(p.Label ?? "", resources.AxesFont).Width);
         }
         float unitTextHeight = g.MeasureString(axis.Label, resources.AxesFont).Height;
         yield return(new YAxisMetrics()
         {
             AxisData = axis,
             Width = resources.MajorAxisMarkSize + maxLabelWidth + unitTextHeight + resources.YAxesPadding
         });
     }
 }
コード例 #6
0
        public static void DrawMeasurer(
            LJD.Graphics g,
            ViewMetrics viewMetrics,
            IViewEvents eventsHandler)
        {
            var drawInfo = eventsHandler.OnDrawMeasurer();

            if (!drawInfo.MeasurerVisible)
            {
                return;
            }
            double viewWidth  = viewMetrics.ActivitiesViewWidth;
            int    viewHeight = viewMetrics.ActivitiesViewHeight;
            var    x1         = Metrics.SafeGetScreenX(drawInfo.X1, viewWidth);
            var    x2         = Metrics.SafeGetScreenX(drawInfo.X2, viewWidth);

            g.DrawLine(viewMetrics.MeasurerPen, x1, viewMetrics.MeasurerTop, x1, viewHeight);
            g.DrawLine(viewMetrics.MeasurerPen, x2, viewMetrics.MeasurerTop, x2, viewHeight);
            g.DrawLine(viewMetrics.MeasurerPen, x1, viewMetrics.MeasurerTop, x2, viewMetrics.MeasurerTop);
            var        textSz = g.MeasureString(drawInfo.Text, viewMetrics.MeasurerTextFont);
            RectangleF textRect;
            int        textHPadding = 2;

            if (textSz.Width < (x2 - x1 - 5))
            {
                textRect = new RectangleF(
                    (x2 + x1 - textSz.Width - textHPadding) / 2,
                    viewMetrics.MeasurerTop - textSz.Height / 2,
                    textSz.Width + textHPadding,
                    textSz.Height
                    );
            }
            else
            {
                textRect = new RectangleF(
                    x2 + 5,
                    viewMetrics.MeasurerTop - textSz.Height / 2,
                    textSz.Width + textHPadding,
                    textSz.Height
                    );
                if (textRect.Right > viewMetrics.ActivitiesViewWidth)
                {
                    textRect.X = x1 - 5 - textRect.Width;
                }
            }
            g.FillRectangle(viewMetrics.MeasurerTextBoxBrush, textRect);
            g.DrawRectangle(viewMetrics.MeasurerTextBoxPen, new RectangleF(textRect.X, textRect.Y, textRect.Width, textRect.Height));
            g.DrawString(drawInfo.Text,
                         viewMetrics.MeasurerTextFont, viewMetrics.MeasurerTextBrush,
                         new PointF((textRect.X + textRect.Right) / 2, (textRect.Y + textRect.Bottom) / 2),
                         viewMetrics.MeasurerTextFormat);
        }
コード例 #7
0
        public static void DrawXAxis(LJD.Graphics g, Resources resources, PlotsDrawingData pdd, float height)
        {
            var majorMarkerHeight = (height - g.MeasureString("123", resources.AxesFont).Height) * 3f / 4f;
            var minorMarkerHeight = majorMarkerHeight / 2f;

            foreach (var x in pdd.XAxis.Points)
            {
                g.DrawLine(
                    resources.AxesPen,
                    new PointF(x.Position, 0),
                    new PointF(x.Position, x.IsMajorMark ? majorMarkerHeight : minorMarkerHeight)
                    );
                g.DrawString(x.Label, resources.AxesFont, resources.DataPointLabelBrush, new PointF(x.Position, height), resources.XAxisPointLabelFormat);
            }
        }
コード例 #8
0
        void IView.UpdateFontDependentData(string fontName, Appearance.LogFontSize fontSize)
        {
            if (drawContext.Font != null)
            {
                drawContext.Font.Dispose();
            }

            drawContext.Font = new LJD.Font("monaco", 12);

            using (var tmp = new LJD.Graphics())             // todo: consider reusing with windows
            {
                int count = 8 * 1024;
                drawContext.CharSize = tmp.MeasureString(new string('0', count), drawContext.Font);
                drawContext.CharWidthDblPrecision = (double)drawContext.CharSize.Width / (double)count;
                drawContext.CharSize.Width       /= (float)count;
                drawContext.LineHeight            = (int)Math.Floor(drawContext.CharSize.Height);
            }

            UpdateTimeAreaSize();
        }
コード例 #9
0
        public static int GetSequenceDiagramAreaMetrics(
            LJD.Graphics g,
            ViewMetrics viewMetrics,
            IViewEvents eventsHandler
            )
        {
            float maxTextWidth = 0;

            if (eventsHandler != null)
            {
                foreach (var a in eventsHandler.OnDrawActivities())
                {
                    if (!string.IsNullOrEmpty(a.SequenceDiagramText))
                    {
                        var w = g.MeasureString(a.SequenceDiagramText, viewMetrics.ActivitesCaptionsFont).Width;
                        maxTextWidth = Math.Max(maxTextWidth, w);
                    }
                }
            }
            return(Math.Min((int)Math.Ceiling(maxTextWidth), viewMetrics.ActivitesCaptionsViewWidth / 2));
        }
コード例 #10
0
        public static void DrawPlotsArea(
            LJD.Graphics g,
            Resources resources,
            PlotsDrawingData pdd,
            PlotsViewMetrics m
            )
        {
            g.DrawRectangle(resources.AxesPen, new RectangleF(new PointF(), m.Size));

            foreach (var x in pdd.XAxis.Points)
            {
                g.DrawLine(resources.GridPen, new PointF(x.Position, 0), new PointF(x.Position, m.Size.Height));
            }

            g.PushState();
            g.EnableAntialiasing(true);
            foreach (var s in pdd.TimeSeries)
            {
                var  pen       = resources.GetTimeSeriesPen(s.Color);
                var  prevPt    = new PointF();
                bool isFirstPt = true;
                foreach (var pt in s.Points)
                {
                    if (!isFirstPt && s.DrawLine)
                    {
                        g.DrawLine(pen, prevPt, pt);
                    }
                    prevPt = pt;
                    DrawPlotMarker(g, resources, pen, pt, s.Marker);
                    isFirstPt = false;
                }
            }
            foreach (var e in pdd.Events)
            {
                if ((e.Type & EventDrawingData.EventType.Group) != 0)
                {
                    var captionSz = g.MeasureString(e.Text, resources.GroupCaptionFont);
                    var round     = 2f;
                    captionSz.Width  += round * 2;
                    captionSz.Height += round * 2;
                    var captionRect = new RectangleF(
                        e.X + e.Width / 2 - captionSz.Width / 2, 1, captionSz.Width, captionSz.Height);
                    var vertLineRect = new RectangleF(e.X, captionRect.Top, e.Width, m.Size.Height);

                    if ((e.Type & EventDrawingData.EventType.ParsedEvent) != 0)
                    {
                        g.FillRectangle(resources.ParsedEventsGroupBrush, vertLineRect);
                    }
                    if ((e.Type & EventDrawingData.EventType.Bookmark) != 0)
                    {
                        g.FillRectangle(resources.BookmarksGroupGrush, vertLineRect);
                    }

                    g.FillRoundRectangle(LJD.Brushes.Red, captionRect, round);
                    g.DrawRoundRectangle(LJD.Pens.White, captionRect, round);
                    g.DrawString(e.Text, resources.GroupCaptionFont, LJD.Brushes.White,
                                 new PointF(captionRect.X + round, captionRect.Y + round));
                }
                else
                {
                    LJD.Pen   pen;
                    LJD.Brush brush;
                    LJD.Image icon;
                    if ((e.Type & EventDrawingData.EventType.Bookmark) != 0)
                    {
                        pen   = resources.BookmarkPen;
                        brush = resources.BookmarkBrush;
                        icon  = resources.BookmarkIcon;
                    }
                    else
                    {
                        pen   = resources.ParsedEventPen;
                        brush = resources.ParsedEventBrush;
                        icon  = resources.ParsedEventIcon;
                    }
                    g.DrawLine(pen, new PointF(e.X, 0), new PointF(e.X, m.Size.Height));
                    if (icon != null)
                    {
                        float iconWidth = 10;                         // todo: hardcoded
                        g.DrawImage(icon, new RectangleF(
                                        e.X - iconWidth / 2, 1, iconWidth, iconWidth * icon.Height / icon.Width));
                    }
                    if (e.Text != null)
                    {
                        g.PushState();
                        g.TranslateTransform(e.X, 6);
                        g.RotateTransform(-90);
                        g.DrawString(e.Text, resources.EventTextFont, brush,
                                     new PointF(), resources.EventTextFormat);
                        g.PopState();
                    }
                }
            }
            g.PopState();

            if (pdd.FocusedMessageX != null)
            {
                g.DrawLine(LJD.Pens.Blue, new PointF(pdd.FocusedMessageX.Value, 0), new PointF(pdd.FocusedMessageX.Value, m.Size.Height));
            }

            pdd.UpdateThrottlingWarning();
        }
コード例 #11
0
ファイル: TimelineMetrics.cs プロジェクト: sabrogden/logjoint
        public IEnumerable <EventMetrics> GetEventMetrics(LJD.Graphics g, IViewModel eventsHandler)
        {
            var    viewMetrics            = this;
            double availableWidth         = viewMetrics.ActivitiesViewWidth;
            int    lastEventRight         = int.MinValue;
            int    overlappingEventsCount = 0;

            foreach (var evt in eventsHandler.OnDrawEvents(DrawScope.VisibleRange))
            {
                if (evt.X < 0 || evt.X > 1)
                {
                    continue;
                }

                EventMetrics m = new EventMetrics()
                {
                    Event = evt
                };

                int eventLineTop = viewMetrics.RulersPanelHeight - 2;
                var szF          = g.MeasureString(evt.Caption, res.ActionCaptionFont);
                var sz           = new Size((int)szF.Width, (int)szF.Height);
                int x            = SafeGetScreenX(evt.X, availableWidth);
                var bounds       = new Rectangle(x - sz.Width / 2, eventLineTop - sz.Height, sz.Width, sz.Height);
                bounds.Inflate(2, 0);
                if (bounds.Left < lastEventRight)
                {
                    ++overlappingEventsCount;
                    bounds.Offset(lastEventRight - bounds.Left + 2, 0);
                    var mid = (bounds.Left + bounds.Right) / 2;
                    var y2  = eventLineTop + 5 * overlappingEventsCount;
                    m.VertLinePoints = new Point[]
                    {
                        new Point(mid, eventLineTop),
                        new Point(mid, y2),
                        new Point(x, y2),
                        new Point(x, viewMetrics.ActivitiesViewHeight)
                    };
                }
                else
                {
                    overlappingEventsCount = 0;
                    m.VertLineA            = new Point(x, eventLineTop);
                    m.VertLineB            = new Point(x, viewMetrics.ActivitiesViewHeight);
                }
                m.CaptionRect          = bounds;
                m.CaptionDrawingOrigin = new Point((bounds.Left + bounds.Right) / 2, eventLineTop);

                if (evt.Type == EventType.UserAction)
                {
                    m.Icon = res.UserIcon;
                }
                else if (evt.Type == EventType.APICall)
                {
                    m.Icon = res.APIIcon;
                }
                if (m.Icon != null)
                {
                    var imgsz = m.Icon.GetSize(height: 14f).Scale(viewMetrics.DPIScale);
                    m.IconRect = new RectangleF(
                        m.CaptionDrawingOrigin.X - imgsz.Width / 2,
                        viewMetrics.RulersPanelHeight - imgsz.Height - viewMetrics.ActionLebelHeight,
                        imgsz.Width, imgsz.Height
                        );
                }

                lastEventRight = bounds.Right;

                yield return(m);
            }
        }
コード例 #12
0
        public void DrawArrowsView(LJD.Graphics g, Size viewSize, Action <Rectangle> drawFocusRect)
        {
            foreach (var message in eventsHandler.ArrowsDrawInfo)
            {
                if (!message.IsFullyVisible)
                {
                    continue;
                }
                if (message.SelectionState != ArrowSelectionState.NotSelected)
                {
                    int y = message.Y;
                    int h = message.Height;
                    var r = new Rectangle(
                        0, y - h + 2,
                        viewSize.Width, h - 2
                        );
                    g.FillRectangle(resources.SelectedLineBrush, r);
                    if (message.SelectionState == ArrowSelectionState.FocusedSelectedArrow)
                    {
                        drawFocusRect(r);
                    }
                }
            }

            foreach (var role in eventsHandler.RolesDrawInfo)
            {
                var x = role.X;
                g.DrawLine(resources.RolePen, x, 0, x, viewSize.Height);
                foreach (var eo in role.ExecutionOccurrences)
                {
                    LJD.Brush fillBrush;
                    if (eo.DrawMode == ExecutionOccurrenceDrawMode.Normal)
                    {
                        fillBrush = eo.IsHighlighted ? resources.NormalHighlightedExecutionOccurrenceBrush : resources.NormalExecutionOccurrenceBrush;
                    }
                    else if (eo.DrawMode == ExecutionOccurrenceDrawMode.Activity)
                    {
                        fillBrush = eo.IsHighlighted ? resources.ActivityHighlightedExecutionOccurrenceBrush : resources.ActivityExecutionOccurrenceBrush;
                    }
                    else
                    {
                        continue;
                    }
                    g.FillRectangle(fillBrush, eo.Bounds);
                    g.DrawRectangle(eo.IsHighlighted ? resources.HighlightedExecutionOccurrencePen : resources.ExecutionOccurrencePen, eo.Bounds);
                }
            }

            Action <string, LJD.Brush, LJD.Brush, RectangleF> drawTextHelper = (str, back, fore, textRect) =>
            {
                if (back != null)
                {
                    var fillSz   = g.MeasureString(str, resources.Font, resources.ArrowTextFormat, textRect.Size);
                    var fillRect = new RectangleF(textRect.X, textRect.Y + 4, fillSz.Width, textRect.Height - 5);
                    g.FillRectangle(back, fillRect);
                }
                g.DrawString(str, resources.Font, fore, textRect, resources.ArrowTextFormat);
            };

            Action <PointF, bool> drawArrow = (pt, leftToRight) => {
                var pts = new List <PointF>(4);
                pts.Add(pt);
                foreach (var p in resources.ArrowEndShapePoints)
                {
                    pts.Add(new PointF(pt.X + (leftToRight ? 1f : -1f) * p.X, pt.Y + p.Y));
                }
                g.FillPolygon(resources.NormalArrowTextBrush, pts.ToArray());
            };

            foreach (var message in eventsHandler.ArrowsDrawInfo)
            {
                int y         = message.Y;
                int x1        = message.FromX;
                int x2        = message.ToX;
                int h         = message.Height;
                int w         = message.Width;
                int padding   = message.TextPadding;
                var backBrush = message.SelectionState != ArrowSelectionState.NotSelected ? resources.SelectedLineBrush : resources.ControlBackgroundBrush;
                var textBrush = message.Color == ArrowColor.Error ? resources.ErrorArrowTextBrush : resources.NormalArrowTextBrush;

                if (message.Mode == ArrowDrawMode.Arrow ||
                    message.Mode == ArrowDrawMode.DottedArrow)
                {
                    var pen = !message.IsHighlighted ?
                              (message.Mode == ArrowDrawMode.Arrow ? resources.RequestPen : resources.ResponsePen) :
                              (message.Mode == ArrowDrawMode.Arrow ? resources.HighlightedRequestPen : resources.HighlightedResponsePen);
                    if (x1 != x2)
                    {
                        if (message.IsFullyVisible)
                        {
                            drawTextHelper(
                                message.DisplayName,
                                backBrush,
                                textBrush,
                                new RectangleF(
                                    Math.Min(x1, x2) + padding, y - h,
                                    Math.Abs(x1 - x2) - padding * 2, h
                                    )
                                );
                        }

                        var nonHorizontal = message.NonHorizontalDrawingData;
                        if (nonHorizontal != null)
                        {
                            g.DrawLines(
                                pen,
                                new[]
                            {
                                new Point(x1, y),
                                new Point(nonHorizontal.VerticalLineX, y),
                                new Point(nonHorizontal.VerticalLineX, nonHorizontal.Y),
                                new Point(nonHorizontal.ToX, nonHorizontal.Y)
                            }
                                );
                            drawArrow(new PointF(nonHorizontal.ToX, nonHorizontal.Y), x2 > x1);
                        }
                        else
                        {
                            if (message.IsFullyVisible)
                            {
                                g.DrawLine(
                                    pen,
                                    x1, y,
                                    x2, y
                                    );
                                drawArrow(new PointF(x2, y), x2 > x1);
                            }
                        }
                    }
                    else
                    {
                        var midY  = y - h / 2;
                        var loopW = 10;
                        var loopH = 10;

                        drawTextHelper(
                            message.DisplayName,
                            backBrush,
                            textBrush,
                            new RectangleF(
                                x1 + loopW + padding, y - h,
                                message.Width - (loopW + padding * 2), h
                                )
                            );

                        g.DrawLines(
                            pen,
                            new[]
                        {
                            new Point(x1, midY - loopH / 2),
                            new Point(x1 + loopW, midY - loopH / 2),
                            new Point(x1 + loopW, midY + loopH / 2),
                            new Point(x1, midY + loopH / 2),
                        }
                            );
                        drawArrow(new PointF(x1, midY + loopH / 2), false);
                    }
                }
                else if (message.Mode == ArrowDrawMode.Bookmark)
                {
                    if (!message.IsFullyVisible)
                    {
                        continue;
                    }
                    float radius   = h / 4f;
                    var   textRect = new RectangleF(
                        message.MinX - w / 2 + padding, y - h,
                        (message.MaxX - message.MinX + w) - padding * 2, h
                        );
                    var sz = g.MeasureString("ABC", resources.Font, resources.ArrowTextFormat, textRect.Size).ToSize();
                    var r  = new RectangleF(textRect.X, y - sz.Height - 1, textRect.Width, sz.Height);
                    r.Inflate(radius, 0);

                    g.PushState();
                    g.EnableAntialiasing(true);
                    g.FillRoundRectangle(resources.BookmarkArrowBackgroundBrush, r, radius);
                    g.DrawRoundRectangle(resources.BookmarkArrowPen, r, radius);
                    g.PopState();

                    SizeF q = new SizeF(3, 3).Scale(resources.DpiScale);
                    if (x1 - q.Width > r.Left && x1 + q.Width < r.Right)
                    {
                        PointF[] pts;

                        pts = new []
                        {
                            new PointF(x1 - q.Width, r.Top + r.Height / 2),
                            new PointF(x1 - q.Width, r.Top),
                            new PointF(x1, r.Top - q.Height),
                            new PointF(x1 + q.Width, r.Top),
                            new PointF(x1 + q.Width, r.Top + r.Height / 2),
                        };
                        g.FillPolygon(resources.BookmarkArrowBackgroundBrush, pts);
                        g.DrawLines(resources.BookmarkArrowPen, pts.Skip(1).Take(3).ToArray());

                        pts = new []
                        {
                            new PointF(x1 + q.Width, r.Bottom - r.Height / 2),
                            new PointF(x1 + q.Width, r.Bottom),
                            new PointF(x1, r.Bottom + q.Height),
                            new PointF(x1 - q.Width, r.Bottom),
                            new PointF(x1 - q.Width, r.Bottom - r.Height / 2),
                        };
                        g.FillPolygon(resources.BookmarkArrowBackgroundBrush, pts);
                        g.DrawLines(resources.BookmarkArrowPen, pts.Skip(1).Take(3).ToArray());
                    }

                    drawTextHelper(
                        message.DisplayName,
                        null,
                        textBrush,
                        textRect
                        );
                }
                else if (message.Mode == ArrowDrawMode.UserAction ||
                         message.Mode == ArrowDrawMode.StateChange ||
                         message.Mode == ArrowDrawMode.APICall ||
                         message.Mode == ArrowDrawMode.ActivityLabel)
                {
                    if (!message.IsFullyVisible)
                    {
                        continue;
                    }
                    var   icon   = message.Mode == ArrowDrawMode.UserAction ? resources.UserActionImage : null;
                    float radius = h / 4f;
                    var   r      = new RectangleF(
                        x1 - (w - radius), y - h,
                        (w - radius) * 2, h
                        );
                    var sz      = g.MeasureString(message.DisplayName, resources.Font, resources.UserActionTextFormat, r.Size);
                    var szh     = sz.Height;
                    var boxRect = new RectangleF(
                        x1 - sz.Width / 2, y - szh - 1,
                        sz.Width, szh
                        );
                    boxRect.Inflate(radius, 0);
                    g.PushState();
                    g.EnableAntialiasing(true);
                    LJD.Brush backgroundBrush = null;
                    LJD.Pen   strokePen       = resources.UserActionFramePen;
                    if (message.Mode == ArrowDrawMode.UserAction || message.Mode == ArrowDrawMode.APICall)
                    {
                        backgroundBrush = resources.UserActionBrush;
                    }
                    else if (message.Mode == ArrowDrawMode.StateChange)
                    {
                        backgroundBrush = resources.StateChangeBrush;
                    }
                    else if (message.Mode == ArrowDrawMode.ActivityLabel)
                    {
                        backgroundBrush = resources.ActivityExecutionOccurrenceBrush;
                        if (message.IsHighlighted)
                        {
                            strokePen = resources.HighlightedExecutionOccurrencePen;
                        }
                    }
                    g.FillRoundRectangle(
                        backgroundBrush,
                        boxRect,
                        radius
                        );
                    g.DrawRoundRectangle(
                        strokePen,
                        boxRect,
                        radius
                        );
                    g.PopState();
                    g.DrawString(message.DisplayName, resources.Font,
                                 textBrush, boxRect, resources.UserActionTextFormat);
                    if (icon != null)
                    {
                        var iconsz = icon.GetSize(width: 10f).Scale(resources.DpiScale);
                        g.DrawImage(
                            icon,
                            new RectangleF(
                                (int)(boxRect.Left - iconsz.Width * 1.3f),
                                (int)(boxRect.Y + (boxRect.Height - iconsz.Height) / 2),
                                iconsz.Width,
                                iconsz.Height
                                )
                            );
                    }
                }
            }
        }
コード例 #13
0
        void UpdateViewMetrics()
        {
            viewMetrics.RulersPanelHeight           = (int)searchTextBoxPlaceholder.Frame.Bottom;
            viewMetrics.ActivitiesViewWidth         = (int)activitiesView.Bounds.Width;
            viewMetrics.ActivitiesViewHeight        = (int)activitiesView.Bounds.Height;
            viewMetrics.ActivitesCaptionsViewWidth  = (int)captionsView.Bounds.Width;
            viewMetrics.ActivitesCaptionsViewHeight = (int)captionsView.Bounds.Height;
            viewMetrics.NavigationPanelWidth        = (int)navigatorView.Bounds.Width;
            viewMetrics.NavigationPanelHeight       = (int)navigatorView.Bounds.Height;

            if (viewMetrics.LineHeight == 0)              // very first update
            {
                var sysFont    = NSFont.SystemFontOfSize(NSFont.SystemFontSize);
                var normalFont = new LJD.Font(sysFont.FamilyName, (float)NSFont.SystemFontSize);
                var smallFont  = new LJD.Font(sysFont.FamilyName, (float)NSFont.SmallSystemFontSize);

                using (var g = new LJD.Graphics())
                    viewMetrics.LineHeight = (int)g.MeasureString("ABC012", normalFont).Height;

                viewMetrics.ActivitesCaptionsFont  = normalFont;
                viewMetrics.ActivitesCaptionsBrush = new LJD.Brush(Color.Black);

                var selectedLineColor = Color.FromArgb(187, 196, 221);
                viewMetrics.SelectedLineBrush = new LJD.Brush(selectedLineColor);
                viewMetrics.ErrorLineBrush    = new LJD.Brush(Color.FromArgb(255, 255, 170, 170));

                viewMetrics.RulerLinePen   = new LJD.Pen(Color.LightGray, 1);
                viewMetrics.RulerMarkFont  = smallFont;
                viewMetrics.RulerMarkBrush = new LJD.Brush(Color.Black);

                viewMetrics.ActivitiesTopBoundPen = new LJD.Pen(Color.Gray, 1);

                viewMetrics.ProcedureBrush         = new LJD.Brush(Color.LightBlue);
                viewMetrics.LifetimeBrush          = new LJD.Brush(Color.LightGreen);
                viewMetrics.NetworkMessageBrush    = new LJD.Brush(Color.LightSalmon);
                viewMetrics.UnknownActivityBrush   = new LJD.Brush(Color.LightGray);
                viewMetrics.MilestonePen           = new LJD.Pen(Color.FromArgb(180, Color.SteelBlue), 3);
                viewMetrics.ActivityBarBoundsPen   = new LJD.Pen(Color.Gray, 0.5f);
                viewMetrics.ActivitiesConnectorPen = new LJD.Pen(Color.DarkGray, 1, new [] { 1f, 1f });
                viewMetrics.PhaseBrushes           = new LJD.Brush[]
                {
                    new LJD.Brush(Color.FromArgb(255, 170, 170, 170)),
                    new LJD.Brush(Color.FromArgb(255, 0, 150, 136)),
                    new LJD.Brush(Color.FromArgb(255, 63, 72, 204)),
                    new LJD.Brush(Color.FromArgb(255, 34, 175, 76)),
                };


                viewMetrics.UserEventPen             = new LJD.Pen(Color.Salmon, 2);
                viewMetrics.EventRectBrush           = new LJD.Brush(Color.Salmon);
                viewMetrics.EventRectPen             = new LJD.Pen(Color.Gray, 1);
                viewMetrics.EventCaptionBrush        = new LJD.Brush(Color.Black);
                viewMetrics.EventCaptionFont         = smallFont;
                viewMetrics.ActionLebelHeight        = 17;
                viewMetrics.EventCaptionStringFormat = new LJD.StringFormat(StringAlignment.Center, StringAlignment.Far);
                viewMetrics.ActionCaptionFont        = smallFont;

                viewMetrics.BookmarkPen  = new LJD.Pen(Color.FromArgb(0x5b, 0x87, 0xe0), 1);
                viewMetrics.BookmarkIcon = new LJD.Image(NSImage.ImageNamed("TimelineBookmark.png"));
                viewMetrics.UserIcon     = new LJD.Image(NSImage.ImageNamed("UserAction.png"));
                viewMetrics.APIIcon      = new LJD.Image(NSImage.ImageNamed("APICall.png"));

                viewMetrics.FocusedMessageLineTop = new LJD.Image(NSImage.ImageNamed("FocusedMsgSlaveVert.png"));
                viewMetrics.FocusedMessagePen     = new LJD.Pen(Color.Blue, 1);

                viewMetrics.MeasurerTop          = 25;
                viewMetrics.MeasurerPen          = new LJD.Pen(Color.DarkGreen, 1f, new[] { 4f, 2f });
                viewMetrics.MeasurerTextFont     = smallFont;
                viewMetrics.MeasurerTextBrush    = new LJD.Brush(Color.Black);
                viewMetrics.MeasurerTextBoxBrush = new LJD.Brush(Color.White);
                viewMetrics.MeasurerTextBoxPen   = new LJD.Pen(Color.DarkGreen, 1f);
                viewMetrics.MeasurerTextFormat   = new LJD.StringFormat(StringAlignment.Center, StringAlignment.Center);

                viewMetrics.NavigationPanel_InvisibleBackground = new LJD.Brush(Color.FromArgb(235, 235, 235));
                viewMetrics.NavigationPanel_VisibleBackground   = new LJD.Brush(Color.White);
                viewMetrics.VisibleRangePen    = new LJD.Pen(Color.Gray, 1f);
                viewMetrics.SystemControlBrush = viewMetrics.NavigationPanel_InvisibleBackground;

                viewMetrics.ActivityBarRectPaddingY    = 5;
                viewMetrics.TriggerLinkWidth           = 8;
                viewMetrics.DistnanceBetweenRulerMarks = 40;
                viewMetrics.VisibleRangeResizerWidth   = 8;
            }

            viewMetrics.VScrollBarValue = (int)(vertScroller.DoubleValue * VertScrollerValueRange);
        }