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); if (context.drawingSurface.GraphicProperties.IsFilled || context.drawingSurface.GraphicProperties.IsStroked) { context.drawingSurface.DrawPath(pdfGeometry); } return(true); } }
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, UIElement element) { Geometry clip = null; FrameworkElement frameworkElement = element as FrameworkElement; if (frameworkElement != null) { clip = System.Windows.Controls.Primitives.LayoutInformation.GetLayoutClip(frameworkElement); } if (clip == null) { clip = element.Clip; } RectangleGeometry rectangleClip = clip as RectangleGeometry; if (rectangleClip == null) { return(null); } PathGeometry geometry = MathHelper.TransformRectangle(drawingSurface.Position.Matrix, rectangleClip.Rect); var pdfGeometry = PdfGeometryHelper.ConvertPathGeometry(geometry); return(drawingSurface.PushClipping(pdfGeometry)); }
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)); }