Compartilhar via


LanguagePreferences.OnUserPreferencesChanged2 Method

Called when a user preference has been changed.

Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.11.0 (in Microsoft.VisualStudio.Package.LanguageService.11.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)

Syntax

'Declaração
Public Overridable Function OnUserPreferencesChanged2 ( _
    viewPrefs As VIEWPREFERENCES2(), _
    framePrefs As FRAMEPREFERENCES2(), _
    langPrefs As LANGPREFERENCES2(), _
    fontColorPrefs As FONTCOLORPREFERENCES2() _
) As Integer
public virtual int OnUserPreferencesChanged2(
    VIEWPREFERENCES2[] viewPrefs,
    FRAMEPREFERENCES2[] framePrefs,
    LANGPREFERENCES2[] langPrefs,
    FONTCOLORPREFERENCES2[] fontColorPrefs
)

Parameters

Return Value

Type: System.Int32

Implements

IVsTextManagerEvents2.OnUserPreferencesChanged2(array<VIEWPREFERENCES2[], array<FRAMEPREFERENCES2[], array<LANGPREFERENCES2[], array<FONTCOLORPREFERENCES2[])

Remarks

This method is called whenever any user preferences are modified. A language service typically concerns itself with the langPrefs. It may deal with fontColorPrefs, but only if the language service owns the color provider specified in the FONTCOLORPREFERENCES2 structure.

This method is an implementation of IVsTextManagerEvents2.OnUserPreferencesChanged2.

The base method stores only the langPrefs but only if the language GUID of the preferences specified in langPrefs matches the GUID of the language service.

Examples

This example is the managed package framework's implementation of this method and shows how to test for ownership of the language preferences.

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

.NET Framework Security

See Also

Reference

LanguagePreferences Class

Microsoft.VisualStudio.Package Namespace