Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public Brush FillBrush(SVG svg, SVGRender svgRender, Shape shape, double elementOpacity, Rect bounds)
        {
            var paintServer = svg.PaintServers.GetServer(PaintServerKey);

            if (paintServer != null)
            {
                if (paintServer is CurrentColorPaintServer)
                {
                    var shapePaintServer = svg.PaintServers.GetServer(shape.PaintServerKey);
                    if (shapePaintServer != null)
                    {
                        return(shapePaintServer.GetBrush(this.Opacity * elementOpacity, svg, svgRender, bounds));
                    }
                }
                if (paintServer is InheritPaintServer)
                {
                    var p = shape.RealParent ?? shape.Parent;
                    while (p != null)
                    {
                        if (p.Fill != null)
                        {
                            var checkPaintServer = svg.PaintServers.GetServer(p.Fill.PaintServerKey);
                            if (!(checkPaintServer is InheritPaintServer))
                            {
                                return(checkPaintServer.GetBrush(this.Opacity * elementOpacity, svg, svgRender, bounds));
                            }
                        }
                        p = p.RealParent ?? p.Parent;
                    }
                    return(null);
                }
                return(paintServer.GetBrush(this.Opacity * elementOpacity, svg, svgRender, bounds));
            }
            return(null);
        }
Ejemplo n.º 3
0
        public Brush StrokeBrush(SVG svg, SVGRender svgRender, Shape shape, double elementOpacity, Rect bounds, PaintServer.PaintServer parent)
        {
            if (this.Color != null)
            {
                if (this.Color is CurrentColorPaintServer)
                {
                    return(shape.Color.GetBrush(this.Opacity * elementOpacity, svg, svgRender, bounds));
                }
                if (this.Color is InheritPaintServer)
                {
                    var p = shape.RealParent ?? shape.Parent;
                    while (p != null)
                    {
                        if (p.Fill != null && !(p.Stroke.Color is InheritPaintServer))
                        {
                            return(p.Stroke.Color.GetBrush(this.Opacity * elementOpacity, svg, svgRender, bounds));
                        }
                        p = p.RealParent ?? p.Parent;
                    }

                    return(null);
                }
                return(this.Color.GetBrush(this.Opacity * elementOpacity, svg, svgRender, bounds));
            }

            return(null);
        }
Ejemplo n.º 4
0
        public static void ParseStyle(SVG svg, string style)
        {
            var svgStyles = svg.Styles;

            var match = _regexStyle.Match(style);

            while (match.Success)
            {
                var name  = match.Groups[1].Value.Trim();
                var value = match.Groups[2].Value.Trim();
                foreach (var nm in name.Split(','))
                {
                    if (!svgStyles.ContainsKey(nm))
                    {
                        svgStyles.Add(nm, new List <XmlUtil.StyleItem>());
                    }
                    foreach (ShapeUtil.Attribute styleitem in XmlUtil.SplitStyle(svg, value))
                    {
                        svgStyles[nm].Add(new XmlUtil.StyleItem(styleitem.Name, styleitem.Value));
                    }
                }

                match = match.NextMatch();
            }
        }
Ejemplo n.º 5
0
 public Stroke(SVG svg)
 {
     this.Width    = 1;
     this.LineCap  = eLineCap.butt;
     this.LineJoin = eLineJoin.miter;
     this.Opacity  = 100;
 }
Ejemplo n.º 6
0
 public Brush FillBrush(SVG svg)
 {
     if (this.Color != null)
     {
         return(this.Color.GetBrush(this.Opacity, svg));
     }
     return(null);
 }
Ejemplo n.º 7
0
 public Stroke(SVG svg)
 {
     this.Color    = new SolidColorPaintServer(svg.PaintServers, Colors.Black);
     this.Width    = 1;
     this.LineCap  = eLineCap.butt;
     this.LineJoin = eLineJoin.miter;
     this.Opacity  = 100;
 }
Ejemplo n.º 8
0
 public Brush StrokeBrush(SVG svg, double elementOpacity)
 {
     if (this.Color != null)
     {
         return(this.Color.GetBrush(this.Opacity * elementOpacity, svg));
     }
     return(null);
 }
Ejemplo n.º 9
0
 public Stroke(SVG svg)
 {
     this.Color = new SolidColorPaintServer(svg.PaintServers, Colors.Black);
     this.Width = 1;
     this.LineCap = eLineCap.butt;
     this.LineJoin = eLineJoin.miter;
     this.Opacity = 100;
 }
