Example #1
0
        public StyleSheet GetStyleSheet()
        {
            if (this.partiallyLoadedXmlData != null)
            {
                ThemeResolutionService.EnsureThemeRegistered(themeName);
                Theme theme = ThemeResolutionService.GetTheme(themeName);
                return(new PartiallyLoadableStyleSheet(theme, this.partiallyLoadedXmlData, this.ThemeLocation));
            }
            else
            {
                return(new PartiallyLoadableStyleSheet(this, this.ThemeLocation));
            }

            /*
             * StyleSheet res = new StyleSheet();
             *          if (this.PropertySettingGroups == null)
             *          {
             *                  return res;
             *          }
             *
             * PropertySettingGroupCollection resGroups = res.PropertySettingGroups;
             * XmlPropertySettingGroupCollection xmlGroups = this.PropertySettingGroups;
             *
             * DeserializePropertySettingGroups(res.PropertySettingGroups);
             *
             * return res;*/
        }
 public static void RegisterElementTypeDefaultStyleBuilder(
     string themeName,
     string elementTypeName,
     StyleGroup builder)
 {
     ThemeResolutionService.EnsureThemeRegistered(ThemeResolutionService.ControlDefaultThemeName);
     ThemeResolutionService.TripleNameKey tripleNameKey = new ThemeResolutionService.TripleNameKey("", themeName, elementTypeName);
     ThemeResolutionService.registeredBuildersDefaultByElementType[(object)tripleNameKey] = (object)builder;
 }
 public static void RegisterStyleBuilderByControlName(
     string controlName,
     string elementTypeName,
     StyleGroup builder,
     string themeName)
 {
     ThemeResolutionService.EnsureThemeRegistered(themeName);
     ThemeResolutionService.TripleNameKey tripleNameKey = new ThemeResolutionService.TripleNameKey("__ID" + controlName, elementTypeName, themeName);
     ThemeResolutionService.registeredBuildersByElementTypeControlID[(object)tripleNameKey] = (object)builder;
 }
 public static void RegisterControlStyleBuilder(
     string controlTypeName,
     string elementTypeName,
     StyleGroup builder,
     string themeName)
 {
     ThemeResolutionService.EnsureThemeRegistered(themeName);
     ThemeResolutionService.TripleNameKey tripleNameKey = new ThemeResolutionService.TripleNameKey(controlTypeName, elementTypeName, themeName);
     ThemeResolutionService.registeredBuildersByElementTypeControlType[(object)tripleNameKey] = (object)builder;
     ThemeResolutionService.RaiseThemeChanged(themeName, controlTypeName);
 }
Example #5
0
        /// <summary>
        /// Deserializes a theme from a given %XmlTheme:Telerik.WinControls.XmlTheme%
        /// instance. Resulting theme is registered within ThemeReolutionService and can be obtained using the following
        /// ThemeResolutionService.GetTheme(xmlTheme.ThemeName)
        /// </summary>
        /// <param name="xmlTheme">An instance of the <see cref="XmlTheme"/>class
        /// which is deserialized.</param>
        /// <param name="registerBuildersWithThemeResService">Defines whether new <see cref="StyleBuilderRegistration"/>
        /// instances are added in the <see cref="ThemeResolutionService"/>.</param>
        public static void Deserialize(XmlTheme xmlTheme, bool registerBuildersWithThemeResService)
        {
            //ThemeResolutionService.BeginEditTheme(xmlTheme.ThemeName);

            if (string.IsNullOrEmpty(xmlTheme.ThemeName))
            {
                return;
            }

            ThemeResolutionService.SuspendThemeChange();

            try
            {
                //Copy theme parameters
                ThemeResolutionService.EnsureThemeRegistered(xmlTheme.ThemeName);
                Theme themeInstance = ThemeResolutionService.GetTheme(xmlTheme.ThemeName);
                foreach (KeyValuePair <string, object> dictionaryEntry in xmlTheme.ThemeProperties)
                {
                    themeInstance.ThemeProperties[dictionaryEntry.Key] = dictionaryEntry.Value;
                }

                string[] themeNames = xmlTheme.ThemeName.Split(',', ';');

                if (xmlTheme.HasRepository)
                {
                    foreach (string themeName in themeNames)
                    {
                        //If a repository for this theme already exists, both are merged.
                        ThemeResolutionService.RegisterThemeRepository(xmlTheme.StyleRepository, themeName.Trim());
                    }
                }

                //Register StyleBuilders
                if (registerBuildersWithThemeResService && xmlTheme.BuilderRegistrations != null)
                {
                    foreach (XmlStyleBuilderRegistration registration in xmlTheme.BuilderRegistrations)
                    {
                        foreach (string themeName in themeNames)
                        {
                            ThemeResolutionService.RegisterStyleBuilder(registration.GetRegistration(), themeName.Trim());
                        }
                    }
                }
            }
            finally
            {
                ThemeResolutionService.ResumeThemeChange();
            }
        }
        public static void RegisterStyleBuilder(StyleGroup styleBuilderRegistration, string themeName)
        {
            foreach (StyleRegistration registration in styleBuilderRegistration.Registrations)
            {
                switch (registration.RegistrationType)
                {
                case "ElementTypeDefault":
                    ThemeResolutionService.RegisterElementTypeDefaultStyleBuilder(themeName, registration.ElementType, styleBuilderRegistration);
                    continue;

                case "ElementTypeControlType":
                    ThemeResolutionService.RegisterControlStyleBuilder(registration.ControlType, registration.ElementType, styleBuilderRegistration, themeName);
                    continue;

                case "ElementTypeControlName":
                    ThemeResolutionService.RegisterStyleBuilderByControlName(registration.ControlName, registration.ElementType, styleBuilderRegistration, themeName);
                    continue;

                default:
                    continue;
                }
            }
            ThemeResolutionService.EnsureThemeRegistered(themeName);
        }