/// <summary> /// Draws the series using the <see cref="IRenderContext2D" /> and the <see cref="IRenderPassData" /> passed in /// </summary> /// <param name="renderContext">The render context. This is a graphics object which has methods to draw lines, quads and polygons to the screen</param> /// <param name="renderPassData">The render pass data. Contains a resampled /// <see cref="IPointSeries" />, the /// <see cref="IndexRange" /> of points on the screen /// and the current YAxis and XAxis /// <see cref="ICoordinateCalculator{T}" /> to convert data-points to screen points</param> protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { base.Draw(renderContext, renderPassData); // Get the data from RenderPassData. See CustomRenderableSeries article which describes PointSeries relationship to DataSeries if (renderPassData.PointSeries.Count == 0) { return; } // Convert to Spline Series _splineSeries = ComputeSplineSeries(renderPassData.PointSeries, IsSplineEnabled, UpSampleFactor); // Get the coordinates of the first dataPoint var point = GetCoordinatesFor(_splineSeries[0].X, _splineSeries[0].Y); // Create a pen to draw the spline line. Make sure you dispose it! using (var linePen = renderContext.CreatePen(this.Stroke, this.AntiAliasing, this.StrokeThickness)) { // Create a line drawing context. Make sure you dispose it! // NOTE: You can create mutliple line drawing contexts to draw segments if you want // You can also call renderContext.DrawLine() and renderContext.DrawLines(), but the lineDrawingContext is higher performance using (var lineDrawingContext = renderContext.BeginLine(linePen, point.X, point.Y)) { for (int i = 1; i < _splineSeries.Count; i++) { point = GetCoordinatesFor(_splineSeries[i].X, _splineSeries[i].Y); lineDrawingContext.MoveTo(point.X, point.Y); } } } DrawPointMarkers(renderContext, renderPassData.PointSeries); }
private void CustomDraw(IRenderContext2D renderContext) { foreach (var p in polygonList) { Polygon polygon = p.Value.polygon; if (polygon.Points.Count > 0) { Point initialPoint = GetRenderingPoint(polygon.Points[0]); System.Windows.Media.Color backgroundColor = System.Windows.Media.Color.FromArgb(p.Value.backgroundColor.A, p.Value.backgroundColor.R, p.Value.backgroundColor.G, p.Value.backgroundColor.B); using (var brush = renderContext.CreateBrush(backgroundColor)) { //IEnumerable<Point> points; // define your points renderContext.FillPolygon(brush, GetRenderingPoints(polygon.Points)); } //// Create a pen to draw. Make sure you dispose it! System.Windows.Media.Color borderColor = System.Windows.Media.Color.FromArgb(p.Value.borderColor.A, p.Value.borderColor.R, p.Value.borderColor.G, p.Value.borderColor.B); using (var linePen = renderContext.CreatePen(borderColor, this.AntiAliasing, p.Value.borderWidth, p.Value.borderOpacity, p.Value.borderDashPattern)) { using (var lineDrawingContext = renderContext.BeginLine(linePen, initialPoint.X, initialPoint.Y)) { for (int i = 1; i < polygon.Points.Count; i++) { lineDrawingContext.MoveTo(GetRenderingPoint(polygon.Points[i]).X, GetRenderingPoint(polygon.Points[i]).Y); } lineDrawingContext.End(); } } } } }
private void CustomDraw(IRenderContext2D renderContext) { foreach (var s in segmentList) { Point initialPoint = GetRenderingPoint(new Point(s.Segment.X1, s.Segment.Y1)); Point endPoint = GetRenderingPoint(new Point(s.Segment.X2, s.Segment.Y2)); System.Windows.Media.Color segmentColor = System.Windows.Media.Color.FromArgb(s.Color.A, s.Color.R, s.Color.G, s.Color.B); /// Create a pen to draw. Make sure you dispose it! using (var linePen = renderContext.CreatePen(segmentColor, this.AntiAliasing, (float)s.Width, s.Opacity, s.DashPattern)) { using (var lineDrawingContext = renderContext.BeginLine(linePen, initialPoint.X, initialPoint.Y)) { lineDrawingContext.MoveTo(endPoint.X, endPoint.Y); lineDrawingContext.End(); } } } }
protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { base.Draw(renderContext, renderPassData); // Create a line drawing context. Make sure you dispose it! // NOTE: You can create mutliple line drawing contexts to draw segments if you want // You can also call renderContext.DrawLine() and renderContext.DrawLines(), but the lineDrawingContext is higher performance foreach (var p in polygonList) { Polygon polygon = p.Value.polygon; if (polygon.Points.Count > 0) { Point initialPoint = GetRenderingPoint(polygon.Points[0]); System.Windows.Media.Color backgroundColor = System.Windows.Media.Color.FromArgb(p.Value.backgroundColor.A, p.Value.backgroundColor.R, p.Value.backgroundColor.G, p.Value.backgroundColor.B); using (var brush = renderContext.CreateBrush(backgroundColor)) { //IEnumerable<Point> points; // define your points renderContext.FillPolygon(brush, GetRenderingPoints(polygon.Points)); } //// Create a pen to draw. Make sure you dispose it! System.Windows.Media.Color borderColor = System.Windows.Media.Color.FromArgb(p.Value.borderColor.A, p.Value.borderColor.R, p.Value.borderColor.G, p.Value.borderColor.B); using (var linePen = renderContext.CreatePen(borderColor, this.AntiAliasing, p.Value.borderWidth, p.Value.borderOpacity, p.Value.borderDashPattern)) { using (var lineDrawingContext = renderContext.BeginLine(linePen, initialPoint.X, initialPoint.Y)) { for (int i = 1; i < polygon.Points.Count; i++) { lineDrawingContext.MoveTo(GetRenderingPoint(polygon.Points[i]).X, GetRenderingPoint(polygon.Points[i]).Y); } lineDrawingContext.End(); } } } } }