Ejemplo n.º 10
0
            public static Element Parse(SVG svg, string text, TextShape owner)
            {
                int     curpos = 0;
                Element root   = new Element(svg, owner, Element.eElementType.Tag, null);

                root.Text       = "<root>";
                root.StartIndex = 0;
                return(Parse(svg, text, ref curpos, null, root));
            }
Ejemplo n.º 11
0
        public static double ParseDouble(SVG svg, string svalue)
        {
            double value = 0d;

            if (GetValueRespectingUnits(svalue, out value, 1))
            {
                return(value);
            }
            return(0.1);
        }
Ejemplo n.º 12
0
        public static double ParseDouble(SVG svg, string svalue)
        {
            string units = string.Empty;
            double value = 0d;

            if (SplitValueUnits(svalue, out value, out units))
            {
                return(value);
            }
            return(0.1);
        }
Ejemplo n.º 13
0
 TSpan.Element ParseTSpan(SVG svg, string tspanText)
 {
     try
     {
         return(TSpan.Parse(svg, tspanText, this));
     }
     catch
     {
         return(null);
     }
 }
Ejemplo n.º 14
0
        public DrawingGroup LoadDrawing(Stream stream)
        {
            this.m_svg = new SVG(stream);

            /*var aa = new MemoryStream();
            var qq = XmlWriter.Create(aa, new XmlWriterSettings() { OmitXmlDeclaration = true, Indent = true });
            XamlWriter.Save(this.CreateDrawing(this.m_svg), qq);
            aa.Position = 0;
            var bb = new StreamReader(aa);
            var cc = bb.ReadToEnd();*/

            return this.CreateDrawing(this.m_svg);
        }
Ejemplo n.º 15
0
        public DrawingGroup LoadDrawing(Stream stream)
        {
            this.m_svg = new SVG(stream);

            /*var aa = new MemoryStream();
             * var qq = XmlWriter.Create(aa, new XmlWriterSettings() { OmitXmlDeclaration = true, Indent = true });
             * XamlWriter.Save(this.CreateDrawing(this.m_svg), qq);
             * aa.Position = 0;
             * var bb = new StreamReader(aa);
             * var cc = bb.ReadToEnd();*/

            return(this.CreateDrawing(this.m_svg));
        }
Ejemplo n.º 16
0
            static Element Parse(SVG svg, string text, ref int curPos, Element parent, Element curTag)
            {
                Element tag = curTag;

                if (tag == null)
                {
                    tag = NextTag(svg, parent, text, ref curPos);
                }
                while (curPos < text.Length)
                {
                    int     prevPos = curPos;
                    Element next    = NextTag(svg, tag, text, ref curPos);
                    if (next == null && curPos < text.Length)
                    {
                        // remaining pure text
                        string s = text.Substring(curPos, text.Length - curPos);
                        tag.Children.Add(new Element(svg, tag, s));
                        return(tag);
                    }
                    if (next != null && next.StartIndex - prevPos > 0)
                    {
                        // pure text between tspan elements
                        int    diff = next.StartIndex - prevPos;
                        string s    = text.Substring(prevPos, diff);
                        tag.Children.Add(new Element(svg, tag, s));
                    }
                    if (next.Text.StartsWith("<tspan"))
                    {
                        // new nested element
                        next = Parse(svg, text, ref curPos, tag, next);
                        tag.Children.Add(next);
                        continue;
                    }
                    if (next.Text.StartsWith("</tspan"))
                    {
                        // end of cur element
                        tag.End = next;
                        return(tag);
                    }
                    if (next.Text.StartsWith("<textPath"))
                    {
                        continue;
                    }
                    if (next.Text.StartsWith("</textPath"))
                    {
                        continue;
                    }
                    throw new Exception(string.Format("unexpected tag '{0}'", next.Text));
                }
                return(tag);
            }
Ejemplo n.º 17
0
 public TextStyle(SVG svg, Shape owner)
 {
     this.FontFamily    = "Arial Unicode MS, Verdana";
     this.FontSize      = 12;
     this.Fontweight    = FontWeights.Normal;
     this.Fontstyle     = FontStyles.Normal;
     this.TextAlignment = System.Windows.TextAlignment.Left;
     this.WordSpacing   = 0;
     this.LetterSpacing = 0;
     this.BaseLineShift = string.Empty;
     if (owner.Parent != null)
     {
         this.Copy(owner.Parent.TextStyle);
     }
 }
