/// <summary> /// Renders the series on the specified rendering context. /// </summary> /// <param name="rc">The rendering context.</param> /// <param name="model">The owner plot model.</param> public override void Render(IRenderContext rc, PlotModel model) { if (Points.Count == 0) { return; } if (Points.Count % 2 != 0) { throw new InvalidOperationException("The number of points should be even."); } if (this.XAxis == null || this.YAxis == null) { throw new InvalidOperationException("Axis has not been defined."); } var clippingRect = GetClippingRect(); IList <ScreenPoint> screenPoints = //TEST Points.Select<IDataPoint, ScreenPoint>(this.Transform).ToList(); Alt.EnumerableHelper.ToList(Alt.EnumerableHelper.Select <IDataPoint, ScreenPoint>(Points, this.Transform)); var verticalLines = new List <ScreenPoint>(); for (int i = 0; i < screenPoints.Count; i += 2) { if (screenPoints[i].DistanceToSquared(screenPoints[i + 1]) < this.StrokeThickness) { screenPoints[i] = new ScreenPoint(screenPoints[i].X - (this.StrokeThickness * 0.5), screenPoints[i].Y); screenPoints[i + 1] = new ScreenPoint(screenPoints[i].X + (this.StrokeThickness * 0.5), screenPoints[i].Y); } if (this.ShowVerticals && i > 0 && Math.Abs(screenPoints[i - 1].X - screenPoints[i].X) < this.Epsilon) { verticalLines.Add(screenPoints[i - 1]); verticalLines.Add(screenPoints[i]); } } //TEST rc.DrawClippedLineSegments(screenPoints, clippingRect, this.ActualColor, this.StrokeThickness, this.LineStyle, this.LineJoin, false); RenderingExtensions.DrawClippedLineSegments(rc, screenPoints, clippingRect, this.ActualColor, this.StrokeThickness, this.LineStyle, this.LineJoin, false); //TEST rc.DrawClippedLineSegments(verticalLines, clippingRect, this.ActualColor, this.StrokeThickness / 3, LineStyle.Dash, this.LineJoin, false); RenderingExtensions.DrawClippedLineSegments(rc, verticalLines, clippingRect, this.ActualColor, this.StrokeThickness / 3, LineStyle.Dash, this.LineJoin, false); //TEST rc.DrawMarkers(screenPoints, clippingRect, this.MarkerType, null, this.MarkerSize, this.MarkerFill, this.MarkerStroke, this.MarkerStrokeThickness); RenderingExtensions.DrawMarkers(rc, screenPoints, clippingRect, this.MarkerType, null, this.MarkerSize, this.MarkerFill, this.MarkerStroke, this.MarkerStrokeThickness); }
/// <summary> /// Renders the series on the specified render context. /// </summary> /// <param name="rc">The rendering context.</param> /// <param name="model">The model.</param> public override void Render(IRenderContext rc, PlotModel model) { if (this.Matrix == null) { return; } int m = this.Matrix.GetLength(0); int n = this.Matrix.GetLength(1); var p0 = this.Transform(0, 0); var p1 = this.Transform(n, m); if (this.image == null) { var pixels = new OxyColor[m, n]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { pixels[i, j] = Math.Abs(this.Matrix[m - 1 - i, j]) <= this.ZeroTolerance ? OxyColors.Transparent : this.NotZeroColor; } } this.image = OxyImage.PngFromArgb(pixels); } var clip = this.GetClippingRect(); var x0 = Math.Min(p0.X, p1.X); var y0 = Math.Min(p0.Y, p1.Y); var w = Math.Abs(p0.X - p1.X); var h = Math.Abs(p0.Y - p1.Y); //TEST rc.DrawClippedImage(clip, this.image, x0, y0, w, h, 1, false); RenderingExtensions.DrawClippedImage(rc, clip, this.image, x0, y0, w, h, 1, false); var points = new List <ScreenPoint>(); if (this.GridInterval > 0) { var p2 = this.Transform(this.GridInterval, this.GridInterval); if (Math.Abs(p2.Y - p0.Y) > this.MinimumGridLineDistance) { for (int i = 1; i < n; i += this.GridInterval) { points.Add(this.Transform(0, i)); points.Add(this.Transform(n, i)); } } if (Math.Abs(p2.X - p0.X) > this.MinimumGridLineDistance) { for (int j = 1; j < m; j += this.GridInterval) { points.Add(this.Transform(j, 0)); points.Add(this.Transform(j, m)); } } } if (this.ShowDiagonal) { points.Add(this.Transform(0, 0)); points.Add(this.Transform(n, m)); } //TEST rc.DrawClippedLineSegments(points, clip, this.GridColor, 1, LineStyle.Solid, OxyPenLineJoin.Miter, true); RenderingExtensions.DrawClippedLineSegments(rc, points, clip, this.GridColor, 1, LineStyle.Solid, OxyPenLineJoin.Miter, true); if (this.BorderColor != null) { var borderPoints = new List <ScreenPoint> { this.Transform(0, 0), this.Transform(m, 0), this.Transform(0, n), this.Transform(m, n), this.Transform(0, 0), this.Transform(0, n), this.Transform(m, 0), this.Transform(m, n) }; //TEST rc.DrawClippedLineSegments( RenderingExtensions.DrawClippedLineSegments(rc, borderPoints, clip, this.BorderColor, 1, LineStyle.Solid, OxyPenLineJoin.Miter, true); } }