public void UserPrefrencesChangedUpdateColorsForTextEditorCategory() { var textManagerEvents = new TextManagerEvents(); var fontResource = new FONTCOLORPREFERENCES { pguidFontCategory = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Guid))), pguidColorService = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Guid))), pColorTable = Marshal.AllocHGlobal(1) }; Marshal.StructureToPtr(DefGuidList.guidTextEditorFontCategory, fontResource.pguidFontCategory, true); Marshal.StructureToPtr(Guid.NewGuid(), fontResource.pguidColorService, true); var fontResources = new[] {fontResource}; try { var mockStore = new Mock<IVsFontAndColorStorage>(); FontAndColorStorage.Override = mockStore.Object; textManagerEvents.OnUserPreferencesChanged(null, null, null, fontResources); const uint flags = (uint) ( __FCSTORAGEFLAGS.FCSF_LOADDEFAULTS | __FCSTORAGEFLAGS.FCSF_PROPAGATECHANGES | __FCSTORAGEFLAGS.FCSF_NOAUTOCOLORS); var textEditorGuid = DefGuidList.guidTextEditorFontCategory; mockStore.Verify(s => s.OpenCategory(ref textEditorGuid, flags)); } finally { FontAndColorStorage.Override = null; } }
public static void RegisterForTextManagerEvents() { var textManager = GetService(); var container = textManager as IConnectionPointContainer; IConnectionPoint textManagerEventsConnection; var eventGuid = typeof(IVsTextManagerEvents).GUID; container.FindConnectionPoint(ref eventGuid, out textManagerEventsConnection); var textManagerEvents = new TextManagerEvents(); uint textManagerCookie; textManagerEventsConnection.Advise(textManagerEvents, out textManagerCookie); }
public static void RegisterForTextManagerEvents() { var textManager = GetService(); var container = textManager as IConnectionPointContainer; IConnectionPoint textManagerEventsConnection; var eventGuid = typeof(IVsTextManagerEvents).GUID; container.FindConnectionPoint(ref eventGuid, out textManagerEventsConnection); var textManagerEvents = new TextManagerEvents(); uint textManagerCookie; textManagerEventsConnection.Advise(textManagerEvents, out textManagerCookie); FontAndColorStorage.UpdateColors(); //Hotfix for loading colors until visual studio call OnUserPreferencesChanged function }
public IClassifier GetClassifier(ITextBuffer buffer) { try { if (OutputClassifier == null) { OutputClassifier = new OutputClassifier(ClassificationRegistry, ServiceProvider); TextManagerEvents.RegisterForTextManagerEvents(); } } catch (Exception ex) { OutputClassifier.LogError(ex.ToString()); throw; } return(OutputClassifier); }