Exemple #1
0
        public override void FromXml(StorageReader storage, FileParsingContext parsingContext)
        {
            Points = storage.Properties.GetInt32("points", Points);
            Name   = storage.Properties.GetString("name", Name);

            var width  = storage.Properties.GetInt32("width", 200);
            var height = storage.Properties.GetInt32("height", 200);

            var reader = storage.GetXmlReader();

            ChartStyle.FromXml(reader);

            reader.MoveToElement();

            // <xyplot>...<input>...</input></xyplot>
            if (!reader.IsEmptyElement)
            {
                var name = reader.Name;

                while (reader.Read())
                {
                    reader.MoveToContent();

                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (reader.Name == typeof(ChartStyle).Name.ToLower())
                        {
                            ChartStyle.FromXml(reader);
                        }

                        if (reader.Name == typeof(PropertiesSource).Name.ToLower())
                        {
                            PropertiesSource.FromXml(reader);
                        }

                        if (reader.Name == typeof(Grid).Name.ToLower())
                        {
                            Grid.FromXml(reader);
                        }

                        // FIXME: remove all *axes.
                        if (reader.Name == typeof(XAxis).Name.ToLower() || reader.Name == "xaxes")
                        {
                            XAxis.FromXml(reader);
                        }

                        if (reader.Name == typeof(YAxis).Name.ToLower() || reader.Name == "yaxes")
                        {
                            YAxis.FromXml(reader);
                        }

                        if (reader.Name == typeof(Y2Axis).Name.ToLower() || reader.Name == "y2axes")
                        {
                            Y2Axis.FromXml(reader);
                        }

                        if (reader.Name == typeof(Title).Name.ToLower() || reader.Name == "title2d")
                        {
                            Title.FromXml(reader);
                        }

                        if (reader.Name == typeof(XYLabel).Name.ToLower())
                        {
                            XYLabel.FromXml(reader);
                        }

                        if (reader.Name == typeof(Legend).Name.ToLower())
                        {
                            Legend.FromXml(reader);
                        }

                        if (reader.Name == "traces")
                        {
                            SeriesFromXml(reader);
                        }

                        // Special case.
                        if (reader.Name == "input")
                        {
                            break;
                        }
                    }

                    if (reader.NodeType == XmlNodeType.EndElement && reader.Name.Equals(name))
                    {
                        break;
                    }
                }
            }

            Size = new Size(width, height);
        }