Reputation: 946
Ok this code gives you access to the user-setup background color in VS:
System.Guid guid = new System.Guid("{58E96763-1D3B-4E05-B6BA-FF7115FD0B7B}");
IVsFontAndColorStorage fontAndColorStorage =
Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider
.GetService(typeof(SVsFontAndColorStorage)) as IVsFontAndColorStorage;
if (fontAndColorStorage != null)
{
// GlobalValues.FontsAndColors_TextEditor is found in the registry: HKEY_USERS\.DEFAULT\Software\Microsoft\VisualStudio\[VS_VER]_Config\FontAndColors\Text Editor, where VS_VER is the actual Visual Studio version: 10.0, 11.0, 12.0, 14.0, etc.
if (fontAndColorStorage.OpenCategory(guid/*Microsoft.VisualStudio.Editor.DefGuidList.guidTextEditorFontCategory*/,
(uint)__FCSTORAGEFLAGS.FCSF_LOADDEFAULTS) == VSConstants.S_OK)
{
ColorableItemInfo[] info = new ColorableItemInfo[] { new ColorableItemInfo() };
fontAndColorStorage.GetItem("Plain Text", info);
fontAndColorStorage.CloseCategory();
}
}
How do I get the actual System.Color
out of the uint crBackground
property of ColorableItemInfo
???
Upvotes: 0
Views: 119
Reputation: 946
EDIT: THIS DOES NOT ALWAYS WORK - IF THE THEME IS WHITE IT GETS THE BLACK COLOR.
byte[] intBytesFO = BitConverter.GetBytes(info[0].crForeground);
Color colBG = Color.FromArgb(intBytesBG[3], intBytesBG[0], intBytesBG[1], intBytesBG[2]);
Upvotes: 0