Export (0) Print
Expand All

ColorableItem Class

Provides a default implementation of the VSIP interface IVsColorableItem.

This API is not CLS-compliant. 


Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)
  Microsoft.VisualStudio.Package.LanguageService.11.0 (in Microsoft.VisualStudio.Package.LanguageService.11.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.12.0 (in Microsoft.VisualStudio.Package.LanguageService.12.0.dll)

public class ColorableItem : IVsColorableItem, 
	IVsHiColorItem, IVsMergeableUIItem

The ColorableItem type exposes the following members.

Public methodColorableItemInitializes the ColorableItem class and accepts all the information needed to describe a colorable item.

Public methodEqualsDetermines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetCanonicalNameGets the canonical name of a colorable item.
Public methodGetColorDataGet the specified high color foreground or background element.
Public methodGetDefaultColorsReturns the foreground and background color for this colorable item.
Public methodGetDefaultFontFlagsReturns the font attributes for this colorable item.
Public methodGetDescriptionReturns a description for this colorable item.
Public methodGetDisplayNameReturns the name of this colorable item.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetMergingPriorityReturns the priority this colorable item has when compared to other colorable items of the same name.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

This class is used for defining custom colors used by the language service for syntax highlighting. The GetColorableItem method on your implementation of the LanguageService class returns a specified IVsColorableItem object.

Notes to Implementers

This class can be used to implement the IVsColorableItem interface. Just construct a new instance of this class for each custom color you wish to implement, and then return the appropriate colorable item from the GetColorableItem method.

The ideal place to construct an array of custom colors is in the constructor of your implementation of the LanguageService class. If you support customization of the colors, then you would initialize this array in LanguageService.CreateDocumentProperties after the DocumentProperties object was created.

Notes to Callers

This class is typically used by the Colorizer class in its implementation of ColorizeLine.

This shows an example of the LanguageService implementation that supports two custom colors (more can be easily added). Note that the first colorable item is never actually referenced and is used as a placeholder (all color indices passed to GetColorableItem start at 1).

namespace MyLanguagePackage
    public class MyLanguageService : LanguageService
        private ColorableItem[] m_colorableItems;

        public MyLanguageService()
            : base()
                m_colorableItems = new ColorableItem[] {
                    new ColorableItem("Text",
                    new ColorableItem("Keyword",
                    new ColorableItem("Comment",

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2015 Microsoft