private bool CheckFontColorReferencesAreEqual(FONTCOLORPREFERENCES fr1, FONTCOLORPREFERENCES fr2) { return(fr1.hBoldViewFont == fr2.hBoldViewFont && fr1.hRegularViewFont == fr2.hRegularViewFont && fr1.pguidColorCategory == fr2.pguidColorCategory && fr1.pguidFontCategory == fr2.pguidFontCategory); }
public void UserPrefrencesChangedNotUpdateColorsForNotTextEditorCategory() { try { 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.guidPrinterFontCategory, fontResource.pguidFontCategory, true); Marshal.StructureToPtr(Guid.NewGuid(), fontResource.pguidColorService, true); var fontResources = new[] { fontResource }; var mockStore = new Mock <IVsFontAndColorStorage>(); FontAndColorStorage.Override = mockStore.Object; textManagerEvents.OnUserPreferencesChanged(null, null, null, fontResources); const uint flags = (uint)( __FCSTORAGEFLAGS.FCSF_LOADDEFAULTS | __FCSTORAGEFLAGS.FCSF_NOAUTOCOLORS | __FCSTORAGEFLAGS.FCSF_PROPAGATECHANGES); var textEditorGuid = DefGuidList.guidTextEditorFontCategory; mockStore.Verify(s => s.OpenCategory(ref textEditorGuid, flags), Times.Never()); } finally { FontAndColorStorage.Override = null; } }
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 void OnUserPreferencesChanged( VIEWPREFERENCES[] pViewPrefs, FRAMEPREFERENCES[] pFramePrefs, LANGPREFERENCES[] pLangPrefs, FONTCOLORPREFERENCES[] pColorPrefs) { try { Setup(); //if (pColorPrefs != null && pColorPrefs.Length > 0 && pColorPrefs[0].pColorTable != null) //{ // var guidFontCategory = (Guid)Marshal.PtrToStructure(pColorPrefs[0].pguidFontCategory, typeof(Guid)); // var guidColorService = (Guid)Marshal.PtrToStructure(pColorPrefs[0].pguidColorService, typeof(Guid)); // if (_guidColorService == Guid.Empty) // { // _guidColorService = guidColorService; // } // if (guidFontCategory == DefGuidList.guidTextEditorFontCategory && _guidColorService == guidColorService) // { // Setup(); // } //} } catch (Exception ex) { //Do Nothing } }
void IVsTextManagerEvents.OnUserPreferencesChanged( VIEWPREFERENCES[] viewPrefs, FRAMEPREFERENCES[] framePrefs, LANGPREFERENCES[] langPrefs, FONTCOLORPREFERENCES[] colorPrefs) { if (colorPrefs != null && colorPrefs.Length > 0) { FONTCOLORPREFERENCES prefs = colorPrefs[0]; Guid fontCategory = Marshal.PtrToStructure <Guid>(prefs.pguidFontCategory); if (fontCategory == DefGuidList.guidTextEditorFontCategory) { this.UpdateFormats(); } } }
public void OnUserPreferencesChanged( VIEWPREFERENCES[] pViewPrefs, FRAMEPREFERENCES[] pFramePrefs, LANGPREFERENCES[] pLangPrefs, FONTCOLORPREFERENCES[] pColorPrefs) { if (pColorPrefs != null && pColorPrefs.Length > 0 && pColorPrefs[0].pColorTable != null) { var guidFontCategory = (Guid) Marshal.PtrToStructure(pColorPrefs[0].pguidFontCategory, typeof(Guid)); var guidColorService = (Guid) Marshal.PtrToStructure(pColorPrefs[0].pguidColorService, typeof(Guid)); if (_guidColorService == Guid.Empty) _guidColorService = guidColorService; if (guidFontCategory == DefGuidList.guidTextEditorFontCategory && _guidColorService == guidColorService) FontAndColorStorage.UpdateColors(); } }
public void OnUserPreferencesChanged(VIEWPREFERENCES[] pViewPrefs, FRAMEPREFERENCES[] pFramePrefs, LANGPREFERENCES[] pLangPrefs, FONTCOLORPREFERENCES[] pColorPrefs) { }
public int SetUserPreferences(VIEWPREFERENCES[] pViewPrefs, FRAMEPREFERENCES[] pFramePrefs, LANGPREFERENCES[] pLangPrefs, FONTCOLORPREFERENCES[] pColorPrefs) { throw new Exception("The method or operation is not implemented."); }
public void OnUserPreferencesChanged(VIEWPREFERENCES[] pViewPrefs, FRAMEPREFERENCES[] pFramePrefs, LANGPREFERENCES[] pLangPrefs, FONTCOLORPREFERENCES[] pColorPrefs) { var handler = UserPreferencesChanged; if (handler != null) { handler(this, EventArgs.Empty); } }