public IPathGeometry CreatePathGeometry(ITransform?transformInterface, IEnumerable <IPathFigure> figures, FillRule fillRule) { var pathGeometry = new PathGeometry() { FillRule = fillRule }; if (transformInterface != null) { if (!(transformInterface is Transform transform)) { throw new InvalidOperationException($"Transforms should all be of type {nameof(Transform)}"); } pathGeometry.Transform = transform; } GraphicsObjectCollection <PathFigure> destinationFigures = pathGeometry.Figures; foreach (IPathFigure pathFigureInterface in figures) { if (!(pathFigureInterface is PathFigure pathFigure)) { throw new InvalidOperationException($"{nameof(CreatePathGeometry)} figures should all be of type {nameof(PathFigure)}"); } destinationFigures.Add(pathFigure); } return(pathGeometry); }
public IPathFigure CreatePathFigure(IEnumerable <IPathSegment> segments, Point startPoint, bool isClosed, bool isFilled) { var pathFigure = new PathFigure() { StartPoint = new Wrapper.Point(startPoint), IsClosed = isClosed, IsFilled = isFilled }; GraphicsObjectCollection <PathSegment> destinationSegments = pathFigure.Segments; foreach (IPathSegment pathSegmentInterface in segments) { if (!(pathSegmentInterface is PathSegment pathSegment)) { throw new InvalidOperationException($"{nameof(CreatePathFigure)} segments should all be of type {nameof(PathSegment)}"); } destinationSegments.Add(pathSegment); } return(pathFigure); }