/// <summary> /// Returns a standard VS color or a system color, if the VS colors service is not available /// </summary> /// <param name="visualStudioColor">Color enum</param> /// <returns>The color itself</returns> public static Color GetVsColor(Vs2010Color visualStudioColor) { uint win32Color = 0; ThreadHelper.ThrowIfNotOnUIThread(); IVsUIShell2 vsuiShell2 = AsyncProjectPackage.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell2; if (vsuiShell2 != null && vsuiShell2.GetVSSysColorEx((Int32)visualStudioColor, out win32Color) == VSConstants.S_OK) { Color color = ColorTranslator.FromWin32((int)win32Color); return(color); } // We need to fall back to some reasonable colors when we're not running in VS // to keep the forms/property pages editable in the designers switch (visualStudioColor) { //case Vs2010Color.VSCOLOR_BUTTONFACE: // return SystemColors.ButtonFace; case Vs2010Color.VSCOLOR_BUTTONTEXT: return(SystemColors.ControlText); case Vs2010Color.VSCOLOR_WINDOW: return(SystemColors.Window); default: return(Color.Red); } }
/// <summary> /// Refreshes the data in the property browser /// </summary> internal static void RefreshPropertyBrowser() { ThreadHelper.ThrowIfNotOnUIThread(); IVsUIShell vsuiShell = AsyncProjectPackage.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell; if (vsuiShell == null) { string message = XHelperMethods.SafeStringFormat(CultureInfo.CurrentUICulture, Resources.GetString(Resources.CannotGetService), typeof(IVsUIShell).Name); throw new InvalidOperationException(message); } else { int hr = vsuiShell.RefreshPropertyBrowser(0); if (hr != 0) { Marshal.ThrowExceptionForHR(hr); } } }