private void Init(Group outerGroup, Group innerGroup, SvgPath svgPath, StringDictionary parentStyle) { var style = StyleHelper.MergeStyles(parentStyle, svgPath.Style); Init(outerGroup, innerGroup, svgPath.Transform, style); var fillPath = innerGroup.Children.Append <VdPath>(); var strokePath = fillPath; fillPath.PathData = svgPath.D; if (style.ContainsKey("fill") && SetFillType(fillPath, style["fill-rule"])) { strokePath = innerGroup.Children.Append <VdPath>(); strokePath.PathData = PathDataFixer.Fix(svgPath.D); } fillPath.PathData = PathDataFixer.Fix(fillPath.PathData); foreach (string key in style.Keys) { var value = style[key]; switch (key) { case "fill": if (value.StartsWith("#")) { fillPath.FillColor = value; } break; case "stroke": if (value.StartsWith("#")) { strokePath.StrokeColor = value; } break; case "stroke-width": strokePath.StrokeWidth = (float)UnitConverter.ConvertToPx(value, 0); break; case "stroke-opacity": strokePath.StrokeAlpha *= float.Parse(value, CultureInfo.InvariantCulture); break; case "fill-opacity": fillPath.FillAlpha *= float.Parse(value, CultureInfo.InvariantCulture); break; case "opacity": strokePath.StrokeAlpha *= float.Parse(value, CultureInfo.InvariantCulture); fillPath.FillAlpha *= float.Parse(value, CultureInfo.InvariantCulture); break; case "stroke-linecap": strokePath.StrokeLineCap = value; break; case "stroke-linejoin": strokePath.StrokeLineJoin = value; break; case "stroke-miterlimit": strokePath.StrokeMiterLimit = value; break; case "stroke-dasharray": _isStrokeDasharrayUsed |= value != "none"; break; } } }
private static string ConvertToDp(string length, double reference) { return(string.Format(CultureInfo.InvariantCulture, "{0}dp", UnitConverter.ConvertToPx(length, reference))); }