Exemple #1
0
        private void DeserializePartiallyThemeFromReader(XmlReader reader, string themeLocation)
        {
            if (reader.ReadToFollowing("XmlTheme"))
            {
                new StyleXmlSerializer(true).ReadObjectElement(reader, this);
                reader.ReadEndElement();
            }
            else
            {
                MessageBox.Show("Error reading theme: element XmlTheme not found in the xml file '" + this.themeSource.ThemeLocation + "'");
            }

            if (this.builderRegistrations == null)
            {
                return;
            }

            foreach (XmlStyleBuilderRegistration reg in this.BuilderRegistrations)
            {
                XmlStyleSheet styleSheet = (reg.BuilderData as XmlStyleSheet);
                if (styleSheet != null)
                {
                    if (themeLocation != null)
                    {
                        styleSheet.SetThemeLocation(themeLocation);
                    }
                    styleSheet.SetThemeName(this.ThemeName);
                }
            }
        }
Exemple #2
0
 private void StyleDesigner_Load(object sender, EventArgs e)
 {
     if (CurrentStyle == null)
     {
         CurrentStyle = new XmlStyleSheet();
     }
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the XmlTheme class from XmlStyleSheet,
 /// control type, and element type.
 /// </summary>
 /// <param name="style"></param>
 /// <param name="controlType"></param>
 /// <param name="elementType"></param>
 public XmlTheme(XmlStyleSheet style, string controlType, string elementType)
 {
     this.themeName            = "";
     this.builderRegistrations = new XmlStyleBuilderRegistration[]
     {
         new XmlStyleBuilderRegistration(style, controlType, elementType)
     };
 }
Exemple #4
0
        /// <summary>
        /// Saves the current Stylesheet object tree to stream
        /// </summary>
        /// <param name="toStream"></param>
        public void SaveStylesheet(Stream toStream)
        {
            //XmlSerializer ser = new XmlSerializer(typeof(XmlStyleSheet));
            //ser.Serialize(toStream, new XmlStyleSheet(this));
            XmlWriter     writer    = XmlWriter.Create(toStream);
            XmlStyleSheet converted = new XmlStyleSheet(this);

            new StyleXmlSerializer().WriteObjectElement(writer, converted);
        }
Exemple #5
0
        /// <summary>
        /// Read the current Stylesheet object from stream /file/, previously created with <see cref="SaveStylesheet"/>
        /// </summary>
        /// <param name="fromStream"></param>
        /// <returns></returns>
        public static StyleSheet LoadStylesheet(Stream fromStream)
        {
            //XmlSerializer ser = new XmlSerializer(typeof(XmlStyleSheet));
            XmlStyleSheet res    = new XmlStyleSheet();
            XmlReader     reader = XmlReader.Create(fromStream);

            new StyleXmlSerializer().ReadObjectElement(reader, res);

            return(res.GetStyleSheet());
        }
        public XmlStyleBuilderRegistration(XmlStyleSheet style, string controlType, string elementType)
        {
            this.builderData         = (XmlBuilderData)style;
            this.stylesheetRelations = new RadStyleSheetRelationList(1);
            RadStylesheetRelation stylesheetRelation = new RadStylesheetRelation();

            this.StylesheetRelations.Add(stylesheetRelation);
            stylesheetRelation.RegistrationType = BuilderRegistrationType.ElementTypeControlType;
            stylesheetRelation.ElementType      = elementType ?? string.Empty;
            stylesheetRelation.ControlType      = controlType ?? string.Empty;
        }
        private void Deserialize()
        {
            //ensure thread safety
            lock (syncRoot)
            {
                if (!string.IsNullOrEmpty(this.partiallyLoadedXmlData))
                {
                    XmlStyleSheet xmlStyleSheet = new XmlStyleSheet();
                    using (TextReader textReader = new StringReader(this.partiallyLoadedXmlData))
                    {
                        using (XmlReader reader = XmlReader.Create(textReader))
                        {
                            StyleXmlSerializer ser = new StyleXmlSerializer(false);
                            ser.PropertiesProvider = this.propertiesProvider;

                            ser.ReadObjectElement(reader, xmlStyleSheet);
                        }
                    }

                    this.partiallyLoadedXmlData = null;

                    base.PropertySettingGroups.Clear();
                    xmlStyleSheet.DeserializePropertySettingGroups(base.PropertySettingGroups);
                }
                else if (loadedXmlStyleSheet != null)
                {
                    base.PropertySettingGroups.Clear();
                    loadedXmlStyleSheet.DeserializePropertySettingGroups(base.PropertySettingGroups);
                    this.loadedXmlStyleSheet = null;
                }

                this.loaded = true;

                if (this.LoadedCompletely != null)
                {
                    this.LoadedCompletely(this, EventArgs.Empty);

                    //this event occurs only once in the lifetime of the object, so remove the event handlers
                    this.LoadedCompletely = null;
                }
            }
        }
Exemple #8
0
 public void SaveXML(string themeName, string fileName)
 {
     using (XmlTextWriter xmlTextWriter = new XmlTextWriter(fileName, Encoding.UTF8))
     {
         xmlTextWriter.Formatting = Formatting.Indented;
         XmlTheme xmlTheme = new XmlTheme();
         xmlTheme.ThemeName    = themeName;
         xmlTheme.ThemeVersion = "2.0";
         XmlStyleSheet xmlStyleSheet = new XmlStyleSheet();
         foreach (PropertySettingGroup propertySettingGroup in this.PropertySettingGroups)
         {
             xmlStyleSheet.PropertySettingGroups.Add(new XmlPropertySettingGroup(propertySettingGroup));
         }
         xmlTheme.BuilderRegistrations = new XmlStyleBuilderRegistration[1]
         {
             new XmlStyleBuilderRegistration(this)
             {
                 BuilderData = (XmlBuilderData)xmlStyleSheet
             }
         };
         xmlTheme.SaveToWriter((XmlWriter)xmlTextWriter);
     }
 }
 public PartiallyLoadableStyleSheet(XmlStyleSheet loadedXmlStyleSheet, string themeLocation)
     : base(themeLocation)
 {
     this.loadedXmlStyleSheet = loadedXmlStyleSheet;
 }