Ejemplo n.º 18
0
            static Element NextTag(SVG svg, Element parent, string text, ref int curPos)
            {
                int start = text.IndexOf("<", curPos);

                if (start < 0)
                {
                    return(null);
                }
                int end = text.IndexOf(">", start + 1);

                if (end < 0)
                {
                    throw new Exception("Start '<' with no end '>'");
                }

                end++;

                string tagtext = text.Substring(start, end - start);

                if (tagtext.IndexOf("<", 1) > 0)
                {
                    throw new Exception(string.Format("Start '<' within tag 'tag'"));
                }

                List <ShapeUtil.Attribute> attrs = new List <ShapeUtil.Attribute>();
                int attrstart = tagtext.IndexOf("tspan");

                if (attrstart > 0)
                {
                    attrstart += 5;
                    while (attrstart < tagtext.Length - 1)
                    {
                        attrs.Add(ShapeUtil.ReadNextAttr(tagtext, ref attrstart));
                    }
                }

                Element tag = new Element(svg, parent, Element.eElementType.Tag, attrs);

                tag.StartIndex = start;
                tag.Text       = text.Substring(start, end - start);
                if (tag.Text.IndexOf("<", 1) > 0)
                {
                    throw new Exception(string.Format("Start '<' within tag 'tag'"));
                }

                curPos = end;
                return(tag);
            }
Ejemplo n.º 19
0
 public TextShape(SVG svg, XmlNode node, Shape parent)
     : base(svg, node, parent)
 {
     this.X = XmlUtil.AttrValue(node, "x", 0);
     this.Y = XmlUtil.AttrValue(node, "y", 0);
     this.Text = node.InnerText;
     this.GetTextStyle(svg);
     // check for tSpan tag
     if (node.InnerXml.IndexOf("<") >= 0)
         this.TextSpan = this.ParseTSpan(svg, node.InnerXml);
     if (DefaultFill == null)
     {
         DefaultFill = new Fill(svg);
         DefaultFill.Color = svg.PaintServers.Parse("black");
     }
     if (DefaultStroke == null)
     {
         DefaultStroke = new Stroke(svg);
         DefaultStroke.Width = 0.1;
     }
 }
Ejemplo n.º 20
0
        public static List <ShapeUtil.Attribute> SplitStyle(SVG svg, string fullstyle)
        {
            List <ShapeUtil.Attribute> list = new List <ShapeUtil.Attribute>();

            if (fullstyle.Length == 0)
            {
                return(list);
            }
            // style contains attributes in format of "attrname:value;attrname:value"
            string[] attrs = fullstyle.Split(';');
            foreach (string attr in attrs)
            {
                string[] s = attr.Split(':');
                if (s.Length != 2)
                {
                    continue;
                }
                list.Add(new ShapeUtil.Attribute(s[0].Trim(), s[1].Trim()));
            }
            return(list);
        }
Ejemplo n.º 21
0
 public TextShape(SVG svg, XmlNode node, Shape parent) : base(svg, node, parent)
 {
     this.X    = XmlUtil.AttrValue(node, "x", 0);
     this.Y    = XmlUtil.AttrValue(node, "y", 0);
     this.Text = node.InnerText;
     this.GetTextStyle(svg);
     // check for tSpan tag
     if (node.InnerXml.IndexOf("<") >= 0)
     {
         this.TextSpan = this.ParseTSpan(svg, node.InnerXml);
     }
     //if (DefaultFill == null)
     //{
     //	DefaultFill = new Fill(svg);
     //	DefaultFill.PaintServerKey = svg.PaintServers.Parse("black");
     //}
     if (DefaultStroke == null)
     {
         DefaultStroke       = new Stroke(svg);
         DefaultStroke.Width = 0.1;
     }
 }
Ejemplo n.º 22
0
 public Element(SVG svg, Shape parent, eElementType eType, List <ShapeUtil.Attribute> attrs) : base(svg, attrs, parent)
 {
     this.ElementType = eType;
     this.Text        = string.Empty;
     this.Children    = new List <Element>();
 }
Ejemplo n.º 23
0
 public Element(SVG svg, Shape parent, string text) : base(svg, (XmlNode)null, parent)
 {
     this.ElementType = eElementType.Text;
     this.Text        = text;
 }
Ejemplo n.º 24
0
 public Fill(SVG svg)
 {
     this.FillRule = eFillRule.nonzero;
     this.Opacity  = 100;
 }
