private void SetPolylinePoints(D2DPolyline polyline, LocationCollection locations) { // materialize the list to skip managed-to-unmanaged marshaling on every iteration var list = this.Owner.ConvertGeographicToPixelCoordinates(locations).ToList(); polyline.SetPoints(list); }
private void RenderPolylines(bool closed) { // Shape geometry models already defined - the D2DCanvas will scale them. if (this.Owner.D2DSurface.HasShapesForLayer(this.id)) { return; } int minPoints = closed ? 3 : 2; foreach (IMapShape shapeModel in this.ShapeModels) { var shape2DModel = shapeModel as MapShape2DModel; if (shape2DModel == null) { continue; } if (shape2DModel.Locations.Count == 1) { if (shape2DModel.Locations[0].Count < minPoints) { continue; } var shape = new D2DPolyline(); shape.IsClosed = closed; this.SetPolylinePoints(shape, shape2DModel.Locations[0]); this.AddShape(shape, shape2DModel); } else { // Use ShapeContainer for more than 1 polyline per model var container = new D2DShapeContainer(); var childShapes = new List <D2DShape>(); foreach (LocationCollection locations in shape2DModel.Locations) { if (locations.Count < minPoints) { continue; } var shape = new D2DPolyline(); shape.IsClosed = closed; this.SetPolylinePoints(shape, locations); childShapes.Add(shape); } container.SetShapes(childShapes); this.AddShape(container, shape2DModel); } } this.Owner.D2DSurface.SetShapesForLayer(this.shapes, new ShapeLayerParameters() { Id = this.id, ZIndex = this.zIndex, RenderPrecision = ShapeRenderPrecision.Double }); }