好的,此代码使您可以访问 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();
}
}
我怎样才能得到实际System.Color
的uint crBackground
财产ColorableItemInfo
???