Beispiel #1
0
        internal static List <Shape> Parse(SVG svg, XmlNode node)
        {
            var vb = node.Attributes.GetNamedItem("viewBox");

            if (vb != null)
            {
                var cord = vb.Value.Split(' ');
                var cult = CultureInfo.InvariantCulture;
                svg.ViewBox = new Rect(double.Parse(cord[0], cult), double.Parse(cord[1], cult), double.Parse(cord[2], cult), double.Parse(cord[3], cult));
            }

            svg.Size = new Size(XmlUtil.AttrValue(node, "width", 300), XmlUtil.AttrValue(node, "height", 150));

            var lstElements = new List <Shape>();

            if (node == null || (node.Name != SVGTags.sSvg && node.Name != SVGTags.sPattern))
            {
                throw new FormatException("Not a valide SVG node");
            }
            foreach (XmlNode childnode in node.ChildNodes)
            {
                Group.AddToList(svg, lstElements, childnode, null);
            }
            return(lstElements);
        }
Beispiel #2
0
        private static void ReadDefs(SVG svg, List <Shape> list, XmlNode node)
        {
            list = new List <Shape>(); // temp list, not needed.
            //ShapeGroups defined in the 'def' section is added the the 'Shapes' dictionary in SVG for later reference
            foreach (XmlNode childnode in node.ChildNodes)
            {
                var nodeName = GetNodeName(childnode);
                if (nodeName == SVGTags.sLinearGradient ||
                    nodeName == SVGTags.sRadialGradient ||
                    nodeName == SVGTags.sPattern)
                {
                    svg.PaintServers.Create(svg, childnode);
                    continue;
                }

                Group.AddToList(svg, list, childnode, null);
            }
        }