コード例 #1
0
        public static LineStyle FromXml(XmlReader _xmlReader)
        {
            // Read all tags between <LineStyle> and </LineStyle> and fills up an object.
            LineStyle lineStyle;
            int       iSize     = 1;
            LineShape lineShape = LineShape.Simple;
            Color     col       = Color.Black;

            try
            {
                while (_xmlReader.Read())
                {
                    if (_xmlReader.IsStartElement())
                    {
                        if (_xmlReader.Name == "Size")
                        {
                            iSize = int.Parse(_xmlReader.ReadString());
                        }
                        else if (_xmlReader.Name == "LineShape")
                        {
                            lineShape = (LineShape)LineShape.Parse(lineShape.GetType(), _xmlReader.ReadString());
                        }
                        else if (_xmlReader.Name == "ColorRGB")
                        {
                            col = XmlHelper.ColorParse(_xmlReader.ReadString(), ';');
                        }
                        else
                        {
                            // forward compatibility : ignore new fields.
                        }
                    }
                    else if (_xmlReader.Name == "LineStyle")
                    {
                        break;
                    }
                    else
                    {
                        // Fermeture d'un tag interne.
                    }
                }

                lineStyle = new LineStyle(iSize, lineShape, col);
            }
            catch (Exception)
            {
                lineStyle = DefaultValue;
            }

            return(lineStyle);
        }