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

Allowing User to Set Theme

6 Answers 283 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
Nancy
Top achievements
Rank 1
Nancy asked on 29 Oct 2009, 10:09 PM
I have a winforms application and would like to allow the user to change the theme they prefer from a pre-defined set of themes.

I watched the video at http://tv.telerik.com/winforms/themes/radcontrols-winforms-theme but it doesn't really explain what the radThemeManager does.  

How is the radThemeManager used and how does it work with the pre-defined themes?

6 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 03 Nov 2009, 06:23 PM

Hello Nancy,

RadThemeManager is not necessary for using our predefined theme components. Please refer to this help article which describes the process of using a predefined theme component. If you want to change the theme of the entire application during runtime, this article expains the API that you should use.

As to the RadThemeManager itself, it is useful when you want to load a custom theme in your project. For additional information, refer to this and this help articles.

If you have additional questions, feel free to contact us.

Regards,

Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Nancy
Top achievements
Rank 1
answered on 04 Nov 2009, 09:56 AM
Thanks for the response.

The use of the manager much clearer.
0
Doug
Top achievements
Rank 1
answered on 18 Dec 2012, 06:58 PM

I just watched the video at http://tv.telerik.com/watch/winforms/visualstylebuilder/changing-themes-at-run-time-with-radcontrols-winforms.  I'm trying that example of loading Telerik themes and custom themes onto menus with the methods in the video:

private void CreateThemeMenuItem(RadMenuItem parentMenu, string menuName, string themeName)
{
    RadMenuItem newMenuItem = new RadMenuItem(menuName, themeName);
    newMenuItem.Click += new EventHandler(themeMenuItem_Click);
    parentMenu.Items.Add(newMenuItem);
}
void themeMenuItem_Click(object sender, EventArgs e)
{
    RadMenuItem menuItem = sender as RadMenuItem;
    ThemeResolutionService.ApplicationThemeName = menuItem.Tag as string;
}

What doesn't work for me is the code for loading custom themes:

foreach (string themeName in radThemeManager1.LoadedThemeNames.Distinct<string>())
    CreateThemeMenuItem(mnuCustomThemes, themeName, themeName);

Here in VS2010, radThemeManager1 doesn't have a property LoadedThemeNames.  What should this code be now?

Thank you,
Gary


0
Nikolay
Telerik team
answered on 21 Dec 2012, 12:20 PM
Hi Gary,

Although the RadThemeManager still exists (for backward compatibility), the preferred way to save a theme is to do it in a single *.tssp file that is loaded as described here.

Let's say that you have dragged and dropped a few Telerik themes and you have loaded your CustomTheme as suggested by the article. You can then check which themes are loaded in the memory and create respective menu items as shown below:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
 
        ThemeResolutionService.LoadPackageResource(@"WindowsFormsApplication9.CustomTheme.tssp");
 
        IEnumerable<string> themes = ThemeRepository.AvailableThemeNames;
        foreach (string thN in themes)
        {
            CreateThemeMenuItem(thN);
        }
    }
 
    private void CreateThemeMenuItem(string themeName)
    {
        RadMenuItem newMenuItem = new RadMenuItem(themeName, themeName);
        newMenuItem.Click += new EventHandler(themeMenuItem_Click);
        themesMenuItem.Items.Add(newMenuItem);
    }
 
    void themeMenuItem_Click(object sender, EventArgs e)
    {
        RadMenuItem menuItem = sender as RadMenuItem;
        ThemeResolutionService.ApplicationThemeName = menuItem.Tag as string;
    }
}

Depending on which Telerik themes you have dropped on the form, the result from this code snippet could be:


I hope this helps.

Regards,
Nikolay
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
0
k
Top achievements
Rank 1
answered on 07 Aug 2016, 02:36 PM
I was able to give a sample Windows
0
Hristo
Telerik team
answered on 08 Aug 2016, 03:51 PM
Hello,

Thank you for writing.

Could you please elaborate in details your scenario so that we would be able to help you? In case you need information on how themes can be used, you can refer to the documentation articles in this section: Themes.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Tags
Themes and Visual Style Builder
Asked by
Nancy
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Nancy
Top achievements
Rank 1
Doug
Top achievements
Rank 1
k
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or