private static Brush GetBrush(ThemeResourceKey key) { if (Application.Current == null) { return null; } return (Brush)Application.Current.Resources[key]; }
public static ImageList GetThemedImageList(Bitmap bitmap, ThemeResourceKey backgroundColorKey) { Debug.Assert(bitmap != null, "bitmap != null"); bitmap.MakeTransparent(TransparentColor); var themedBitmap = ThemeBitmap(bitmap, VSColorTheme.GetThemedColor(backgroundColorKey)); var imageList = new ImageList { ColorDepth = ColorDepth.Depth32Bit, ImageSize = new Size(16, 16) }; imageList.Images.AddStrip(themedBitmap); #if VS12ORNEWER // scales images as appropriate for screen resolution DpiHelper.LogicalToDeviceUnits(ref imageList); #endif return imageList; }
/// <summary> /// Convert from VSTheme EnvironmentColor to a XAML SolidColorBrush /// </summary> /// <param name="key">VSTheme EnvironmentColor key</param> /// <returns>XAML SolidColorBrush</returns> private static SolidColorBrush ToBrush(ThemeResourceKey key) { var color = VSColorTheme.GetThemedColor(key); return(new SolidColorBrush(Color.FromArgb(color.A, color.R, color.G, color.B))); }
public static Color ToMediaColor(ThemeResourceKey key) => ToMediaColor(VSColorTheme.GetThemedColor(key));
/// <summary> /// Convert from VSTheme EnvironmentColor to a XAML SolidColorBrush /// </summary> /// <param name="key">VSTheme EnvironmentColor key</param> /// <returns>XAML SolidColorBrush</returns> public static SolidColorBrush ToBrush(ThemeResourceKey key) => new SolidColorBrush(ToMediaColor(VSColorTheme.GetThemedColor(key)));
private static System.Drawing.Color GetThemedColor(IVsUIShell5 shell, ThemeResourceKey themeResourceKey) { return(shell.GetThemedGDIColor(themeResourceKey)); }
/// <summary> /// Initializes a new instance of the <see cref="ThemeResourceExtension"/> class. /// </summary> /// <param name="key">The resource key.</param> public ThemeResourceExtension(ThemeResourceKey key) { _themeKey = key; }
public static Bitmap GetThemedButtonImage(Bitmap bitmap, ThemeResourceKey backgroundColorKey) { return(GetThemedButtonImage(bitmap, VSColorTheme.GetThemedColor(backgroundColorKey))); }
public static WpfBrush GetWpfBrush(this ThemeResourceKey resourceKey) { return(new WpfBrush(resourceKey.GetWpfColor())); }
private Brush this[ThemeResourceKey key] { set => Resources[key.ToString()] = value;
public static Bitmap GetThemedButtonImage(Bitmap bitmap, ThemeResourceKey backgroundColorKey) { return GetThemedButtonImage(bitmap, VSColorTheme.GetThemedColor(backgroundColorKey)); }
/// <summary> /// This is used to get the theme color for the given them resource key /// </summary> /// <param name="themeResourceKey">The theme resource key for which to get the color</param> /// <returns>The color for the theme resource key or null if it could not be obtained</returns> private static Color? GetThemeColor(ThemeResourceKey themeResourceKey) { try { System.Drawing.Color vsThemeColor = VSColorTheme.GetThemedColor(themeResourceKey); return Color.FromArgb(vsThemeColor.A, vsThemeColor.R, vsThemeColor.G, vsThemeColor.B); } catch(Exception ex) { System.Diagnostics.Debug.WriteLine("Failed to get Visual Studio theme color {0}. Exception:\r\n{1}", themeResourceKey.Name, ex); } return null; }
public ThemeColor(ThemeResourceKey foreground = null, ThemeResourceKey background = null) { _foregroundResourceKey = foreground; _backgroundResourceKey = background; }
private static Brush GetAppBrush([NotNull] ThemeResourceKey brushKey) => Application.Current.Resources[brushKey] as Brush;
public Color GetVsThemedColor(ThemeResourceKey resourceKey) { return(VSColorTheme.GetThemedColor(resourceKey)); }
public static string VSColorThemeConverter(ThemeResourceKey color) { return($"#{VSColorTheme.GetThemedColor(color).ToArgb().ToString("X")}"); }
public static object GetResource(ThemeResourceKey resourceKey) { return(ResourceDictionary.Contains(resourceKey.ToString()) ? ResourceDictionary[resourceKey.ToString()] : null); }
public static WpfColor GetWpfColor(this ThemeResourceKey resourceKey) { return(resourceKey.GetGdiColor().ToWpfColor()); }
public static GdiColor GetGdiColor(this ThemeResourceKey resourceKey) { return(VSColorTheme.GetThemedColor(resourceKey)); }
internal static void SetResource(ThemeResourceKey resourceKey, object resource) { SetResource(resourceKey.ToString(), resource); }