次の方法で共有


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.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)
  Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)

Syntax

'宣言
<ComVisibleAttribute(True)> _
<CLSCompliantAttribute(False)> _
Public Class ColorableItem _
    Implements IVsColorableItem, IVsHiColorItem, IVsMergeableUIItem
'使用
Dim instance As ColorableItem
[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

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

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.Package.ColorableItem

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.

See Also

Reference

ColorableItem Members

Microsoft.VisualStudio.Package Namespace