Jaa


Adding Icons to your custom IIS 7.0 Manager UI Modules

There is a lot of enthusiasm around building IIS UI modules that show up in the IIS Manager. The extensibility model that IIS 7.0 ships with is great and provides a lot of opportunity for developers to come up with nifty modules.

One thing that developers miss out is to add an icon for the UI module. If you register a UI module without an icon IIS Manager shows the default icon of a gear wheel.

Default

Its pretty simple to add an Icon to your module so that it looks neat in IIS Manager. One of the constructors of the ModulePageInfo class takes in icons in the form of image objects.

ModulePageInfo(Module, Type, String, String, Object, Object, String)

The two Object variables are for the smallImage and largeImage that IIS manager can use as icons for your module.

To use this constructor you have to embed the image files in your assembly. To do that add the image to your Visual Studio solution. In the Solution Explorer right click on the image and go to its properties. Change the Build Action to Embedded Resource.

ImageProperties

You can then create a Bitmap object from the embedded resource and pass it to the constructor of the ModulePageInfo.

Something like this.

 //Create a module description
System.IO.Stream icoStream = this.GetType().Assembly.GetManifestResourceStream("FindDebugModules.Debug.jpg");
System.Drawing.Bitmap ico = new System.Drawing.Bitmap(icoStream);
icoStream.Close();
ModulePageInfo modulePage = new ModulePageInfo(this, typeof(FindDebugModulesPage), "Find Debug Modules", "Find Debug Modules", ico, ico);

 

Note that the string you pass for GetManifestResourceStream is case sensitive. I had to struggle a bit to get the proper string and finally ended up listing all the resource names with Assembly.GetManifestResourceNames to find the right one.

Once you register the module in administration.config you will see that the image is shown as the icon of your module. The above code snippet is from the FindDebugModules UI module that I posted here.

Reference :

Comments