The most common kind of )
CompiledIconId. This represents icons that have been compiled into an assembly's resources. ReSharper also supports several other types of icons:
CompiledIconIdrepresents icons that have been compiled into an assembly's resources.
ColorIconIdrepresents an icon that is a solid colour.
CompositeIconIdis an icon that is composed of other
EffectOnIconIdcreates an icon based on another
IconId, applying alpha, made monochrome based on a tint colour, and/or with a blur radius.
ShellFileIconIdis a file type icon for a given extension.
RotatedIconIdrepresent icons that are animated.
The icon types don't apply theming, and when creating a new icon based on an existing icon, will create a WPF
ImageSource that uses the existing icon, meaning WPF will be responsible for scaling the base icon.
An icon representing a solid colour can be defined by creating a new instance of
ColorIconId and passing in a
Color. The resulting icon will be a solid square of that colour.
CompositeIconId will combine other icons into a single image, useful for applying overlays. To create a composite icon, call one of the static
Compose methods, passing in the
IconId of the icons to combine. The images are composed in left to right order. That is, the
Compose method's leftmost argument being applied first, and subsequent arguments are applied on top.
A more realistic example shows how to create an icon that represents a private method (although this is unlikely to be required in user code, as the PSI can provide this icon automatically for a given declared element):
Applying effects to icons
EffectOnIconId creates a new
IconId based on an existing icon, but with various effects applied. The new icon can have an alpha opacity value applied, turn the icon monochrome, apply a blur radius, or any combination of the three. Alpha transparency is applied as a double value from 0 to 1, where 1 is no transparency and 0 is fully transparent. Applying the blur radius requires passing in a double value that represents the radius in WPF's Device Independent Units (1/96 of an inch).
When making the icon monochrome, if the base icon is a WPF vector image, the brushes associated with the vector geometries are replaced with the given colour. When the base icon is a bitmap, the bitmap is rendered and the monochrome colour is applied.
File type icons
Icons for file types can be retrieved using the
ShellFileIconId class. These icon IDs ask the operating system for the icon to represent a given file extension (the dot should be included), at a given file size. The returned icon is also converted to monochrome, if the current theme is a monochrome theme (such as Visual Studio's Light or Dark theme. The Blue theme is not, and the icon is not converted if this is the current theme).
Small icons are 16×16 and large icons are 32×32. Since the icons are raster images, they will not scale well, so try to use the appropriate size for the use case. Note that the resulting image does get created for the current DPI, so it will still display correctly in high DPI scenarios.
RotatedIconId classes are used to get a static image for scenarios where animation is not supported. The
AnimatedIconId is simply a base class, and
RotatedIconId is used to identify and provide another
IconId as a static icon.
RotatedIconId is added to a WPF UI using the
ThemedIconViewImage control (which can be used instead of the WPF
Image element), then the static image is continuously rotated by a WPF animation, specified in
RotatedIconId.AnimatedRenderTransform. This is how the animated icons in the unit test runner are rendered.
For Windows Forms, the individual frames of a rotated animation can be retrieved using
PresentableItemRenderer class makes use of this to render animation frames for
IPresentableItem objects that include frames.
Alternatively, animation can be achieved by creating icons for individual frames and updating an
IProperty<IconId> with each frame. Again, this can be used with
ThemedIconViewImage, which will display each frame as a static image, and update when the icon changes for each frame. This is how the solution wide analysis round icon in the status bar is handled.