private void drawBackground(DrawTreeNodeEventArgs e) { Color backgroundColor = VsColors.GetThemedGDIColor(_shell5, TreeViewColors.BackgroundColorKey); if (e.Node.TreeView.BackColor != backgroundColor) { e.Node.TreeView.BackColor = backgroundColor; } }
private static BitmapSource ToBitmap(ImageMoniker moniker, int size) { var shell = ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell)) as IVsUIShell5; uint backgroundColor = VsColors.GetThemedColorRgba(shell, EnvironmentColors.BrandedUIBackgroundBrushKey); var imageAttributes = new ImageAttributes { Flags = (uint)_ImageAttributesFlags.IAF_RequiredFlags | unchecked ((uint)_ImageAttributesFlags.IAF_Background), ImageType = (uint)_UIImageType.IT_Bitmap, Format = (uint)_UIDataFormat.DF_WPF, Dpi = 96, LogicalHeight = size, LogicalWidth = size, Background = backgroundColor, StructSize = Marshal.SizeOf(typeof(ImageAttributes)) }; var service = (IVsImageService2)Package.GetGlobalService(typeof(SVsImageService)); IVsUIObject result = service.GetImage(moniker, imageAttributes); result.get_Data(out object data); return(data as BitmapSource); }