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); } }
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(); }