ColorableItem Class
Provides a default implementation of the VSIP interface IVsColorableItem.
This API is not CLS-compliant.
Inheritance Hierarchy
Object
Microsoft.VisualStudio.Package.ColorableItem
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)
Syntax
'Declaration
<ComVisibleAttribute(True)> _
<CLSCompliantAttribute(False)> _
Public Class ColorableItem _
Implements IVsColorableItem, IVsHiColorItem, IVsMergeableUIItem
[ComVisibleAttribute(true)]
[CLSCompliantAttribute(false)]
public class ColorableItem : IVsColorableItem,
IVsHiColorItem, IVsMergeableUIItem
[ComVisibleAttribute(true)]
[CLSCompliantAttribute(false)]
public ref class ColorableItem : IVsColorableItem,
IVsHiColorItem, IVsMergeableUIItem
[<ComVisibleAttribute(true)>]
[<CLSCompliantAttribute(false)>]
type ColorableItem =
class
interface IVsColorableItem
interface IVsHiColorItem
interface IVsMergeableUIItem
end
public class ColorableItem implements IVsColorableItem, IVsHiColorItem, IVsMergeableUIItem
The ColorableItem type exposes the following members.
Constructors
Name | Description | |
---|---|---|
ColorableItem | Initializes the ColorableItem class and accepts all the information needed to describe a colorable item. |
Top
Methods
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetCanonicalName | Gets the canonical name of a colorable item. | |
GetColorData | Get the specified high color foreground or background element. | |
GetDefaultColors | Returns the foreground and background color for this colorable item. | |
GetDefaultFontFlags | Returns the font attributes for this colorable item. | |
GetDescription | Returns a description for this colorable item. | |
GetDisplayName | Returns the name of this colorable item. | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetMergingPriority | Returns the priority this colorable item has when compared to other colorable items of the same name. | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Remarks
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.
Examples
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).
[C#]
namespace MyLanguagePackage
{
[Guid("B614A40A-80D9-4fac-A6AD-FC2868FFF7CD")]
public class MyLanguageService : LanguageService
{
private ColorableItem[] m_colorableItems;
public MyLanguageService()
: base()
{
m_colorableItems = new ColorableItem[] {
new ColorableItem("Text",
COLORINDEX.CI_SYSPLAINTEXT_FG,
COLORINDEX.CI_SYSPLAINTEXT_BK,
System.Drawing.Color.Empty,
System.Drawing.Color.Empty,
FONTFLAGS.FF_DEFAULT),
new ColorableItem("Keyword",
COLORINDEX.CI_MAROON,
COLORINDEX.CI_SYSPLAINTEXT_BK,
System.Drawing.Color.Empty,
System.Drawing.Color.Empty,
FONTFLAGS.FF_BOLD),
new ColorableItem("Comment",
COLORINDEX.CI_GREEN,
COLORINDEX.CI_SYSPLAINTEXT_BK,
System.Drawing.Color.Empty,
System.Drawing.Color.Empty,
FONTFLAGS.FF_DEFAULT)
};
}
}
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.