Esempio n. 1
0
        static public List <PointF> ReadSVGPath(string s)              // simple L,M,Z path only
        {
            StringParser  sp     = new StringParser(s);
            List <PointF> points = new List <PointF>();

            while (!sp.IsEOL)
            {
                char ctrl = sp.GetChar(true);
                ctrl = char.ToLower(ctrl);
                if (ctrl == 'z')
                {
                    if (points.Count > 0)
                    {
                        points.Add(points[0]);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else if (ctrl == 'm' || ctrl == 'l')
                {
                    if ((ctrl == 'm' && points.Count == 0) || (ctrl == 'l'))
                    {
                        double?x = sp.NextDoubleComma(", ");
                        double?y = sp.NextDouble();

                        if (x.HasValue && y.HasValue)
                        {
                            points.Add(new PointF((float)x, (float)y));
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
                else
                {
                    return(null);
                }
            }

            return(points);
        }