This is a migrated thread and some comments may be shown as answers.

Solution? dynamic use of themes

1 Answer 124 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
Holger Boskugel
Top achievements
Rank 2
Holger Boskugel asked on 19 Jun 2012, 11:03 AM
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

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 22 Jun 2012, 08:02 AM
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 >>
Tags
Themes and Visual Style Builder
Asked by
Holger Boskugel
Top achievements
Rank 2
Answers by
Jack
Telerik team
Share this question
or