// Token: 0x0600540F RID: 21519 RVA: 0x00174C84 File Offset: 0x00172E84
        internal static VirtualizationCacheLength FromString(string s, CultureInfo cultureInfo)
        {
            TokenizerHelper tokenizerHelper = new TokenizerHelper(s, cultureInfo);

            double[] array = new double[2];
            int      num   = 0;

            while (tokenizerHelper.NextToken())
            {
                if (num >= 2)
                {
                    num = 3;
                    break;
                }
                array[num] = double.Parse(tokenizerHelper.GetCurrentToken(), cultureInfo);
                num++;
            }
            if (num == 1)
            {
                return(new VirtualizationCacheLength(array[0]));
            }
            if (num != 2)
            {
                throw new FormatException(SR.Get("InvalidStringVirtualizationCacheLength", new object[]
                {
                    s
                }));
            }
            return(new VirtualizationCacheLength(array[0], array[1]));
        }
        /// <summary>
        /// Parses a VirtualizationCacheLength from a string given the CultureInfo.
        /// </summary>
        /// <param name="s">String to parse from.</param>
        /// <param name="cultureInfo">Culture Info.</param>
        /// <returns>Newly created VirtualizationCacheLength instance.</returns>
        static internal VirtualizationCacheLength FromString(string s, CultureInfo cultureInfo)
        {
            TokenizerHelper th = new TokenizerHelper(s, cultureInfo);

            double[] lengths = new double[2];
            int      i       = 0;

            // Peel off each double in the delimited list.
            while (th.NextToken())
            {
                if (i >= 2)
                {
                    i = 3;    // Set i to a bad value.
                    break;
                }

                lengths[i] = Double.Parse(th.GetCurrentToken(), cultureInfo);
                i++;
            }

            // We have a reasonable interpreation for one value (all four edges), two values (horizontal, vertical),
            // and four values (left, top, right, bottom).
            switch (i)
            {
            case 1:
                return(new VirtualizationCacheLength(lengths[0]));

            case 2:
                // Should allowInfinity be false ??? (Rob)
                return(new VirtualizationCacheLength(lengths[0], lengths[1]));
            }

            throw new FormatException(SR.Get(SRID.InvalidStringVirtualizationCacheLength, s));
        }
Example #3
0
        // Token: 0x06000C56 RID: 3158 RVA: 0x0002DEF8 File Offset: 0x0002C0F8
        internal static Thickness FromString(string s, CultureInfo cultureInfo)
        {
            TokenizerHelper tokenizerHelper = new TokenizerHelper(s, cultureInfo);

            double[] array = new double[4];
            int      num   = 0;

            while (tokenizerHelper.NextToken())
            {
                if (num >= 4)
                {
                    num = 5;
                    break;
                }
                array[num] = LengthConverter.FromString(tokenizerHelper.GetCurrentToken(), cultureInfo);
                num++;
            }
            switch (num)
            {
            case 1:
                return(new Thickness(array[0]));

            case 2:
                return(new Thickness(array[0], array[1], array[0], array[1]));

            case 4:
                return(new Thickness(array[0], array[1], array[2], array[3]));
            }
            throw new FormatException(SR.Get("InvalidStringThickness", new object[]
            {
                s
            }));
        }
Example #4
0
        // Token: 0x06000381 RID: 897 RVA: 0x0000A168 File Offset: 0x00008368
        internal static CornerRadius FromString(string s, CultureInfo cultureInfo)
        {
            TokenizerHelper tokenizerHelper = new TokenizerHelper(s, cultureInfo);

            double[] array = new double[4];
            int      num   = 0;

            while (tokenizerHelper.NextToken())
            {
                if (num >= 4)
                {
                    num = 5;
                    break;
                }
                array[num] = double.Parse(tokenizerHelper.GetCurrentToken(), cultureInfo);
                num++;
            }
            if (num == 1)
            {
                return(new CornerRadius(array[0]));
            }
            if (num != 4)
            {
                throw new FormatException(SR.Get("InvalidStringCornerRadius", new object[]
                {
                    s
                }));
            }
            return(new CornerRadius(array[0], array[1], array[2], array[3]));
        }
