private IVsUIShell5 GetIVsUIShell5() { IVsUIShell5 shell5 = null; Microsoft.VisualStudio.OLE.Interop.IServiceProvider sp = OLEServiceProvider; Type SVsUIShellType = typeof(SVsUIShell); IntPtr serviceIntPtr; int hr = sp.QueryService(SVsUIShellType.GUID, SVsUIShellType.GUID, out serviceIntPtr); if (hr != 0) { System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(hr); } else if (!serviceIntPtr.Equals(IntPtr.Zero)) { object serviceObject = System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(serviceIntPtr); shell5 = (IVsUIShell5)serviceObject; System.Runtime.InteropServices.Marshal.Release(serviceIntPtr); } return(shell5); }
public static bool IsDarkTheme() { ThreadHelper.ThrowIfNotOnUIThread(); if (Interlocked.Exchange(ref _serviceInitialized, INITIALIZED) == NOT_INITIALIZED) { _vsUIShell5 = ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell)) as IVsUIShell5; } if (_vsUIShell5 == null) { return(true); } Color editorBackgroundColor = _vsUIShell5.GetThemedWPFColor(EnvironmentColors.DarkColorKey); if (editorBackgroundColor == null) { return(true); } return(editorBackgroundColor.R < RedCriteria || editorBackgroundColor.G < GreenCriteria || editorBackgroundColor.B < BlueCriteria); }
public static bool IsDarkTheme() { if (vsUIShell5 == null) { lock (locker) { if (vsUIShell5 == null) { vsUIShell5 = ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell)) as IVsUIShell5; } } } if (vsUIShell5 == null) { return(true); } Color editorBackgroundColor = vsUIShell5.GetThemedWPFColor(EnvironmentColors.DarkColorKey); if (editorBackgroundColor == null) { return(true); } return(editorBackgroundColor.R < RedCriteria || editorBackgroundColor.G < GreenCriteria || editorBackgroundColor.B < BlueCriteria); }
public void SetControlColors()//P4VsProviderService.ColorCollection colors) { #if !VS2015 object s5 = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(IVsUIShell)); IVsUIShell5 shell5 = s5 as IVsUIShell5; #endif ForeColor = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowTextColorKey); BackColor = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowBackgroundColorKey); if ((Images != null) && (Images.Count > 0)) { for (int idx = 0; idx < Images.Count; idx++) { string imgKey = string.Format("{0}.Images[{1}]", ImageCacheKey, idx); Images[idx] = InvertImage(imgKey,shell5,Images[idx], Color.Transparent, (uint)BackColor.ToArgb()); } } if ((ImageLists != null) && (ImageLists.Count > 0)) { for (int idx = 0; idx < ImageLists.Count; idx++) { string imgKey = string.Format("{0}.ImageLists[{1}]", ImageCacheKey, idx); InvertImageList(imgKey,shell5, ImageLists[idx], Color.Transparent, (uint)BackColor.ToArgb()); } } SetControlColors(Controls, ImageCacheKey); }
private Image InvertImage(string imageListCacheKey, IVsUIShell5 shell5, Image i, Color transparentColor, uint backgroundColor) #endif { if (i == null) { return null; } if (ImageCache.ContainsKey(imageListCacheKey) == false) { // new image, so cache it ImageCache.Add(imageListCacheKey, i); } else { // get the origonal image out of the cache i = ImageCache[imageListCacheKey]; } #if VS2015 Bitmap ii = GetInvertedBitmap((Bitmap)i, (uint)BackColor.ToArgb()); #else Bitmap ii = GetInvertedBitmap(shell5, (Bitmap)i, Color.Transparent, backgroundColor); #endif return ii; }
private ProfilerPlugin(Package package, IVsOutputWindowPane outputPaneTizen, IVsThreadedWaitDialogFactory dialogFactory) { _package = package ?? throw new ArgumentNullException(nameof(package)); _outputPaneTizen = outputPaneTizen; _dialogFactory = dialogFactory; OLEServiceProvider = GetService(typeof(Microsoft.VisualStudio.OLE.Interop.IServiceProvider)) as Microsoft.VisualStudio.OLE.Interop.IServiceProvider; VsUiShell5 = GetIVsUIShell5(); ExplorerWindowCommand.Initialize(_package); ProfilingProgressWindowCommand.Initialize(_package); GeneralOptions = new GeneralOptions(new SettingsStore(_package, SettingsCollectionPath)); HeaptrackOptions = new HeaptrackOptions(new SettingsStore(_package, SettingsCollectionPath)); RegisterMenuHandlers(); ProfileLauncher.Initialize(); HeaptrackLauncher.Initialize(); ProfileLauncher = ProfileLauncher.Instance; HeaptrackLauncher = HeaptrackLauncher.Instance; HeaptrackLauncher.OnSessionFinished += HandleMenuItemRunMemoryProfiler; _solutionListener = new SolutionListener(_package) { AfterOpenSolution = delegate { _solutionSessionsContainer.Update(); return(VSConstants.S_OK); }, AfterCloseSolution = delegate { _solutionSessionsContainer.Update(); return(VSConstants.S_OK); } }; _solutionListener.Initialize(); _solutionSessionsContainer = new SolutionSessionsContainer((DTE2)Package.GetGlobalService(typeof(SDTE))); }
public void SetPropertyGridColors(IVsUIShell5 shell) { var backgroundColor = VsColors.GetThemedGDIColor(shell, EnvironmentColors.ToolWindowBackgroundColorKey); var foregroundColor = VsColors.GetThemedGDIColor(shell, EnvironmentColors.ToolWindowTextColorKey); var lineColor = VsColors.GetThemedGDIColor(shell, EnvironmentColors.ToolWindowContentGridColorKey); var disabledColor = VsColors.GetThemedGDIColor(shell, EnvironmentColors.SystemGrayTextColorKey); var highlightColor = VsColors.GetThemedGDIColor(shell, EnvironmentColors.SystemHighlightColorKey); var highlightTextColor = VsColors.GetThemedGDIColor(shell, EnvironmentColors.SystemHighlightTextColorKey); var hyperLinkColor = VsColors.GetThemedGDIColor(shell, EnvironmentColors.ControlLinkTextColorKey); var hyperLinkActiveColor = VsColors.GetThemedGDIColor(shell, EnvironmentColors.ControlLinkTextPressedColorKey); if (!SystemInformation.HighContrast || !DotNetFrameworkUtilities.IsInstalledFramework471OrAbove()) { _propertyGrid.LineColor = lineColor; } _propertyGrid.ViewBackColor = backgroundColor; _propertyGrid.ViewForeColor = foregroundColor; _propertyGrid.ViewBorderColor = lineColor; _propertyGrid.HelpBackColor = backgroundColor; _propertyGrid.HelpForeColor = foregroundColor; _propertyGrid.HelpBorderColor = backgroundColor; _propertyGrid.CategoryForeColor = foregroundColor; _propertyGrid.CategorySplitterColor = lineColor; _propertyGrid.CommandsActiveLinkColor = hyperLinkActiveColor; _propertyGrid.CommandsDisabledLinkColor = disabledColor; _propertyGrid.CommandsLinkColor = hyperLinkColor; _propertyGrid.CommandsForeColor = foregroundColor; _propertyGrid.CommandsBackColor = backgroundColor; _propertyGrid.CommandsDisabledLinkColor = disabledColor; _propertyGrid.CommandsBorderColor = backgroundColor; _propertyGrid.SelectedItemWithFocusForeColor = highlightTextColor; _propertyGrid.SelectedItemWithFocusBackColor = highlightColor; _propertyGrid.DisabledItemForeColor = disabledColor; _propertyGrid.CanShowVisualStyleGlyphs = false; }
internal static Color GetDesignerThemeColor(IVsUIShell5 uiShellService, Guid themeCategory, String themeColorName, __THEMEDCOLORTYPE colorType, Color defaultColor) { if (uiShellService != null) { UInt32 rgbaValue = 0; Int32 hr = Microsoft.VisualStudio.ErrorHandler.CallWithCOMConvention( () => { rgbaValue = uiShellService.GetThemedColor(themeCategory, themeColorName, (System.UInt32)colorType); }); if (Microsoft.VisualStudio.ErrorHandler.Succeeded(hr)) { return(RGBAToColor(rgbaValue)); } } return(defaultColor); }
public void SetPropertyGridColors() { ThreadHelper.ThrowIfNotOnUIThread(); IVsUIShell5 shell = (IVsUIShell5)GetVsService(typeof(SVsUIShell)); var backgroundColorDarker = VsColors.GetThemedGDIColor(shell, EnvironmentColors.ToolWindowBackgroundColorKey); var backgroundColorLighter = VsColors.GetThemedGDIColor(shell, EnvironmentColors.BrandedUIBackgroundColorKey); var searchBoxBackgroundColorKey = VsColors.GetThemedGDIColor(shell, EnvironmentColors.SearchBoxBackgroundColorKey); var foregroundColor = VsColors.GetThemedGDIColor(shell, EnvironmentColors.ToolWindowTextColorKey); var buttonFaceColor = VsColors.GetThemedGDIColor(shell, EnvironmentColors.SystemButtonFaceBrushKey); var buttonTextColor = VsColors.GetThemedGDIColor(shell, EnvironmentColors.SystemButtonTextColorKey); this.searchButton.BackColor = buttonFaceColor; this.searchButton.ForeColor = buttonTextColor; this.searchOptionBar.BackColor = backgroundColorLighter; this.searchOptionBar.ForeColor = foregroundColor; this.searchBox.BackColor = searchBoxBackgroundColorKey; this.searchBox.ForeColor = foregroundColor; this.showCountComboBox.BackColor = searchBoxBackgroundColorKey; this.showCountComboBox.ForeColor = foregroundColor; this.showCountLabel.BackColor = backgroundColorLighter; this.showCountLabel.ForeColor = foregroundColor; this.languageLabel.BackColor = backgroundColorLighter; this.languageLabel.ForeColor = foregroundColor; this.languageFilters.BackColor = backgroundColorLighter; this.languageFilters.ForeColor = foregroundColor; this.panel1.BackColor = backgroundColorLighter; this.panel1.ForeColor = foregroundColor; this.panel2.BackColor = backgroundColorLighter; this.panel2.ForeColor = foregroundColor; this.tableLayoutPanel1.BackColor = backgroundColorLighter; //this.tableLayoutPanel1.ForeColor = foregroundColor; this.tableLayoutPanel1.CellBorderStyle = TableLayoutPanelCellBorderStyle.None; this.toolStripSeparator1.BackColor = backgroundColorLighter; this.toolStripSeparator1.ForeColor = foregroundColor; this.snippetExplorerSplitter.BackColor = backgroundColorLighter; this.previewCodeWindow.ForeColor = foregroundColor; this.previewCodeWindow.BackColor = backgroundColorDarker; }
private void InvertImageList(string imageListCacheKey, IVsUIShell5 shell5, ImageList list, Color transparentColor, uint backgroundColor) #endif { if (list != null) { List<Image> il = null; if (ImageListCache.ContainsKey(imageListCacheKey) == false) { // haven't converted this image list yet, so make a copy of the images in the list // to use if we need to adjust the images for another theme change. il = new List<Image>(); for (int idx = 0; idx < list.Images.Count; idx++) { il.Add(list.Images[idx]); } ImageListCache.Add(imageListCacheKey, il); } else { il = ImageListCache[imageListCacheKey]; } for (int idx = 0; idx < list.Images.Count; idx++) { Image i = il[idx]; if (i != null) { #if VS2015 Bitmap ii = GetInvertedBitmap((Bitmap)i, backgroundColor); #else Bitmap ii = GetInvertedBitmap(shell5, (Bitmap)i, Color.Transparent, backgroundColor); #endif list.Images[idx] = ii; } } } }
public Vs11PresentationAssistantThemeColourFiller(IVsUIShell5 vsUIShell5) { vsUiShell5 = vsUIShell5; }
private static System.Drawing.Color GetThemedColor(IVsUIShell5 shell, ThemeResourceKey themeResourceKey) { return(shell.GetThemedGDIColor(themeResourceKey)); }
protected override void Initialize() { base.Initialize(); _shell5 = Package.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell5; }
//#if VS2012 // public Color SelectedItemActiveBackColor = VSColorTheme.GetThemedColor(TreeViewColors.SelectedItemActiveColorKey); // public Color SelectedItemActiveForeColor = VSColorTheme.GetThemedColor(TreeViewColors.SelectedItemActiveTextColorKey); // public Color SelectedItemInactiveBackColor = VSColorTheme.GetThemedColor(TreeViewColors.SelectedItemInactiveColorKey); // public Color SelectedItemInactiveForeColor = VSColorTheme.GetThemedColor(TreeViewColors.SelectedItemInactiveTextColorKey); // public Color DisabledItemForeColor = VSColorTheme.GetThemedColor(EnvironmentColors.SystemGrayTextColorKey); //#endif public void SetControlColors(Control.ControlCollection Controls, string ImageCacheKey) { #if !VS2015 object s5 = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(IVsUIShell)); IVsUIShell5 shell5 = s5 as IVsUIShell5; #endif if ((Controls == null) || (Controls.Count <= 0)) { return; } foreach (Control c in Controls) { string ImageCacheSubkey = string.Concat(ImageCacheKey, ".", c.Name); //if (c is SplitContainer) //{ // SplitContainer s = c as SplitContainer; // s.BackColor = VSColorTheme.GetThemedColor(EnvironmentColors.EnvironmentBackgroundColorKey); //} //else if (c is Panel) if (c is Panel) { Panel p = c as Panel; SetControlColors(p.Controls, ImageCacheSubkey); p.ForeColor = ForeColor; p.BackColor = BackColor; } else if (c is Button) { Button b = c as Button; b.ForeColor = ForeColor; b.BackColor = BackColor; b.FlatAppearance.BorderColor = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowBorderColorKey); //b.UseVisualStyleBackColor = false; #if VS2015 b.Image = InvertImage(ImageCacheSubkey, b.Image, (uint)BackColor.ToArgb()); InvertImageList(ImageCacheSubkey + ".ImageList", b.ImageList, (uint)BackColor.ToArgb()); #else if (shell5 != null) { if (b.ImageList != null) { InvertImageList(ImageCacheSubkey + ".ImageList", shell5, b.ImageList, Color.Transparent, (uint)BackColor.ToArgb()); } else if (b.Image != null) { b.Image = InvertImage(ImageCacheSubkey, shell5, b.Image, Color.Transparent, (uint)BackColor.ToArgb()); } } #endif } else if (c is ListBox) { ListBox lb = c as ListBox; lb.ForeColor = ForeColor; lb.BackColor = BackColor; } else if (c is ProgressBar) { //ProgressBar pb = c as ProgressBar; //pb.ForeColor = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWin); //pb.BackColor = BackColor; } else if (c is ListView) { ListView lv = c as ListView; lv.ForeColor = ForeColor; lv.BackColor = BackColor; #if !VS2015 if (shell5 != null) { InvertImageList(ImageCacheSubkey + ".SmallImageList", shell5, lv.SmallImageList, Color.Transparent, (uint)BackColor.ToArgb()); #else InvertImageList(ImageCacheSubkey + ".SmallImageList", lv.SmallImageList, (uint)BackColor.ToArgb()); #endif if (lv is TreeListView) { TreeListView tlv = lv as TreeListView; #if VS2015 InvertImageList(ImageCacheSubkey + ".classicStateImageList", tlv.classicStateImageList, (uint)BackColor.ToArgb()); InvertImageList(ImageCacheSubkey + ".LeftImageList", tlv.LeftImageList, (uint)BackColor.ToArgb()); InvertImageList(ImageCacheSubkey + ".RightImageList", tlv.RightImageList, (uint)BackColor.ToArgb()); InvertImageList(ImageCacheSubkey + ".checkboxImageList", tlv.checkboxImageList, (uint)BackColor.ToArgb()); #else InvertImageList(ImageCacheSubkey + ".classicStateImageList", shell5, tlv.classicStateImageList, Color.Transparent, (uint)BackColor.ToArgb()); InvertImageList(ImageCacheSubkey + ".LeftImageList", shell5, tlv.LeftImageList, Color.Transparent, (uint)BackColor.ToArgb()); InvertImageList(ImageCacheSubkey + ".RightImageList", shell5, tlv.RightImageList, Color.Transparent, (uint)BackColor.ToArgb()); InvertImageList(ImageCacheSubkey + ".checkboxImageList", shell5, tlv.checkboxImageList, Color.Transparent, (uint)BackColor.ToArgb()); } #endif } } else if (c is ComboBox) { ComboBox cb = c as ComboBox; cb.ForeColor = ForeColor; cb.BackColor = VSColorTheme.GetThemedColor(EnvironmentColors.ComboBoxBackgroundColorKey); } else if (c is GroupBox) { GroupBox gb = c as GroupBox; gb.ForeColor = ForeColor; gb.BackColor = BackColor; SetControlColors(gb.Controls, ImageCacheSubkey); } else if (c is CheckBox) { CheckBox cb = c as CheckBox; cb.ForeColor = ForeColor; cb.BackColor = BackColor; //cb.UseVisualStyleBackColor = false; } else if (c is RadioButton) { RadioButton rb = c as RadioButton; rb.ForeColor = ForeColor; rb.BackColor = BackColor; rb.UseVisualStyleBackColor = false; } else if (c is Label) { Label l = c as Label; l.ForeColor = ForeColor; l.BackColor = BackColor; } else if (c is TextBox) { TextBox tb = c as TextBox; tb.ForeColor = ForeColor; tb.BackColor = BackColor; } else if (c is ContainerControl) { ContainerControl s = c as ContainerControl; SetControlColors(s.Controls, ImageCacheSubkey); } else { #if DEBUG Type t = c.GetType(); System.Diagnostics.Trace.WriteLine(string.Format("Unhandled type: {0}", t.ToString())); #endif } } }