Solution? dynamic use of themes

2 posts, 0 answers
  1. Holger Boskugel
    Holger Boskugel avatar
    24 posts
    Member since:
    Apr 2012

    Posted 19 Jun 2012 Link to this post

    Hello,

    After sticking a while how to use themes dynamicly we found a simple solution, don't imaging why the ThemeResolutionService not instances the required theme.

    ThemeResolutionService provides several methods to register a theme so we ware expecting he loads also the theme and instances it if required by setting ApplicationThemeName. It doesn't do so.

    Our solution is quiet simple. Take a Dictionary<string, RadThemeComponentBase> in class being alive the whole time your application runes (static class or like us in the AddIn class). If a theme is required so check your dictionary if theme is loaded otherwise create object (f.i. with Activator.CreateInstance<...>()) and add it to the dictionary. Now the theme is alive and each change on ThemeResolutionService.ApplicationThemeName uses the living theme.

    private void AddinModule_OfficeColorSchemeChanged(object sender,
                                         OfficeColorScheme theme)
    {
      string themeName = string.Format("Office2010{0}",
                              theme);
     
      if (!this.themes.ContainsKey(themeName))
      {
         switch (theme)
        {
          case OfficeColorScheme.Black:
            this.themes.Add(themeName,
                        Activator.CreateInstance<Office2010BlackTheme>());
            break;
     
          case OfficeColorScheme.Blue:
            this.themes.Add(themeName,
                        Activator.CreateInstance<Office2010BlueTheme>());
            break;
     
          case OfficeColorScheme.Silver:
            this.themes.Add(themeName,
                        Activator.CreateInstance<Office2010SilverTheme>());
            break;
        }
      }
     
      ThemeResolutionService.ApplicationThemeName = themeName;
    }

    Hope it helps others


    Regards from Leipzig

    Holger Boskugel
  2. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 22 Jun 2012 Link to this post

    Hello Holger,

    Thank you for sharing you solution with the community.

    In our latest release - Q2 2012 we introduced a new theming engine. It minimizes the start-up time and lowers the memory consumption of your application. Find further details in our dedicated blog. With this version there is no more need to use this solution because all themes are loaded on demand.

    We will appreciate your feedback regarding our new release. 
     
    Kind regards,
    Jack
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top