Udostępnij za pośrednictwem


IVsColorableItem Interface

Definition

Provides default font colors, font style, and item name information for a custom colorable item.

public interface class IVsColorableItem
public interface class IVsColorableItem
__interface IVsColorableItem
[System.Runtime.InteropServices.Guid("56694A40-78D0-45DD-AB15-681BC207579C")]
[System.Runtime.InteropServices.InterfaceType(1)]
public interface IVsColorableItem
[System.Runtime.InteropServices.Guid("56694A40-78D0-45DD-AB15-681BC207579C")]
[System.Runtime.InteropServices.InterfaceType(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown)]
public interface IVsColorableItem
[<System.Runtime.InteropServices.Guid("56694A40-78D0-45DD-AB15-681BC207579C")>]
[<System.Runtime.InteropServices.InterfaceType(1)>]
type IVsColorableItem = interface
[<System.Runtime.InteropServices.Guid("56694A40-78D0-45DD-AB15-681BC207579C")>]
[<System.Runtime.InteropServices.InterfaceType(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown)>]
type IVsColorableItem = interface
Public Interface IVsColorableItem
Derived
Attributes

Examples

This example is from a language service.

using Microsoft.VisualStudio.TextManager.Interop;  

namespace MyNamespace  
{  
    internal class MyColorItem : IVsColorableItem  
    {  
        //==========================================================  
        // Private fields.  
        private COLORINDEX foreColor;  
        private COLORINDEX backColor;  
        private FONTFLAGS fontFlags;  
        private string name;  
        private string displayName;  

        //==========================================================  
        // Public constructor.  

        public MyColorItem(string name,  
                           string displayName,  
                           COLORINDEX foreColor,  
                           COLORINDEX backColor,  
                           FONTFLAGS fontFlags)  
        {  
            this.name = name;  
            this.displayName = displayName;  
            this.foreColor = foreColor;  
            this.backColor = backColor;  
            this.fontFlags = fontFlags;  
        }  

        //==========================================================  
        // IVsColorableItem methods.  
        #region IVsColorableItem Members  

        int IVsColorableItem.GetDefaultColors(COLORINDEX[] piForeground,  
                                              COLORINDEX[] piBackground)  
        {  
            int retval = VSConstants.E_POINTER;  
            if (piForeground != null)  
            {  
                piForeground[0] = this.foreColor;  
                retval = VSConstants.S_OK;  
            }  
            if (piBackground != null)  
            {  
                piBackground[0] = this.backColor;  
            }  
            return retval;  
        }  

        int IVsColorableItem.GetDefaultFontFlags(out uint pdwFontFlags)  
        {  
            pdwFontFlags = (uint)this.fontFlags;  
            return VSConstants.S_OK;  
        }  

        int IVsColorableItem.GetDisplayName(out string pbstrName)  
        {  
            pbstrName = this.displayName;  
            return VSConstants.S_OK;  
        }  

        #endregion  
    }  

    //==============================================================  
    // Example of how to instantiate the MyColorItem class.  

    public class MyLanguageService  
    {  
        private ColorableItem[] colorableItemsList;  

        public MyLanguageService()  
        {  
            colorableItemsList = {  
                new MyColorableItem("MyLanguage- Text",  
                                    "MyLanguage- Text",  
                                    COLORINDEX.CI_SYSPLAINTEXT_FG,  
                                    COLORINDEX.CI_SYSPLAINTEXT_BK,  
                                    FONTFLAGS.FF_BOLD),  

                new MyColorableItem("MyLanguage- Keyword",  
                                    "MyLanguage- Keyword",  
                                    COLORINDEX.CI_MAROON,  
                                    COLORINDEX.CI_SYSPLAINTEXT_BK,  
                                    FONTFLAGS.FF_BOLD),  

                new MyColorableItem("MyLanguage- Operator",  
                                    "MyLanguage- Operator",  
                                    COLORINDEX.CI_DARKBLUE,  
                                    COLORINDEX.CI_BLUE,  
                                    FONTFLAGS.FF_PLAIN)  
            };  
        }  
    }  
}  

Remarks

The display name for the custom colorable item should be localized.

The color values returned from this interface are predefined colors. High color (24-bit) values can be returned through the IVsHiColorItem interface. See the IVsHiColorItem interface for an example.

How to implement custom colorable items is described in Custom Colorable Items.

Notes to Implementers

Implement this interface to provide font and name information about a custom colorable item that is returned from a language service.

If you want to support high color values, you must implement the IVsHiColorItem interface on the same object that implements the IVsColorableItem interface.

Notes to Callers

An IVsColorableItem object can be obtained by calling the GetColorableItem(Int32, IVsColorableItem) method on the IVsProvideColorableItems interface.

Methods

GetDefaultColors(COLORINDEX[], COLORINDEX[])

Defines the default background and foreground colors for a custom colorable item.

GetDefaultFontFlags(UInt32)

Returns the default font flags for the custom colorable item.

GetDisplayName(String)

Gets the display name of the custom colorable item.

Applies to