public static void SetSvgFontSize(this HtmlElement element, double fontSize, SvgValueConverter converter) { if (fontSize.IsNaN()) { element.ClearHtmlStyleProperty("font-size"); } else { element.SetSvgAttribute("font-size", converter.ToPixelString(fontSize)); } }
public static void SetSvgSize(this HtmlElement element, Size size, SvgValueConverter converter) { if (size.IsNullOrEmpty()) { element.RemoveAttribute("width"); element.RemoveAttribute("height"); } else { element.SetAttribute("width", converter.ToImplicitValueString(size.Width)); element.SetAttribute("height", converter.ToImplicitValueString(size.Height)); } }
public WebApplicationHost() { RenderQueue renderQueue = new RenderQueue(); HtmlValueConverter htmlValueConverter = new HtmlValueConverter(); SvgValueConverter svgValueConverter = new SvgValueConverter(); SvgDefinitionContainer svgDefinitionContainer = new SvgDefinitionContainer(renderQueue); ImageElementContainer imageElementContainer = new ImageElementContainer(); EmbeddedResourceObjectFactory embeddedResourceObjectFactory = new EmbeddedResourceObjectFactory(htmlValueConverter); HtmlRenderElementFactory htmlRenderElementFactory = new HtmlRenderElementFactory(renderQueue, htmlValueConverter, imageElementContainer, embeddedResourceObjectFactory, svgValueConverter, svgDefinitionContainer); PresentationSourceFactory = new PresentationSourceFactory(htmlRenderElementFactory, htmlValueConverter, imageElementContainer, svgDefinitionContainer); TaskScheduler = new TaskScheduler(); TextMeasurementService = new TextMeasurementService(htmlValueConverter); }
private static void SetSvgAttribute(this HtmlElement element, string attributeName, double value, SvgValueConverter converter) { if (value.IsNaN()) { element.RemoveAttribute(attributeName); } else { element.SetAttribute(attributeName, converter.ToImplicitValueString(value)); } }
public static void SetSvgTransform(this HtmlElement element, Matrix transform, SvgValueConverter converter) { if (transform.IsNullOrIdentity()) { element.RemoveAttribute("transform"); } else { element.SetAttribute("transform", converter.ToMatrixString(transform)); } }
public static void SetSvgLocation(this HtmlElement element, Point location, SvgValueConverter converter) { element.SetSvgPointAttributes("x", "y", location, converter); }
public static void SetSvgSpreadMethod(this HtmlElement element, GradientSpreadMethod spreadMethod, SvgValueConverter converter) { element.SetAttribute("spreadMethod", converter.ToSpreadMethodString(spreadMethod)); }
public static void SetSvgMappingMode(this HtmlElement element, BrushMappingMode mappingMode, SvgValueConverter converter) { element.SetAttribute("gradientUnits", converter.ToGradientUnitsString(mappingMode)); }
public static void SetSvgFontStyle(this HTMLElement element, System.Windows.FontStyle fontStyle, SvgValueConverter converter) { if (fontStyle == System.Windows.FontStyle.Normal) { element.ClearHtmlStyleProperty("font-style"); } else { element.SetSvgAttribute("font-style", converter.ToFontStyleString(fontStyle)); } }
public static void SetSvgGradientOrigin(this HtmlElement element, Point gradientOrigin, SvgValueConverter converter) { element.SetSvgPointAttributes("fx", "fy", gradientOrigin, converter); }
public static void SetSvgBounds(this HtmlElement element, Rect bounds, SvgValueConverter converter) { element.SetSvgLocation(bounds.Location, converter); element.SetSvgSize(bounds.Size, converter); }
public static void SetSvgOpacity(this HtmlElement element, double opacity, SvgValueConverter converter) { element.SetSvgAttribute("opacity", opacity, converter); }
public static void SetSvgFontStretch(this HtmlElement element, System.Windows.FontStretch fontStretch, SvgValueConverter converter) { if (fontStretch == System.Windows.FontStretch.Normal) { element.ClearHtmlStyleProperty("font-stretch"); } else { element.SetSvgAttribute("font-stretch", converter.ToFontStretchString(fontStretch)); } }
public static void SetSvgEndPoint(this HtmlElement element, Point endPoint, SvgValueConverter converter) { element.SetSvgPointAttributes("x2", "y2", endPoint, converter); }
public static void SetSvgFontWeight(this HtmlElement element, FontWeight fontWeight, SvgValueConverter converter) { if (fontWeight == FontWeight.Normal) { element.ClearHtmlStyleProperty("font-weight"); } else { element.SetSvgAttribute("font-weight", converter.ToFontWeightString(fontWeight)); } }
public static void SetSvgStartPoint(this HtmlElement element, Point startPoint, SvgValueConverter converter) { element.SetSvgPointAttributes("x1", "y1", startPoint, converter); }
public static void SetSvgFontFamily(this HtmlElement element, FontFamily fontFamily, SvgValueConverter converter) { if (!fontFamily.FamilyNames.Any()) { element.ClearHtmlStyleProperty("font-family"); } else { element.SetSvgAttribute("font-family", converter.ToFontFamilyNamesString(fontFamily)); } }
public static void SetSvgImageSource(this HtmlElement element, ImageSource imageSource, IRenderElementFactory factory, SvgValueConverter converter) { element.SetAttributeNS(SvgDocument.XlinkNamespaceUri, "href", converter.ToImageUrl(imageSource, factory)); }
private static void SetSvgPointAttributes(this HtmlElement element, string xAttributeName, string yAttributeName, Point point, SvgValueConverter converter) { if (point.IsNullOrEmpty()) { element.RemoveAttribute(xAttributeName); element.RemoveAttribute(yAttributeName); } else { element.SetAttribute(xAttributeName, converter.ToImplicitValueString(point.X)); element.SetAttribute(yAttributeName, converter.ToImplicitValueString(point.Y)); } }
public static void SetSvgStrokeThickness(this HtmlElement element, double strokeThickness, SvgValueConverter converter) { element.SetSvgAttribute("stroke-width", strokeThickness, converter); }
public static void SetSvgCenter(this HtmlElement element, Point center, SvgValueConverter converter) { element.SetSvgPointAttributes("cx", "cy", center, converter); }