Ejemplo n.º 25
0
 public DrawingGroup CreateDrawing(SVG svg)
 {
     return this.LoadGroup(svg.Elements, svg.ViewBox);
 }
Ejemplo n.º 26
0
        // http://apike.ca/prog_svg_paths.html
        public PathShape(SVG svg, XmlNode node) : base(svg, node)
        {
            if (DefaultFill == null)
            {
                DefaultFill       = new Fill(svg);
                DefaultFill.Color = svg.PaintServers.Parse("black");
            }


            this.ClosePath = false;
            string             path = XmlUtil.AttrValue(node, "d", string.Empty);
            CommandSplitter    cmd  = new CommandSplitter(path);
            string             commandstring;
            char               command;
            List <PathElement> elements = this.m_elements;

            while (true)
            {
                commandstring = cmd.ReadNext();
                if (commandstring.Length == 0)
                {
                    break;
                }
                ShapeUtil.StringSplitter split = cmd.SplitCommand(commandstring, out command);
                if (command == 'm' || command == 'M')
                {
                    elements.Add(new MoveTo(command, split));
                    if (split.More)
                    {
                        elements.Add(new LineTo(command, split));
                    }
                    continue;
                }
                if (command == 'l' || command == 'L' || command == 'H' || command == 'h' || command == 'V' || command == 'v')
                {
                    elements.Add(new LineTo(command, split));
                    continue;
                }
                if (command == 'c' || command == 'C')
                {
                    while (split.More)
                    {
                        elements.Add(new CurveTo(command, split));
                    }
                    continue;
                }
                if (command == 's' || command == 'S')
                {
                    while (split.More)
                    {
                        CurveTo lastshape = elements[elements.Count - 1] as CurveTo;
                        System.Diagnostics.Debug.Assert(lastshape != null);
                        elements.Add(new CurveTo(command, split, lastshape.CtrlPoint2));
                    }
                    continue;
                }
                if (command == 'a' || command == 'A')
                {
                    elements.Add(new EllipticalArcTo(command, split));
                    while (split.More)
                    {
                        elements.Add(new EllipticalArcTo(command, split));
                    }
                    continue;
                }
                if (command == 'z' || command == 'Z')
                {
                    this.ClosePath = true;
                    continue;
                }

                // extended format moveto or lineto can contain multiple points which should be translated into lineto
                PathElement lastitem = elements[elements.Count - 1];
                if (lastitem is MoveTo || lastitem is LineTo || lastitem is CurveTo)
                {
                    //Point p = Point.Parse(s);
                    //elements.Add(new LineTo(p));
                    continue;
                }


                System.Diagnostics.Debug.Assert(false, string.Format("type '{0}' not supported", commandstring));
            }
        }
Ejemplo n.º 27
0
            static Element NextTag(SVG svg, Element parent, string text, ref int curPos)
            {
                int start = text.IndexOf("<", curPos);
                if (start < 0)
                    return null;
                int end = text.IndexOf(">", start+1);
                if (end < 0)
                    throw new Exception("Start '<' with no end '>'");

                end++;

                string tagtext = text.Substring(start, end - start);
                if (tagtext.IndexOf("<", 1) > 0)
                    throw new Exception(string.Format("Start '<' within tag 'tag'"));

                List<ShapeUtil.Attribute> attrs = new List<ShapeUtil.Attribute>();
                int attrstart = tagtext.IndexOf("tspan");
                if (attrstart > 0)
                {
                    attrstart += 5;
                    while (attrstart < tagtext.Length-1)
                        attrs.Add(ShapeUtil.ReadNextAttr(tagtext, ref attrstart));
                }

                Element tag = new Element(svg, parent, Element.eElementType.Tag, attrs);
                tag.StartIndex = start;
                tag.Text = text.Substring(start, end - start);
                if (tag.Text.IndexOf("<", 1) > 0)
                    throw new Exception(string.Format("Start '<' within tag 'tag'"));

                curPos = end;
                return tag;
            }
