Thursday, 14 April 2011

Adding a custom image to a folder or view in Service Manager 2010

JR52MAR posted a comment earlier on my post about my Asset Management MP asking how I added the custom graphics for the views and folders.


I'll show you here how to add them for the folders and use the Mobile Assets as an example, but the views are the same principal.

  1. Grab an image you want to use and get it sized appropriately, I used a 16 x 16 pixel image, called it mobilephone16x16.png and saved it in the same dir as the MP I was creating.
  2. Add this XML at the bottom of your MP to reference the file:
    <Resources>
     <Image ID="Image.MobilePhoneFolder.16x16" Accessibility="Public" FileName="mobilephone16x16.png" HasNullStream="false"/>
    </Resources>
  3. Add this XML to the Categories section (after TypeDefinitions and before Presentation):
    <Categories>
     <Category ID="Category.MobilePhoneFolderImage16x16" Target="Image.MobilePhoneFolder.16x16" Value="System!System.Internal.ManagementPack.Images.u16x16Icon"/>
    </Categories>
  4. Add this XML to the ImageReferences section (before StringResources):
    <ImageReferences>
    <ImageReference ElementID="Folder.Mobiles" ImageID="Image.MobilePhoneFolder.16x16"/>
    </ImageReferences>
  5. Use the new-mpbfile.ps1 powershell script to bundle the MP and images together into a MPB file.
So...
Step 1 is find and save you picture in the right size/format
Step 2 is add the section that tells the MP where to find the graphic
Step 3 tells the MP what size and usage etc the image is
Step 4 tells the MP to link the image to the folder (this is where you could point the image at a view instead)
Step 5 bundles the images and MP together into a MPB for importing

No comments:

Post a Comment