private void AddElements() { if ((bool)GetValue(UseDirect2DProperty) == false) { line.Data = LineGeometries.PathGeometryFromCurve(curve, null); line.SetValue(Canvas.ZIndexProperty, 200); line.Data.Transform = graphToCanvas; markers.SetValue(Canvas.ZIndexProperty, 200); host.Canvas.Children.Add(line); host.Canvas.Children.Add(markers); } else { if (!host.direct2DControl.InitializationFailed) { host.direct2DControl.AddPath(lineD2D); host.direct2DControl.AddPath(markersD2D); markersD2D.GraphToCanvas = graphToCanvas; } } Plot.Legend.Items.Add(legendItem); annotation.SetValue(Canvas.ZIndexProperty, 201); annotation.Visibility = Visibility.Collapsed; host.Canvas.Children.Add(annotation); // UpdateLegendMarkers(); }
internal override void BeforeArrange() { graphToCanvas.Matrix = new Matrix(xAxis.Scale, 0, 0, -yAxis.Scale, -xAxis.Offset - xAxis.AxisPadding.Lower, yAxis.Offset + yAxis.AxisTotalLength - yAxis.AxisPadding.Upper); canvasToGraph = (MatrixTransform)(graphToCanvas.Inverse); Curve.FilterMinMax(canvasToGraph, new Rect(new Point(xAxis.Min, yAxis.Min), new Point(xAxis.Max, yAxis.Max))); if (host.UseDirect2D == true && !host.direct2DControl.InitializationFailed) { lineD2D.Geometry = curve.ToDirect2DPathGeometry(lineD2D.Factory, graphToCanvas); markersD2D.SetGeometry((MarkersType)GetValue(MarkersTypeProperty), (double)GetValue(MarkersSizeProperty)); //host.direct2DControl.RequestRender(); } else { line.Data = LineGeometries.PathGeometryFromCurve(curve, graphToCanvas); markers.Data = MarkerGeometries.MarkersAsGeometry(Curve, graphToCanvas, (MarkersType)GetValue(MarkersTypeProperty), (double)GetValue(MarkersSizeProperty)); } Point annotationPoint = graphToCanvas.Transform(new Point(curve.xTransformed[0], curve.yTransformed[0])); annotation.SetValue(Canvas.TopProperty, annotationPoint.Y); annotation.SetValue(Canvas.LeftProperty, annotationPoint.X); }