Example #5
0
        static internal CornerRadius FromString(string s, CultureInfo cultureInfo)
        {
            TokenizerHelper th = new TokenizerHelper(s, cultureInfo);

            double[] radii = new double[4];
            int      i     = 0;

            // Peel off each Length in the delimited list.
            while (th.NextToken())
            {
                if (i >= 4)
                {
                    i = 5;    // Set i to a bad value.
                    break;
                }

                radii[i] = double.Parse(th.GetCurrentToken(), cultureInfo);
                i++;
            }

            // We have a reasonable interpreation for one value (all four edges)
            // and four values (left, top, right, bottom).
            switch (i)
            {
            case 1:
                return(new CornerRadius(radii[0]));

            case 4:
                return(new CornerRadius(radii[0], radii[1], radii[2], radii[3]));
            }

            throw new FormatException(SR.Get(SRID.InvalidStringCornerRadius, s));
        }
        internal override object ConvertFromCore(ITypeDescriptorContext td, CultureInfo ci, string value)
        {
            _tokenizer = new TokenizerHelper(value, '\0' /* quote char */, DelimiterChar);
            List <bool> list = new List <bool>(Math.Min(256, value.Length / EstimatedCharCountPerItem + 1));

            while (_tokenizer.NextToken())
            {
                list.Add(Convert.ToInt32(_tokenizer.GetCurrentToken(), ci) != 0);
            }
            return(list);
        }
Example #7
0
        /// <summary>
        /// Parses a series of points.
        /// </summary>
        internal static PointStopCollection ParsePoints(string value)
        {
            PointStopCollection points    = new PointStopCollection();
            TokenizerHelper     tokenizer = new TokenizerHelper(value, CultureInfo.InvariantCulture);

            while (tokenizer.NextToken())
            {
                Point point = new Point(ParserHelper.ParseDouble(tokenizer.GetCurrentToken()), ParserHelper.ParseDouble(tokenizer.NextTokenRequired()));
                points.Add(point);
            }
            return(points);
        }
Example #8
0
        public static Point3DCollection Parse(string source)
        {
            IFormatProvider   cultureInfo = CultureInfo.InvariantCulture;
            TokenizerHelper   helper      = new TokenizerHelper(source, cultureInfo);
            Point3DCollection pointds     = new Point3DCollection();

            while (helper.NextToken())
            {
                Point3D pointd = new Point3D(Convert.ToSingle(helper.GetCurrentToken(), cultureInfo), Convert.ToSingle(helper.NextTokenRequired(), cultureInfo), Convert.ToSingle(helper.NextTokenRequired(), cultureInfo));
                pointds.Add(pointd);
            }
            return(pointds);
        }
Example #9
0
        public static Int32Collection Parse(string source)
        {
            IFormatProvider cultureInfo = CultureInfo.InvariantCulture;
            TokenizerHelper helper      = new TokenizerHelper(source, cultureInfo);
            Int32Collection ints        = new Int32Collection();

            while (helper.NextToken())
            {
                int num = Convert.ToInt32(helper.GetCurrentToken(), cultureInfo);
                ints.Add(num);
            }
            return(ints);
        }
Example #10
0
        public static Vector3DCollection Parse(string source)
        {
            IFormatProvider    cultureInfo = CultureInfo.InvariantCulture;
            TokenizerHelper    helper      = new TokenizerHelper(source, cultureInfo);
            Vector3DCollection vectords    = new Vector3DCollection();

            while (helper.NextToken())
            {
                Vector3D vectord = new Vector3D(Convert.ToSingle(helper.GetCurrentToken(), cultureInfo), Convert.ToSingle(helper.NextTokenRequired(), cultureInfo), Convert.ToSingle(helper.NextTokenRequired(), cultureInfo));
                vectords.Add(vectord);
            }
            return(vectords);
        }
        internal sealed override object ConvertFromCore(ITypeDescriptorContext td, CultureInfo ci, string value)
        {
            _tokenizer = new TokenizerHelper(value, '\0' /* quote char */, DelimiterChar);

            // Estimate the output list's capacity from length of the input string.
            List <double> list = new List <double>(Math.Min(256, value.Length / EstimatedCharCountPerItem + 1));

            while (_tokenizer.NextToken())
            {
                list.Add(Convert.ToDouble(_tokenizer.GetCurrentToken(), ci));
            }
            return(list);
        }
