static IEnumerable <CanvasGeometry> CreateCanvasGeometries( ShapeContext context, Stack <ShapeLayerContent> stack, ShapeFill.PathFillType pathFillType) { while (stack.Count > 0) { // Ignore context on the stack - we only want geometries. var shapeContent = stack.Pop(); switch (shapeContent.ContentType) { case ShapeContentType.Group: { // Convert all the shapes in the group to a list of geometries var group = (ShapeGroup)shapeContent; var groupedGeometries = CreateCanvasGeometries(context.Clone(), new Stack <ShapeLayerContent>(group.Contents.ToArray()), pathFillType).ToArray(); foreach (var geometry in groupedGeometries) { yield return(geometry); } } break; case ShapeContentType.MergePaths: yield return(MergeShapeLayerContent(context, stack, ((MergePaths)shapeContent).Mode)); break; case ShapeContentType.Repeater: context.Issues.RepeaterIsNotSupported(); break; case ShapeContentType.Transform: // TODO - do we need to clear out the transform when we've finished with this call to CreateCanvasGeometries?? Maybe the caller should clone the context. context.SetTransform((Transform)shapeContent); break; case ShapeContentType.SolidColorStroke: case ShapeContentType.LinearGradientStroke: case ShapeContentType.RadialGradientStroke: case ShapeContentType.SolidColorFill: case ShapeContentType.RadialGradientFill: case ShapeContentType.LinearGradientFill: case ShapeContentType.TrimPath: case ShapeContentType.RoundCorners: // Ignore commands that set the context - we only want geometries. break; case ShapeContentType.Path: yield return(Paths.CreateWin2dPathGeometryFromShape(context, (Path)shapeContent, pathFillType, optimizeLines: true)); break; case ShapeContentType.Ellipse: yield return(Ellipses.CreateWin2dEllipseGeometry(context, (Ellipse)shapeContent)); break; case ShapeContentType.Rectangle: yield return(Rectangles.CreateWin2dRectangleGeometry(context, (Rectangle)shapeContent)); break; case ShapeContentType.Polystar: context.Issues.PolystarIsNotSupported(); break; default: throw new InvalidOperationException(); } } }
public static CanvasFilledRegionDetermination FilledRegionDetermination(ShapeFill.PathFillType fillType) { return((fillType == ShapeFill.PathFillType.Winding) ? CanvasFilledRegionDetermination.Winding : CanvasFilledRegionDetermination.Alternate); }