Partilhar via


ColorableItem Class

Definition

Important

This API is not CLS-compliant.

Provides a default implementation of the VSIP interface IVsColorableItem.

public ref class ColorableItem : Microsoft::VisualStudio::TextManager::Interop::IVsColorableItem, Microsoft::VisualStudio::TextManager::Interop::IVsHiColorItem, Microsoft::VisualStudio::TextManager::Interop::IVsMergeableUIItem
[Windows::Foundation::Metadata::WebHostHidden]
class ColorableItem : Microsoft::VisualStudio::TextManager::Interop::IVsColorableItem, Microsoft::VisualStudio::TextManager::Interop::IVsHiColorItem, Microsoft::VisualStudio::TextManager::Interop::IVsMergeableUIItem
[System.CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(true)]
public class ColorableItem : Microsoft.VisualStudio.TextManager.Interop.IVsColorableItem, Microsoft.VisualStudio.TextManager.Interop.IVsHiColorItem, Microsoft.VisualStudio.TextManager.Interop.IVsMergeableUIItem
[System.Runtime.InteropServices.ComVisible(true)]
public class ColorableItem : Microsoft.VisualStudio.TextManager.Interop.IVsColorableItem, Microsoft.VisualStudio.TextManager.Interop.IVsHiColorItem, Microsoft.VisualStudio.TextManager.Interop.IVsMergeableUIItem
[<System.CLSCompliant(false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ColorableItem = class
    interface IVsColorableItem
    interface IVsHiColorItem
    interface IVsMergeableUIItem
[<System.Runtime.InteropServices.ComVisible(true)>]
type ColorableItem = class
    interface IVsColorableItem
    interface IVsHiColorItem
    interface IVsMergeableUIItem
Public Class ColorableItem
Implements IVsColorableItem, IVsHiColorItem, IVsMergeableUIItem
Inheritance
ColorableItem
Attributes
Implements

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)  
                };  
        }  
    }  
}  

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 Inheritors

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(Int32, IVsColorableItem) 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 CreateDocumentProperties(CodeWindowManager) after the DocumentProperties object was created.

Notes to Callers

This class is typically used by the Colorizer class in its implementation of ColorizeLine(Int32, Int32, IntPtr, Int32, UInt32[]).

Constructors

ColorableItem(String, String, COLORINDEX, COLORINDEX, Color, Color, FONTFLAGS)

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

Methods

GetCanonicalName(String)

Gets the canonical name of a colorable item.

GetColorData(Int32, UInt32)

Get the specified high color foreground or background element.

GetDefaultColors(COLORINDEX[], COLORINDEX[])

Returns the foreground and background color for this colorable item.

GetDefaultFontFlags(UInt32)

Returns the font attributes for this colorable item.

GetDescription(String)

Returns a description for this colorable item.

GetDisplayName(String)

Returns the name of this colorable item.

GetMergingPriority(Int32)

Returns the priority this colorable item has when compared to other colorable items of the same name.

Applies to