Ejemplo n.º 28
0
        // http://apike.ca/prog_svg_paths.html
        public PathShape(SVG svg, XmlNode node)
            : base(svg, node)
        {
            if (DefaultFill == null)
            {
                DefaultFill = new Fill(svg);
                DefaultFill.Color = svg.PaintServers.Parse("black");
            }

            this.ClosePath = false;
            string path = XmlUtil.AttrValue(node, "d", string.Empty);
            CommandSplitter cmd = new CommandSplitter(path);
            string commandstring;
            char command;
            List<PathElement> elements = this.m_elements;
            while (true)
            {
                commandstring = cmd.ReadNext();
                if (commandstring.Length == 0)
                    break;
                ShapeUtil.StringSplitter split = cmd.SplitCommand(commandstring, out command);
                if (command == 'm' || command == 'M')
                {
                    elements.Add(new MoveTo(command, split));
                    if (split.More)
                        elements.Add(new LineTo(command, split));
                    continue;
                }
                if (command == 'l' || command == 'L' || command == 'H' || command == 'h' || command == 'V' || command == 'v')
                {
                    elements.Add(new LineTo(command, split));
                    continue;
                }
                if (command == 'c' || command == 'C')
                {
                    while (split.More)
                        elements.Add(new CurveTo(command, split));
                    continue;
                }
                if (command == 's' || command == 'S')
                {
                    while (split.More)
                    {
                        CurveTo lastshape = elements[elements.Count - 1] as CurveTo;
                        System.Diagnostics.Debug.Assert(lastshape != null);
                        elements.Add(new CurveTo(command, split, lastshape.CtrlPoint2));
                    }
                    continue;
                }
                if (command == 'a' || command == 'A')
                {
                    elements.Add(new EllipticalArcTo(command, split));
                    while (split.More)
                        elements.Add(new EllipticalArcTo(command, split));
                    continue;
                }
                if (command == 'z' || command == 'Z')
                {
                    this.ClosePath = true;
                    continue;
                }

                // extended format moveto or lineto can contain multiple points which should be translated into lineto
                PathElement lastitem = elements[elements.Count-1];
                if (lastitem is MoveTo || lastitem is LineTo || lastitem is CurveTo)
                {
                    //Point p = Point.Parse(s);
                    //elements.Add(new LineTo(p));
                    continue;
                }

                System.Diagnostics.Debug.Assert(false, string.Format("type '{0}' not supported", commandstring));
            }
        }
Ejemplo n.º 29
0
 public Fill(SVG svg)
 {
     this.FillRule = eFillRule.nonzero;
     this.Color    = new SolidColorPaintServer(svg.PaintServers, Colors.LightSeaGreen);
     this.Opacity  = 100;
 }
Ejemplo n.º 30
0
 public Brush StrokeBrush(SVG svg)
 {
     if (this.Color != null)
         return this.Color.GetBrush(this.Opacity, svg);
     return null;
 }
Ejemplo n.º 31
0
        // http://apike.ca/prog_svg_paths.html
        public PathShape(SVG svg, XmlNode node, Shape parent) : base(svg, node, parent)
        {
            if (DefaultFill == null)
            {
                DefaultFill = new Fill(svg);
                DefaultFill.PaintServerKey = svg.PaintServers.Parse("black");
            }

            this.ClosePath = false;
            string path = XmlUtil.AttrValue(node, "d", string.Empty);

            this.Data = path;

            /*
             * CommandSplitter cmd = new CommandSplitter(path);
             * string commandstring;
             * char command;
             * List<PathElement> elements = this.m_elements;
             * while (true)
             * {
             *  commandstring = cmd.ReadNext();
             *  if (commandstring.Length == 0)
             *      break;
             *  ShapeUtil.StringSplitter split = cmd.SplitCommand(commandstring, out command);
             *  if (command == 'm' || command == 'M')
             *  {
             *      elements.Add(new MoveTo(command, split));
             *      if (split.More)
             *          elements.Add(new LineTo(command, split));
             *      continue;
             *  }
             *  if (command == 'l' || command == 'L' || command == 'H' || command == 'h' || command == 'V' || command == 'v')
             *  {
             *      elements.Add(new LineTo(command, split));
             *      continue;
             *  }
             *  if (command == 'c' || command == 'C')
             *  {
             *      while (split.More)
             *          elements.Add(new CurveTo(command, split));
             *      continue;
             *  }
             *  if (command == 'q' || command == 'Q')
             *  {
             *      while (split.More)
             *          elements.Add(new QuadraticCurveTo(command, split));
             *      continue;
             *  }
             *  if (command == 's' || command == 'S')
             *  {
             *      while (split.More)
             *      {
             *          CurveTo lastshape = elements[elements.Count - 1] as CurveTo;
             *          System.Diagnostics.Debug.Assert(lastshape != null);
             *          elements.Add(new CurveTo(command, split, lastshape.CtrlPoint2));
             *      }
             *      continue;
             *  }
             *  if (command == 'a' || command == 'A')
             *  {
             *      elements.Add(new EllipticalArcTo(command, split));
             *      while (split.More)
             *          elements.Add(new EllipticalArcTo(command, split));
             *      continue;
             *  }
             *  if (command == 'z' || command == 'Z')
             *  {
             *      this.ClosePath = true;
             *      continue;
             *  }
             *
             *  // extended format moveto or lineto can contain multiple points which should be translated into lineto
             *  PathElement lastitem = elements[elements.Count - 1];
             *  if (lastitem is MoveTo || lastitem is LineTo || lastitem is CurveTo)
             *  {
             *      //Point p = Point.Parse(s);
             *      //elements.Add(new LineTo(p));
             *      continue;
             *  }
             *
             *
             *  System.Diagnostics.Debug.Assert(false, string.Format("type '{0}' not supported", commandstring));
             * }
             */
        }
