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

Problem with theme loaded as Resource

5 Answers 517 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Web
Top achievements
Rank 1
Web asked on 14 Dec 2006, 03:26 PM
I have Togglebuttons and ComboBoxes and TextBoxes on my Winform. I created for each one a theme and saved the themes under Resources (i am using VS 2005). in your documentation you said that you just have to change the xml files proberty to embedded resources and the go to the themeManager and choose "load file from resources"  and change to filetype Resources. unfortunately when i give it the path it always looks for it on the local drive or in my visual studio root folder i can get it work locally somehow but as soon as i deploy my solution and open it up on a different computer it starts looking again for it locally filesystem instead of the Resource folder of my project.
Thank you

5 Answers, 1 is accepted

Sort by
0
Mike
Telerik team
answered on 15 Dec 2006, 06:15 PM
Hello Kerstin,

We made a very simple project that demonstrates how to load a theme from a resource. The application's only form contains a RadButton which uses a theme, loaded from the resource of the application. The theme is originally placed in a folder of the project, and compiled as "Embedded Resource". Once you build the application the theme is loaded from the resources.
What we did to build this project:
1. We place the RadButton on the Form.
2. Opened the Theme Builder from control's smart tag option.
3. We created a sample theme and save it in a new project folder - Resources.
4. We included the Resources folder and the theme file in the project and set the "compile as embedded resource" option of the file.
5. We selected New Theme Manager from smart tag and configured it to use the theme from the application resources.

Note that the resource name may differ in C# and VB.NET. C# uses the project namespace combined with the file path as a name for the resource.
If you are not sure about the resource name, you can use the famous Reflector tool to check that up, first time you build the application.

Sincerely yours,
Mike
the telerik team
0
Bryan Brannon
Top achievements
Rank 2
answered on 07 May 2007, 08:25 PM
I am using the ThemeManager to load my themes as a resource.  I followed the directions as described above but my theme does not reflect in design-time mode nor is it listed in the control's themes (design-time dropdown) as it does if loaded from a file.  In runtime, everything looks fine and works well.

It would be nice to have only one ThemeManager per application and then reuse the themes throught the forms/controls without having to re-add them per control/form.
0
Mike
Telerik team
answered on 08 May 2007, 02:43 PM
Hello Bryan,

It is true that when loading a theme from resource, the designer is not able to load the resource, since it compiles within the application executable after building. There is a way for to workaround this problem by automating the VS2005 environment to find the actual file, corresponding to the referenced resource. Unfortunately this solution will be available after SP1 release.

As to loading theme files only once per application, this functionality is actually achievable. You have two options. If your application has a "main" form that loads always when your application runs, you can add a single ThemeManager component in that main form and load all themes required for the whole application. Since themes are registered in a static storage, they will be available through the application lifetime. The other option is to use the available themes-related API instead of the ThemeManager component. For each theme to be loaded you should use the following statement:

ThemeResolutionService.RegisterThemeFromStorage(ThemeStorageType.Resource,
                "Telerik.Examples.WinControls.Resources.CollapsiblePaneDefault.xml");


This method should be used in a routine that will execute before any RadControl is displayed, for example in the Load method of the main form.
 

Kind regards,
Mike
the telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Web
Top achievements
Rank 1
answered on 24 Sep 2007, 10:13 PM
I followed your example (unfortunately the .zip file does not work gives errors on the form so i can not see the configuration). i have the theme file created and it is on the folder resources in my solution with the property embedded resource. first of all in my theme manager i get a obecjt not referenced error when i embed it as resource if i choose file (path goes to same resource folder) then it works fine- but of cource just on my computer. I need to get it working pretty quick so a qucik response would be appreciated. I use the Q1 2007 release and C#.

Thank you!
0
Mike
Telerik team
answered on 25 Sep 2007, 05:00 PM
Hi Ryan,

Your problem is most probably related to not specifying the correct resource name. You can obtain the correct resource name using the .net  Reflector tool for example (as suggested in the previous post). Please note that due to missing functionality in the older Q1 2007, themes would not load in the designer when Resource StorageType is used for specifying theme file location. The case would be the same if relative file path is used. We implemented this in Q2 2007 version and I strongly suggest you use the new one.

As for loading themes from file, you should have in mind that the file name is generated automatically, and references the full file path on your hard drive. It is quite possible that this path is not valid when deploying the application on another station. For that reason you should use embedded resource OR file name relative to application's executable file. Here is example for relative path:
  • If your application compiles in "C:\Prorects\MyApp\bin\debug" and the theme file is located in "MyApp\Resources" folder, the relative path would be: "..\..\Resources\MyThemeFileName.xml"

In Q2 2007 this will work in the designer as well.

  
Kind regards,

Mike
the Telerik team


Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Web
Top achievements
Rank 1
Answers by
Mike
Telerik team
Bryan Brannon
Top achievements
Rank 2
Web
Top achievements
Rank 1
Share this question
or