Example #12
0
        public static IntCollection Parse(string source)
        {
            IFormatProvider formatProvider = CultureInfo.InvariantCulture;
            var             th             = new TokenizerHelper(source, formatProvider);
            var             resource       = new IntCollection();

            while (th.NextToken())
            {
                var value = Convert.ToInt32(th.GetCurrentToken(), formatProvider);
                resource.Add(value);
            }

            return(resource);
        }
Example #13
0
        public static List <IntegerMarkup> Parse(string source)
        {
            IFormatProvider formatProvider = TypeConverterHelper.InvariantEnglishUS;

            TokenizerHelper      th       = new TokenizerHelper(source, formatProvider);
            List <IntegerMarkup> resource = new List <IntegerMarkup>();

            int value;

            while (th.NextToken())
            {
                value = Convert.ToInt32(th.GetCurrentToken(), formatProvider);

                resource.Add(new IntegerMarkup(value));
            }

            return(resource);
        }
        /// <summary>
        /// Parse - returns an instance converted from the provided string
        /// using the current culture
        /// <param name="source"> string with DoubleCollection data </param>
        /// </summary>
        public static DoubleCollection Parse(string source)
        {
            IFormatProvider formatProvider = System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS;

            TokenizerHelper  th       = new TokenizerHelper(source, formatProvider);
            DoubleCollection resource = new DoubleCollection();

            double value;

            while (th.NextToken())
            {
                value = Convert.ToDouble(th.GetCurrentToken(), formatProvider);

                resource.Add(value);
            }

            return(resource);
        }
Example #15
0
        /// <summary>
        /// Parse - returns an instance converted from the provided string.
        /// <param name="source"> string with Point3DCollection data </param>
        /// <param name="formatProvider">IFormatprovider for processing string</param>
        /// </summary>
        private static List <Point> ParsePointCollection(string source, IFormatProvider formatProvider)
        {
            TokenizerHelper th = new TokenizerHelper(source, formatProvider);

            List <Point> resource = new List <Point>(source.Length / 8); // SWAG the length of the collection.

            Point value;

            while (th.NextToken())
            {
                value = new Point(
                    Convert.ToDouble(th.GetCurrentToken(), formatProvider),
                    Convert.ToDouble(th.NextTokenRequired(), formatProvider));

                resource.Add(value);
            }

            return(resource);
        }
Example #16
0
        /// <summary>
        /// Parse - returns an instance converted from the provided string
        /// using the current culture
        /// <param name="source"> string with GradientStopCollection data </param>
        /// </summary>
        public static GradientStopCollection Parse(string source)
        {
            IFormatProvider formatProvider = System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS;

            TokenizerHelper        th       = new TokenizerHelper(source, formatProvider);
            GradientStopCollection resource = new GradientStopCollection();

            GradientStop value;

            while (th.NextToken())
            {
                value = new GradientStop(
                    Parsers.ParseColor(th.GetCurrentToken(), formatProvider),
                    Convert.ToDouble(th.NextTokenRequired(), formatProvider));

                resource.Add(value);
            }

            return(resource);
        }
Example #17
0
        public static Vector2Collection Parse(string source)
        {
            IFormatProvider formatProvider = CultureInfo.InvariantCulture;

            var th       = new TokenizerHelper(source, formatProvider);
            var resource = new Vector2Collection();

            Vector2 value;

            while (th.NextToken())
            {
                value = new Vector2(
                    Convert.ToSingle(th.GetCurrentToken(), formatProvider),
                    Convert.ToSingle(th.NextTokenRequired(), formatProvider));

                resource.Add(value);
            }

            return(resource);
        }
        static internal Thickness FromString(string s, CultureInfo cultureInfo)
        {
            TokenizerHelper th = new TokenizerHelper(s, cultureInfo);

            double[] lengths = new double[4];
            int      i       = 0;

            // Peel off each double in the delimited list.
            while (th.NextToken())
            {
                if (i >= 4)
                {
                    i = 5;    // Set i to a bad value.
                    break;
                }

                lengths[i] = LengthConverter.FromString(th.GetCurrentToken(), cultureInfo);
                i++;
            }

            // We have a reasonable interpreation for one value (all four edges), two values (horizontal, vertical),
            // and four values (left, top, right, bottom).
            switch (i)
            {
            case 1:
                return(new Thickness(lengths[0]));

            case 2:
                return(new Thickness(lengths[0], lengths[1], lengths[0], lengths[1]));

            case 4:
                return(new Thickness(lengths[0], lengths[1], lengths[2], lengths[3]));
            }

            throw new FormatException(SR.Get(SRID.InvalidStringThickness, s));
        }
        /// <summary> 
        /// Parse - returns an instance converted from the provided string.
        /// <param name="source"> string with Point3DCollection data </param> 
        /// <param name="formatProvider">IFormatprovider for processing string</param> 
        /// </summary>
        private static List<Point> ParsePointCollection(string source, IFormatProvider formatProvider) 
        {
            TokenizerHelper th = new TokenizerHelper(source, formatProvider);

            List<Point> resource = new List<Point>(source.Length/ 8 ); // SWAG the length of the collection. 

            Point value; 
 
            while (th.NextToken())
            { 
                value = new Point(
                    Convert.ToDouble(th.GetCurrentToken(), formatProvider),
                    Convert.ToDouble(th.NextTokenRequired(), formatProvider) );
 
                resource.Add(value);
            } 
 
            return resource;
        } 
