private static void SaveColor(IVsFontAndColorStorage vsStorage, ColorKey colorKey, Color color) { var colorableItemInfo = new ColorableItemInfo(); if (colorKey.IsForeground) { colorableItemInfo.bForegroundValid = 1; colorableItemInfo.crForeground = (uint)ColorTranslator.ToWin32(color); } else { colorableItemInfo.bBackgroundValid = 1; colorableItemInfo.crBackground = (uint)ColorTranslator.ToWin32(color); } ErrorHandler.ThrowOnFailure(vsStorage.SetItem(colorKey.Name, new[] { colorableItemInfo })); }
void SetColor(string item, Color color, bool isForeground) { var cii = new ColorableItemInfo[1]; uint wincolor = (uint)(color.B << 16) + (uint)(color.R) + (uint)(color.G << 8); if (isForeground) { cii[0].bForegroundValid = 1; cii[0].crForeground = (uint)wincolor; } else { cii[0].bBackgroundValid = 1; cii[0].crBackground = (uint)wincolor; } m_pStorage.SetItem(item, cii); }
private static void SaveColor(IVsFontAndColorStorage vsStorage, ColorKey colorKey, System.Drawing.Color color) { Debug.WriteLine($"GeneralOptions.SaveColoR keyName={colorKey.Name} color={color}"); ThreadHelper.ThrowIfNotOnUIThread(); ColorableItemInfo[] arr = new ColorableItemInfo[1]; ErrorHandler.ThrowOnFailure(vsStorage.GetItem(colorKey.Name, arr)); if (colorKey.IsForeground) { arr[0].bForegroundValid = 1; arr[0].crForeground = (uint)ColorTranslator.ToWin32(color); } else { arr[0].bBackgroundValid = 1; arr[0].crBackground = (uint)ColorTranslator.ToWin32(color); } ErrorHandler.ThrowOnFailure(vsStorage.SetItem(colorKey.Name, arr)); }
private void UpdateColors() { var theme = themeEngine.GetCurrentTheme(); // Did theme change? if (theme != currentTheme) { currentTheme = theme; var colors = themeColors[theme]; if (fontAndColorStorage != null && fontAndColorUtilities != null) { if (fontAndColorStorage.OpenCategory(Microsoft.VisualStudio.Editor.DefGuidList.guidTextEditorFontCategory, (uint)(__FCSTORAGEFLAGS.FCSF_LOADDEFAULTS | __FCSTORAGEFLAGS.FCSF_PROPAGATECHANGES)) == VSConstants.S_OK) { try { foreach (var pair in colors) { var colorInfos = new ColorableItemInfo[1]; if (fontAndColorStorage.GetItem(pair.Key, colorInfos) == VSConstants.S_OK) { if (pair.Value.ForegroundColor != null) { colorInfos[0].crForeground = (uint)(pair.Value.ForegroundColor.Value.R | (pair.Value.ForegroundColor.Value.G << 8) | (pair.Value.ForegroundColor.Value.B << 16)); } if (pair.Value.BackgroundColor != null) { colorInfos[0].crBackground = (uint)(pair.Value.BackgroundColor.Value.R | (pair.Value.BackgroundColor.Value.G << 8) | (pair.Value.BackgroundColor.Value.B << 16)); } fontAndColorStorage.SetItem(pair.Key, colorInfos); } } } finally { fontAndColorStorage.CloseCategory(); } } } } }
private static void SaveColor(IVsFontAndColorStorage vsStorage, ColorKey colorKey, Color color) { var colorableItemInfo = new ColorableItemInfo(); if (colorKey.IsForeground) { colorableItemInfo.bForegroundValid = 1; colorableItemInfo.crForeground = (uint)ColorTranslator.ToWin32(color); } else { colorableItemInfo.bBackgroundValid = 1; colorableItemInfo.crBackground = (uint)ColorTranslator.ToWin32(color); } ErrorHandler.ThrowOnFailure(vsStorage.SetItem(colorKey.Name, new[] { colorableItemInfo })); }