internal override bool Render(UIElement element, PdfRenderContext context) { Path path = element as Path; if (path == null) { return(false); } var pdfGeometry = PdfGeometryHelper.ConvertGeometry(path.Data); if (pdfGeometry == null) { return(false); } using (context.drawingSurface.SaveGraphicProperties()) { SetFill(context, path.Fill, path.ActualWidth, path.ActualHeight); SetStroke(context, path.StrokeThickness, path.Stroke, path.ActualWidth, path.ActualHeight, path.StrokeDashArray); if (context.drawingSurface.GraphicProperties.IsFilled || context.drawingSurface.GraphicProperties.IsStroked) { context.drawingSurface.DrawPath(pdfGeometry); } return(true); } }
internal static IDisposable SaveClip(FixedContentEditor drawingSurface, Rect rectangle) { PathGeometry geometry = MathHelper.TransformRectangle(drawingSurface.Position.Matrix, rectangle); var pdfGeometry = PdfGeometryHelper.ConvertPathGeometry(geometry); return(drawingSurface.PushClipping(pdfGeometry)); }
internal override bool Render(UIElement element, PdfRenderContext context) { Shape shape = element as Shape; if (shape == null) { return(false); } Type type = shape.GetType(); PropertyInfo geometryProperty = type.GetProperty("DefiningGeometry", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); Geometry geometry = (Geometry)geometryProperty.GetValue(shape, null); var pdfGeometry = PdfGeometryHelper.ConvertGeometry(geometry); if (pdfGeometry == null) { return(false); } using (context.drawingSurface.SaveGraphicProperties()) { SetFill(context, shape.Fill, shape.ActualWidth, shape.ActualHeight); SetStroke(context, shape.StrokeThickness, shape.Stroke, shape.ActualWidth, shape.ActualHeight, shape.StrokeDashArray); if (context.drawingSurface.GraphicProperties.IsFilled || context.drawingSurface.GraphicProperties.IsStroked) { context.drawingSurface.DrawPath(pdfGeometry); } return(true); } }