Example #20
0
        private static ColLayout FromString(string s, CultureInfo cultureInfo)
        {
            var th      = new TokenizerHelper(s, cultureInfo);
            var lengths = new int[6];
            var i       = 0;

            while (th.NextToken())
            {
                if (i >= 6)
                {
                    i = 7;    // Set i to a bad value.
                    break;
                }

                lengths[i] = th.GetCurrentToken().Value <int>();
                i++;
            }

            switch (i)
            {
            case 1:
                return(new ColLayout(lengths[0]));

            case 2:
                return(new ColLayout
                {
                    Xs = lengths[0],
                    Sm = lengths[1]
                });

            case 3:
                return(new ColLayout
                {
                    Xs = lengths[0],
                    Sm = lengths[1],
                    Md = lengths[2]
                });

            case 4:
                return(new ColLayout
                {
                    Xs = lengths[0],
                    Sm = lengths[1],
                    Md = lengths[2],
                    Lg = lengths[3]
                });

            case 5:
                return(new ColLayout
                {
                    Xs = lengths[0],
                    Sm = lengths[1],
                    Md = lengths[2],
                    Lg = lengths[3],
                    Xl = lengths[4]
                });

            case 6:
                return(new ColLayout
                {
                    Xs = lengths[0],
                    Sm = lengths[1],
                    Md = lengths[2],
                    Lg = lengths[3],
                    Xl = lengths[4],
                    Xxl = lengths[5]
                });
            }

            throw new FormatException("InvalidStringColLayout");
        }
