Item template: Project Tree Modifier extension
Item template: Custom Icons
In order to add custom icons to your project, you need to follow these steps:
- Add New Item
Project Tree Properties Provider extension
- This will add an IProjectTreePropertiesProvider export to your project type that will replace the project icon with a JavaScript Icon
- Add New Item -
Custom Icons
. This template does a few things:- Generates a new .imagemanifest file, that defines one image with 2 sources:
- .png file that will be used for 100 % dpi
- .xaml file that will be used for everything else
- Note that
Include in VSIX
is set to true
- Generates a new class (
Images1Monikers.cs
) that exposes a property to easily access the new image
- Generates a new .imagemanifest file, that defines one image with 2 sources:
- Update the file generated at step 2 to consume the ImageMoniker exposed at step 1
propertyValues.Icon = Images1Monikers.ProjectIconImageMoniker.ToProjectSystemType();
- Image manifest
-
Create a new xml file, name it to .imagemanifest (e.g.
Images1.imagemanifest
)<?xml version="1.0" encoding="utf-8"?> <ImageManifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/VisualStudio/ImageManifestSchema/2014"> <Symbols> <String Name="Resources" Value="/<AssemblyName>;Component/" /> <Guid Name="Images1Guid" Value="<GUID>" /> <ID Name="ProjectIcon" Value="0" /> </Symbols> <Images> <Image Guid="$(Images1Guid)" ID="$(ProjectIcon)"> <Source Uri="$(Resources)/Images/Images1ProjectIcon.xaml" /> <Source Uri="$(Resources)/Images/Images1ProjectIcon.png" > <Size Value="16" /> </Source> </Image> </Images> <ImageLists /> </ImageManifest>
-
Replace
<AssemblyName>
with your assembly name -
Replace
<GUID>
with a guid -
In the Properties page, set the following properties:
Build Action
toContent
Include in VSIX
toTrue
-
- Image Monikers
- Create a new
Images1Monikers.cs
fileusing System; using Microsoft.VisualStudio.Imaging.Interop; namespace <namespace> { public static class Images1Monikers { private static readonly Guid ManifestGuid = new Guid("<GUID>"); private const int ProjectIcon = 0; public static ImageMoniker ProjectIconImageMoniker { get { return new ImageMoniker { Guid = ManifestGuid, Id = ProjectIcon }; } } } }
- Replace
<GUID>
with the same value used in the image manifest - Replace
<namespace>
with your namespace
- Create a new
- Add images
- Add the the following images to your project under an
Images
folder- Images/Images1ProjectIcon.png
- Images/Images1ProjectIcon.xaml
- Set the
Build Action
for both images toResource
- Add the the following images to your project under an
- Consume the new Image Moniker from your code (see the Tutorial above)