Ejemplo n.º 1
0
        public SvgGroup(XmlNode node, SvgNode parent, bool renderable = true) : base(node, parent)
        {
            children = new List <SvgNode>();

            Renderable = renderable;

            // Add all the children present
            foreach (var child in node.ChildElements())
            {
                ProcessChildNode(child);
            }
        }
Ejemplo n.º 2
0
        // The most general constructor
        protected SvgNode(XmlNode node, SvgNode parent, string transformAttributeName = "transform")
        {
            // Assign the ID for everyone
            Parent = parent;
            Id     = node.SvgAttribute("id");

            // Build the property list
            var properties = new Dictionary <string, string>();

            // Go through all attributes
            foreach (XmlAttribute attr in node.Attributes)
            {
                // Skip if the attribute doesn't belong to the SVG namespace or no namespace
                if (!string.IsNullOrEmpty(attr.NamespaceURI) && attr.NamespaceURI != Svg.Namespace)
                {
                    continue;
                }

                // Skip if the attribute is style or id
                if (attr.LocalName == "style" || attr.LocalName == "id")
                {
                    continue;
                }

                // Attach it to the properties
                if (attr.LocalName == transformAttributeName)
                {
                    properties["transform"] = attr.Value.Trim();
                }
                else
                {
                    properties[attr.LocalName] = attr.Value.Trim();
                }
            }

            // Parse the CSS property list in style
            var styleProperties = node.SvgAttribute("style").ToPropertyList();

            foreach (var kvp in styleProperties)
            {
                properties[kvp.Key] = kvp.Value;
            }

            // Now, parse
            Parse(properties);
        }