Ejemplo n.º 32
0
 public DrawingGroup CreateDrawing(SVG svg)
 {
     return(this.LoadGroup(svg.Elements, svg.ViewBox));
 }
Ejemplo n.º 33
0
 public static Element Parse(SVG svg, string text, TextShape owner)
 {
     int curpos = 0;
     Element root = new Element(svg, owner, Element.eElementType.Tag, null);
     root.Text = "<root>";
     root.StartIndex = 0;
     return Parse(svg, text, ref curpos, null, root);
 }
Ejemplo n.º 34
0
 public DrawingGroup LoadDrawing(string filename)
 {
     this.m_svg = new SVG(filename);
     return(this.CreateDrawing(this.m_svg));
 }
Ejemplo n.º 35
0
 public Fill(SVG svg)
 {
     this.FillRule = eFillRule.nonzero;
     this.Color = new SolidColorPaintServer(svg.PaintServers, Colors.LightSeaGreen);
     this.Opacity = 100;
 }
Ejemplo n.º 36
0
 public DrawingGroup LoadDrawing(string filename)
 {
     this.m_svg = new SVG(filename);
     return this.CreateDrawing(this.m_svg);
 }
Ejemplo n.º 37
0
 static Element Parse(SVG svg, string text, ref int curPos, Element parent, Element curTag)
 {
     Element tag = curTag;
     if (tag == null)
         tag = NextTag(svg, parent, text, ref curPos);
     while (curPos < text.Length)
     {
         int prevPos = curPos;
         Element next = NextTag(svg, tag, text, ref curPos);
         if (next == null && curPos < text.Length)
         {
             // remaining pure text
             string s = text.Substring(curPos, text.Length - curPos);
             tag.Children.Add(new Element(tag, s));
             return tag;
         }
         if (next != null && next.StartIndex-prevPos > 0)
         {
             // pure text between tspan elements
             int diff = next.StartIndex-prevPos;
             string s = text.Substring(prevPos, diff);
             tag.Children.Add(new Element(tag, s));
         }
         if (next.Text.StartsWith("<tspan"))
         {
             // new nested element
             next = Parse(svg, text, ref curPos, tag, next);
             tag.Children.Add(next);
             continue;
         }
         if (next.Text.StartsWith("</tspan"))
         {
             // end of cur element
             tag.End = next;
             return tag;
         }
         if (next.Text.StartsWith("<textPath"))
         {
             continue;
         }
         if (next.Text.StartsWith("</textPath"))
         {
             continue;
         }
         throw new Exception(string.Format("unexpected tag '{0}'", next.Text));
     }
     return tag;
 }
Ejemplo n.º 38
0
 public Element(SVG svg, Shape parent, eElementType eType, List<ShapeUtil.Attribute> attrs)
     : base(svg, attrs, parent)
 {
     this.ElementType = eType;
     this.Text = string.Empty;
     this.Children = new List<Element>();
 }
Ejemplo n.º 39
0
 TSpan.Element ParseTSpan(SVG svg, string tspanText)
 {
     try
     {
         return TSpan.Parse(svg, tspanText, this);
     }
     catch
     {
         return null;
     }
 }
Ejemplo n.º 40
0
 public AnimateTransform(SVG svg, XmlNode node)
     : base(svg, node)
 {
 }
Ejemplo n.º 41
0
 public AnimateTransform(SVG svg, XmlNode node)
     : base(svg, node)
 {
 }