Allowing User to Set Theme

7 posts, 0 answers
  1. Nancy
    Nancy avatar
    4 posts
    Member since:
    Oct 2008

    Posted 29 Oct 2009 Link to this post

    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?
  2. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 03 Nov 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Nancy
    Nancy avatar
    4 posts
    Member since:
    Oct 2008

    Posted 04 Nov 2009 Link to this post

    Thanks for the response.

    The use of the manager much clearer.
  5. Doug
    Doug avatar
    50 posts
    Member since:
    Jul 2012

    Posted 18 Dec 2012 Link to this post

    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


  6. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 21 Dec 2012 Link to this post

    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.
  7. k
    k avatar
    1 posts
    Member since:
    Aug 2016

    Posted 07 Aug in reply to Nikolay Link to this post

    I was able to give a sample Windows
  8. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 08 Aug Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready