DX WinForms Skins without Requiring Skin Assemblies
For some time I’d wanted to find a way to make use of the skins provided with the DevExpress WinForms controls without deploying and loading the optional skin assemblies. If you just want to use one of the custom skins DevExpress provides, it may be overkill to ship and load 7MB of assemblies for this purpose.
Recently I was lucky enough to hang out with much of the team from DevExpress, as well as fellow members of the DX-Squad, at DevConnections in Las Vegas. Michael Proctor (who was interested in accomplishing something similar) and I spoke with Azret Botash, who works on the .NET controls at DevExpress. Azret indicated that it was already possible to load the WinForms skins without the optional skin assemblies. He then proceeded to download and install Reflector on a conference PC before disassembling one of the DX WinForms samples and highlighting a few of the key classes involved, such as SkinXmlCreator and SkinXmlLoader.
After returning home, I started digging through the samples that ship with DXperience and was able to assemble various pieces of the puzzle to make my own SkinBlobXmlFileCreator class. It descends from SkinXmlCreator and then uses some very basic code to load a skin directly from its .XML and .BLOB files rather than from an assembly. These .XML and .BLOB files ship with DXperience and are located here:
C:\Program Files\DevExpress 201X.Y\Components\Sources\DevExpress.BonusSkins\SkinData
C:\Program Files\DevExpress 201X.Y\Components\Sources\DevExpress.OfficeSkins\SkinData
C:\Program Files\DevExpress 201X.Y\Components\Sources\DevExpress.Utils\SkinData
Using this new class, you can load a skin with the following lines:
SkinBlobXmlFileCreator creator = new SkinBlobXmlFileCreator("VS2010", Application.StartupPath + "\\", "VS2010.skin.xml");
SkinManager.Default.RegisterSkin(creator);
UserLookAndFeel.Default.SetSkinStyle("VS2010");
This works without deploying or referencing the BonusSkins assembly. Only the “VS2010.skin.xml” and “VS2010.blob” files are required.
You can download the source for the SkinBlobXmlFileCreator here.
Really interested in seeing this, but the zip file seems to be corrupted. Any chance you could upload it again?
phrenetic
phrenetic
December 10, 2011 at 12:10 pm
Thanks for the interest. Sorry about the broken link – it’s fixed now!
nwoolls
December 10, 2011 at 3:11 pm
I have created a custom skin using the SkinEditor and Devexpress Default Style template, and when loading the skin with the “DevExpress.Skins.SkinManager.Default.RegisterAssembly ….” the application’s memory at runtime increases from 19MB to 45MB.
Loading the skin by using this class, the memory at runtime increases from 19MB to only 26MB. That’s a big difference.
Thanks for the class.
Florin
December 17, 2011 at 4:28 am
I have the latest 11.2 Winform Devexpress Controls, I don’t quite see how to save my skin as a .blob file. Any Assistant you could provide would be great.
Mike Weeber
January 30, 2012 at 2:47 pm