Example #1
0
        private void SolveElements(XElement element)
        {
            var name = element.Name.LocalName;

            if (name == "style")
            {
                var value  = element.Value;
                var styles = value.Split('\n').Where(x => x != "").ToList();
                styles.ForEach(styleString =>
                {
                    var style = SvgStyle.Parse(styleString);
                    Styles.Add(style);
                });
            }

            if (name == "rect")
            {
                var svgRect = CreateRect(element);
                Elements.Add(svgRect);
            }

            if (name == "circle")
            {
                var svgCircle = CreateCircle(element);
                Elements.Add(svgCircle);
            }

            if (name == "path")
            {
                var svgPath = CreatePath(element);
                Elements.Add(svgPath);
            }

            if (name == "g")
            {
                var svgGroup = CreateGroup(element);
                Elements.Add(svgGroup);
            }

            if (name == "line")
            {
                var svgLine = CreateLine(element);
                Elements.Add(svgLine);
            }

            if (name == "ellipse")
            {
                var svgLine = CreateEllipse(element);
                Elements.Add(svgLine);
            }

            if (name == "polygon")
            {
                var svgPolygon = CreatePolygon(element);
                Elements.Add(svgPolygon);
            }
        }
Example #2
0
        public static SvgStyle Parse(string stringStyle)
        {
            var svgStyle   = new SvgStyle();
            var styleProps = svgStyle.ExtractProperties(stringStyle);

            svgStyle.Name = svgStyle.ExtractName(stringStyle);

            styleProps.ForEach(prop =>
            {
                var name  = prop.Item1;
                var value = prop.Item2;

                svgStyle.UseProperty(name, value);
            });

            return(svgStyle);
        }