LanguagePreferences.OnUserPreferencesChanged2 方法

定义

当用户首选项已更改时调用。

public:
 virtual int OnUserPreferencesChanged2(cli::array <Microsoft::VisualStudio::TextManager::Interop::VIEWPREFERENCES2> ^ viewPrefs, cli::array <Microsoft::VisualStudio::TextManager::Interop::FRAMEPREFERENCES2> ^ framePrefs, cli::array <Microsoft::VisualStudio::TextManager::Interop::LANGPREFERENCES2> ^ langPrefs, cli::array <Microsoft::VisualStudio::TextManager::Interop::FONTCOLORPREFERENCES2> ^ fontColorPrefs);
 virtual int OnUserPreferencesChanged2(std::Array <Microsoft::VisualStudio::TextManager::Interop::VIEWPREFERENCES2> const & viewPrefs, std::Array <Microsoft::VisualStudio::TextManager::Interop::FRAMEPREFERENCES2> const & framePrefs, std::Array <Microsoft::VisualStudio::TextManager::Interop::LANGPREFERENCES2> const & langPrefs, std::Array <Microsoft::VisualStudio::TextManager::Interop::FONTCOLORPREFERENCES2> const & fontColorPrefs);
public virtual int OnUserPreferencesChanged2 (Microsoft.VisualStudio.TextManager.Interop.VIEWPREFERENCES2[] viewPrefs, Microsoft.VisualStudio.TextManager.Interop.FRAMEPREFERENCES2[] framePrefs, Microsoft.VisualStudio.TextManager.Interop.LANGPREFERENCES2[] langPrefs, Microsoft.VisualStudio.TextManager.Interop.FONTCOLORPREFERENCES2[] fontColorPrefs);
abstract member OnUserPreferencesChanged2 : Microsoft.VisualStudio.TextManager.Interop.VIEWPREFERENCES2[] * Microsoft.VisualStudio.TextManager.Interop.FRAMEPREFERENCES2[] * Microsoft.VisualStudio.TextManager.Interop.LANGPREFERENCES2[] * Microsoft.VisualStudio.TextManager.Interop.FONTCOLORPREFERENCES2[] -> int
override this.OnUserPreferencesChanged2 : Microsoft.VisualStudio.TextManager.Interop.VIEWPREFERENCES2[] * Microsoft.VisualStudio.TextManager.Interop.FRAMEPREFERENCES2[] * Microsoft.VisualStudio.TextManager.Interop.LANGPREFERENCES2[] * Microsoft.VisualStudio.TextManager.Interop.FONTCOLORPREFERENCES2[] -> int
Public Overridable Function OnUserPreferencesChanged2 (viewPrefs As VIEWPREFERENCES2(), framePrefs As FRAMEPREFERENCES2(), langPrefs As LANGPREFERENCES2(), fontColorPrefs As FONTCOLORPREFERENCES2()) As Integer

参数

viewPrefs
VIEWPREFERENCES2[]

VIEWPREFERENCES2 描述用户视图首选项的结构。

framePrefs
FRAMEPREFERENCES2[]

FRAMEPREFERENCES2 描述用户面向框架的首选项的结构。

langPrefs
LANGPREFERENCES2[]

LANGPREFERENCES2 描述用户语言服务特定首选项的结构。

fontColorPrefs
FONTCOLORPREFERENCES2[]

FONTCOLORPREFERENCES2 描述用户字体和颜色首选项的结构。

返回

Int32

实现

示例

此示例是此方法的托管包框架的实现,并演示如何测试语言首选项的所有权。

namespace Microsoft.VisualStudio.Package  
{  
    [CLSCompliant(false),ComVisible(true)]  
    public class LanguagePreferences : IVsTextManagerEvents2, IDisposable  
    {  
        public virtual void OnUserPreferencesChanged2(  
                                       VIEWPREFERENCES2[] viewPrefs,  
                                       FRAMEPREFERENCES2[] framePrefs,  
                                       LANGPREFERENCES2[] langPrefs,  
                                       FONTCOLORPREFERENCES2[] fontColorPrefs)  
        {  
            if (langPrefs != null &&  
                langPrefs.Length > 0 &&  
                langPrefs[0].guidLang == this.langSvc)  
            {  
                this.prefs = langPrefs[0];  
            }  
        }  
    }  
}  

注解

只要修改任何用户首选项,就会调用此方法。 语言服务通常会自行考虑 langPrefs 。 它可以处理 fontColorPrefs ,但前提是语言服务拥有结构中指定的颜色提供程序 FONTCOLORPREFERENCES2

此方法是的实现 Microsoft.VisualStudio.TextManager.Interop.IVsTextManagerEvents2.OnUserPreferencesChanged2

langPrefs如果中指定的首选项的语言 guid langPrefs 与语言服务的 guid 匹配,则基方法仅存储。

适用于