Example #21
0
        /// <summary>
        /// Parses a PathGeometry from a data string element.
        /// </summary>
        PathGeometry ParsePathGeometry(string data)
        {
#if DEBUG_
            // XPS = M 20,100 C 45,50 70,150 95,100 S 145,150 170,100 220,150 245,100 C 220,50 195,150 170,100 S 120,150 95,100 45,150 20,100
            // XXX = M20,100C45,50 70,150 95,100 120,50 145,150 170,100 195,50 220,150 245,100 220,50 195,150 170,100 145,50 120,150 95,100 70,50 45,150 20,100
            if (data.StartsWith("M 20,100 C 45,50 70,150 95,100 S 145,"))
            {
                Debugger.Break();
            }
#endif
            PathGeometry geo = TryParseStaticResource <PathGeometry>(data);
            if (geo != null)
            {
                return(geo);
            }

            data = FixHack(data);
            // From the algorithm on page 365 in XPS 1.0 specs
            // See Petzold page 813
            geo = new PathGeometry();
            Point           point  = new Point();
            PathFigure      figure = null;
            TokenizerHelper helper = new TokenizerHelper(data);
            helper.NextTokenRequired();
            do
            {
                string token = helper.GetCurrentToken();
                switch (token[0])
                {
                // FillRule
                case 'F':
                    geo.FillRule = helper.NextTokenRequired() == "1" ? FillRule.NonZero : FillRule.EvenOdd;
                    break;

                // Move
                case 'M':
                {
                    figure = new PathFigure();
                    geo.Figures.Add(figure);
                    point             = new Point(ParseDouble(helper.NextTokenRequired()), ParseDouble(helper.NextTokenRequired()));
                    figure.StartPoint = point;
                }
                break;

                // Move
                case 'm':
                {
                    figure = new PathFigure();
                    geo.Figures.Add(figure);
                    point             = new Point(point.X + ParseDouble(helper.NextTokenRequired()), point.Y + ParseDouble(helper.NextTokenRequired()));
                    figure.StartPoint = point;
                }
                break;

                // Line
                case 'L':
                {
                    PolyLineSegment seg;
                    int             segCount = figure.Segments.Count;
                    if (segCount > 0 && (seg = figure.Segments[segCount - 1] as PolyLineSegment) != null)
                    {
                    }
                    else
                    {
                        seg = new PolyLineSegment();
                        figure.Segments.Add(seg);
                    }
                    do
                    {
                        point = new Point(ParseDouble(helper.NextTokenRequired()), ParseDouble(helper.NextTokenRequired()));
                        seg.Points.Add(point);
                    } while (!Char.IsLetter(helper.PeekNextCharacter()));
                }
                break;

                // Line
                case 'l':
                {
                    PolyLineSegment seg;
                    int             segCount = figure.Segments.Count;
                    if (segCount > 0 && (seg = figure.Segments[segCount - 1] as PolyLineSegment) != null)
                    {
                    }
                    else
                    {
                        seg = new PolyLineSegment();
                        figure.Segments.Add(seg);
                    }
                    do
                    {
                        point = new Point(ParseDouble(helper.NextTokenRequired()), ParseDouble(helper.NextTokenRequired()));
                        seg.Points.Add(point);
                    } while (!Char.IsLetter(helper.PeekNextCharacter()));
                }
                break;

                // Horizontal Line
                case 'H':
                {
                    PolyLineSegment seg;
                    int             segCount = figure.Segments.Count;
                    if (segCount > 0 && (seg = figure.Segments[segCount - 1] as PolyLineSegment) != null)
                    {
                    }
                    else
                    {
                        seg = new PolyLineSegment();
                        figure.Segments.Add(seg);
                    }
                    do
                    {
                        point.X = ParseDouble(helper.NextTokenRequired());
                        seg.Points.Add(point);
                    } while (!Char.IsLetter(helper.PeekNextCharacter()));
                }
                break;

                // Horizontal Line
                case 'h':
                {
                    PolyLineSegment seg;
                    int             segCount = figure.Segments.Count;
                    if (segCount > 0 && (seg = figure.Segments[segCount - 1] as PolyLineSegment) != null)
                    {
                    }
                    else
                    {
                        seg = new PolyLineSegment();
                        figure.Segments.Add(seg);
                    }
                    do
                    {
                        point.X += ParseDouble(helper.NextTokenRequired());
                        seg.Points.Add(point);
                    } while (!Char.IsLetter(helper.PeekNextCharacter()));
                }
                break;

                // Vertical Line
                case 'V':
                {
                    PolyLineSegment seg;
                    int             segCount = figure.Segments.Count;
                    if (segCount > 0 && (seg = figure.Segments[segCount - 1] as PolyLineSegment) != null)
                    {
                    }
                    else
                    {
                        seg = new PolyLineSegment();
                        figure.Segments.Add(seg);
                    }
                    do
                    {
                        point.Y = ParseDouble(helper.NextTokenRequired());
                        seg.Points.Add(point);
                    } while (!Char.IsLetter(helper.PeekNextCharacter()));
                }
                break;

                // Vertical Line
                case 'v':
                {
                    PolyLineSegment seg;
                    int             segCount = figure.Segments.Count;
                    if (segCount > 0 && (seg = figure.Segments[segCount - 1] as PolyLineSegment) != null)
                    {
                    }
                    else
                    {
                        seg = new PolyLineSegment();
                        figure.Segments.Add(seg);
                    }
                    do
                    {
                        point.Y += ParseDouble(helper.NextTokenRequired());
                        seg.Points.Add(point);
                    } while (!Char.IsLetter(helper.PeekNextCharacter()));
                }
                break;

                // Elliptical Arc
                case 'A':
                    do
                    {
                        // I cannot believe it: "A70.1,50.1 1,34 0 0 170.1,30.1"
                        // The rotation angle "1,34" uses a ',' instead of a '.' in my German Windows Vista!
                        //A70.1,50.1    1,34   0   0   170.1,30.1
                        ArcSegment seg = new ArcSegment();
                        figure.Segments.Add(seg);
                        seg.Size           = new Size(ParseDouble(helper.NextTokenRequired()), ParseDouble(helper.NextTokenRequired()));
                        seg.RotationAngle  = ParseDouble(helper.NextTokenRequired());
                        seg.IsLargeArc     = helper.NextTokenRequired() == "1";
                        seg.SweepDirection = helper.NextTokenRequired() == "1" ? SweepDirection.Clockwise : SweepDirection.Counterclockwise;
                        point     = new Point(ParseDouble(helper.NextTokenRequired()), ParseDouble(helper.NextTokenRequired()));
                        seg.Point = point;
                    } while (!Char.IsLetter(helper.PeekNextCharacter()));
                    break;

                // Elliptical Arc
                case 'a':
                    do
                    {
                        ArcSegment seg = new ArcSegment();
                        figure.Segments.Add(seg);
                        seg.Size           = new Size(ParseDouble(helper.NextTokenRequired()), ParseDouble(helper.NextTokenRequired()));
                        seg.RotationAngle  = ParseDouble(helper.NextTokenRequired());
                        seg.IsLargeArc     = helper.NextTokenRequired() == "1";
                        seg.SweepDirection = helper.NextTokenRequired() == "1" ? SweepDirection.Clockwise : SweepDirection.Counterclockwise;
                        point     = new Point(point.X + ParseDouble(helper.NextTokenRequired()), point.Y + ParseDouble(helper.NextTokenRequired()));
                        seg.Point = point;
                    } while (!Char.IsLetter(helper.PeekNextCharacter()));
                    break;

                // Cubic Bézier Curve
                case 'C':
                {
                    PolyBezierSegment seg;
                    int segCount = figure.Segments.Count;
                    if (segCount > 0 && (seg = figure.Segments[segCount - 1] as PolyBezierSegment) != null)
                    {
                    }
                    else
                    {
                        seg = new PolyBezierSegment();
                        figure.Segments.Add(seg);
                    }
                    do
                    {
                        seg.Points.Add(new Point(ParseDouble(helper.NextTokenRequired()), ParseDouble(helper.NextTokenRequired())));
                        seg.Points.Add(new Point(ParseDouble(helper.NextTokenRequired()), ParseDouble(helper.NextTokenRequired())));
                        point = new Point(ParseDouble(helper.NextTokenRequired()), ParseDouble(helper.NextTokenRequired()));
                        seg.Points.Add(point);
                    } while (!Char.IsLetter(helper.PeekNextCharacter()));
                }
                break;

                // Cubic Bézier Curve
                case 'c':
                {
                    PolyBezierSegment seg;
                    int segCount = figure.Segments.Count;
                    if (segCount > 0 && (seg = figure.Segments[segCount - 1] as PolyBezierSegment) != null)
                    {
                    }
                    else
                    {
                        seg = new PolyBezierSegment();
                        figure.Segments.Add(seg);
                    }
                    do
                    {
                        seg.Points.Add(new Point(point.X + ParseDouble(helper.NextTokenRequired()), point.Y + ParseDouble(helper.NextTokenRequired())));
                        seg.Points.Add(new Point(point.X + ParseDouble(helper.NextTokenRequired()), point.Y + ParseDouble(helper.NextTokenRequired())));
                        point = new Point(point.X + ParseDouble(helper.NextTokenRequired()), point.Y + ParseDouble(helper.NextTokenRequired()));
                        seg.Points.Add(point);
                    } while (!Char.IsLetter(helper.PeekNextCharacter()));
                }
                break;

                // Smooth Cubic Bézier Curve
                case 'S':
                {
                    PolyBezierSegment seg;
                    int segCount = figure.Segments.Count;
                    if (segCount > 0 && (seg = figure.Segments[segCount - 1] as PolyBezierSegment) != null)
                    {
                    }
                    else
                    {
                        seg = new PolyBezierSegment();
                        figure.Segments.Add(seg);
                    }
                    do
                    {
                        Point pt    = new Point();
                        int   count = seg.Points.Count;
                        segCount = figure.Segments.Count;
                        if (count > 0)
                        {
                            Point lastCtrlPoint = seg.Points[count - 2];
                            pt.X = 2 * point.X - lastCtrlPoint.X;
                            pt.Y = 2 * point.Y - lastCtrlPoint.Y;
                        }
                        else if (segCount > 1 && figure.Segments[count - 2] is PolyBezierSegment)
                        {
                            PolyBezierSegment lastSeg = (PolyBezierSegment)figure.Segments[count - 2];
                            count = lastSeg.Points.Count;
                            Point lastCtrlPoint = lastSeg.Points[count - 2];
                            pt.X = 2 * point.X - lastCtrlPoint.X;
                            pt.Y = 2 * point.Y - lastCtrlPoint.Y;
                        }
                        else
                        {
                            pt = point;
                        }
                        seg.Points.Add(pt);
                        seg.Points.Add(new Point(ParseDouble(helper.NextTokenRequired()), ParseDouble(helper.NextTokenRequired())));
                        point = new Point(ParseDouble(helper.NextTokenRequired()), ParseDouble(helper.NextTokenRequired()));
                        seg.Points.Add(point);
                    } while (!Char.IsLetter(helper.PeekNextCharacter()));
                }
                break;

                // Smooth Cubic Bézier Curve
                case 's':
                {
                    PolyBezierSegment seg;
                    int segCount = figure.Segments.Count;
                    if (segCount > 0 && (seg = figure.Segments[segCount - 1] as PolyBezierSegment) != null)
                    {
                    }
                    else
                    {
                        seg = new PolyBezierSegment();
                        figure.Segments.Add(seg);
                    }
                    do
                    {
                        Point pt    = new Point();
                        int   count = seg.Points.Count;
                        segCount = figure.Segments.Count;
                        if (count > 0)
                        {
                            Point lastCtrlPoint = seg.Points[count - 2];
                            pt.X = 2 * point.X - lastCtrlPoint.X;
                            pt.Y = 2 * point.Y - lastCtrlPoint.Y;
                        }
                        else if (segCount > 1 && figure.Segments[count - 2] is PolyBezierSegment)
                        {
                            PolyBezierSegment lastSeg = (PolyBezierSegment)figure.Segments[count - 2];
                            count = lastSeg.Points.Count;
                            Point lastCtrlPoint = lastSeg.Points[count - 2];
                            pt.X = 2 * point.X - lastCtrlPoint.X;
                            pt.Y = 2 * point.Y - lastCtrlPoint.Y;
                        }
                        else
                        {
                            pt = point;
                        }
                        seg.Points.Add(pt);
                        seg.Points.Add(new Point(point.X + ParseDouble(helper.NextTokenRequired()), point.Y + ParseDouble(helper.NextTokenRequired())));
                        point = new Point(point.X + ParseDouble(helper.NextTokenRequired()), point.Y + ParseDouble(helper.NextTokenRequired()));
                        seg.Points.Add(point);
                    } while (!Char.IsLetter(helper.PeekNextCharacter()));
                }
                break;

                // Quadratic Bézier Curve
                case 'Q':
                {
                    PolyQuadraticBezierSegment seg = new PolyQuadraticBezierSegment();
                    figure.Segments.Add(seg);
                    do
                    {
                        seg.Points.Add(new Point(ParseDouble(helper.NextTokenRequired()), ParseDouble(helper.NextTokenRequired())));
                        point = new Point(ParseDouble(helper.NextTokenRequired()), ParseDouble(helper.NextTokenRequired()));
                        seg.Points.Add(point);
                    } while (!Char.IsLetter(helper.PeekNextCharacter()));
                }
                break;

                // Quadratic Bézier Curve
                case 'q':
                {
                    PolyQuadraticBezierSegment seg = new PolyQuadraticBezierSegment();
                    figure.Segments.Add(seg);
                    do
                    {
                        seg.Points.Add(new Point(point.X + ParseDouble(helper.NextTokenRequired()), point.Y + ParseDouble(helper.NextTokenRequired())));
                        point = new Point(point.X + ParseDouble(helper.NextTokenRequired()), point.Y + ParseDouble(helper.NextTokenRequired()));
                        seg.Points.Add(point);
                    } while (!Char.IsLetter(helper.PeekNextCharacter()));
                }
                break;

                // Close
                case 'Z':
                case 'z':
                {
                    figure.IsClosed = true;
                    if (figure.Segments.Count > 0)
                    {
                        PathSegment seg = figure.Segments[0];
                    }
                    point  = figure.StartPoint;
                    figure = null;
                }
                break;

                default:
                    Debug.Assert(false);
                    break;
                }
            } while (helper.NextToken());
            return(geo);
        }