Ejemplo n.º 1
0
        public static Spread ReadXml(XmlReader reader)
        {
            Spread result = new Spread();

            if (reader.HasAttributes)
            {
                result.Self = System.Convert.ToString(reader.GetAttribute("Self"));
                result.FlattenerOverride       = (SpreadFlattenerLevel?)Parser.ParseEnum <SpreadFlattenerLevel>(reader.GetAttribute("FlattenerOverride"));
                result.AllowPageShuffle        = Parser.ParseBoolean(reader.GetAttribute("AllowPageShuffle"));
                result.ItemTransform           = System.Convert.ToString(reader.GetAttribute("ItemTransform"));
                result.ShowMasterItems         = Parser.ParseBoolean(reader.GetAttribute("ShowMasterItems"));
                result.PageCount               = System.Convert.ToInt32(reader.GetAttribute("PageCount"));
                result.BindingLocation         = System.Convert.ToInt32(reader.GetAttribute("BindingLocation"));
                result.PageTransitionType      = (PageTransitionTypeOptions?)Parser.ParseEnum <PageTransitionTypeOptions>(reader.GetAttribute("PageTransitionType"));
                result.PageTransitionDirection = (PageTransitionDirectionOptions)Parser.ParseEnum <PageTransitionDirectionOptions>(reader.GetAttribute("PageTransitionDirection"));
                result.PageTransitionDuration  = (PageTransitionDurationOptions)Parser.ParseEnum <PageTransitionDurationOptions>(reader.GetAttribute("PageTransitionDuration"));
            }

            if (reader.IsEmptyElement)
            {
                return(result);
            }

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if ((string)reader.Name == "Properties")
                    {
                        while (reader.Read())
                        {
                            if ((string)reader.Name == "")
                            {
                            }
                            else if ((string)reader.Name == "Properties")
                            {
                                if (reader.NodeType == XmlNodeType.EndElement)
                                {
                                    break;
                                }
                            }
                            else
                            {
                                if (reader.NodeType == XmlNodeType.Element)
                                {
                                    Debug.WriteLine("Unrecognized element: {0} in element: {1}", reader.Name, "Spread - Properties");
                                }
                            }
                        }
                    }
                    else if ((string)reader.Name == "FlattenerPreference")
                    {
                        result.FlattenerPreference = FlattenerPreference.ReadXml(reader);
                    }
                    else if ((string)reader.Name == "Page")
                    {
                        result.Children.Add(Page.ReadXml(reader));
                    }
                    else if ((string)reader.Name == "TextFrame")
                    {
                        result.Children.Add(TextFrame.ReadXml(reader));
                    }
                    else if ((string)reader.Name == "Rectangle")
                    {
                        result.Children.Add(Rectangle.ReadXml(reader));
                    }
                    else
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            Debug.WriteLine("Unrecognized element: {0} in element: {1}", reader.Name, "Spread");
                        }
                    }
                }
            }

            return(result);
        }