public static Geometry GetGenericGeometry(MarkersType markersType, double width, double height) { StreamGeometry geometry = new StreamGeometry(); GenericMarker markerSpecification = GenericMarkerLookup[markersType]; using (StreamGeometryContext ctx = geometry.Open()) { ctx.BeginFigure(new Point(markerSpecification.X[0] * width, markerSpecification.Y[0] * height), false /* is filled */, true /* is closed */); int n = markerSpecification.X.Length; for (int i = 1; i < n; ++i) { ctx.LineTo(new Point(markerSpecification.X[i] * width, markerSpecification.Y[i] * height), true /* is stroked */, false /* is smooth join */); } } return(geometry); }
public static Geometry MarkerGeometry(MarkersType markersType, Factory factory, float width, float height) { Geometry geometry = null; switch (markersType) { case MarkersType.None: break; case MarkersType.Square: geometry = new RectangleGeometry(factory, new System.Drawing.RectangleF() { X = 0, Y = 0, Width = width, Height = height }); break; case MarkersType.Circle: geometry = new EllipseGeometry(factory, new Ellipse() { Point = new System.Drawing.PointF(0, 0), RadiusX = width / 2, RadiusY = height / 2, }); break; default: GenericMarker markerSpecification = MarkerGeometries.GenericMarkerLookup[markersType]; geometry = new PathGeometry(factory); using (GeometrySink sink = (geometry as PathGeometry).Open()) { PointF p0 = new PointF((float)markerSpecification.X[0] * width, (float)markerSpecification.Y[0] * height); sink.BeginFigure(p0, FigureBegin.Hollow); int n = markerSpecification.X.Length; for (int i = 1; i < n; ++i) { sink.AddLine(new PointF((float)markerSpecification.X[i] * width, (float)markerSpecification.Y[i] * height)); } sink.EndFigure(FigureEnd.Closed); sink.Close(); } break; } return(geometry); }