示例#1
0
        private static Brush GetBrush(ThemeResourceKey key)
        {
            if (Application.Current == null)
            {
                return null;
            }

            return (Brush)Application.Current.Resources[key];
        }
示例#2
0
        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;
        }
示例#3
0
        /// <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)));
        }
示例#4
0
 public static Color ToMediaColor(ThemeResourceKey key)
 => ToMediaColor(VSColorTheme.GetThemedColor(key));
示例#5
0
 /// <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)));
示例#6
0
 private static System.Drawing.Color GetThemedColor(IVsUIShell5 shell, ThemeResourceKey themeResourceKey)
 {
     return(shell.GetThemedGDIColor(themeResourceKey));
 }
示例#7
0
 /// <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)));
 }
示例#9
0
 public static WpfBrush GetWpfBrush(this ThemeResourceKey resourceKey)
 {
     return(new WpfBrush(resourceKey.GetWpfColor()));
 }
 private Brush this[ThemeResourceKey key]
 {
     set => Resources[key.ToString()] = value;
示例#11
0
 public static Bitmap GetThemedButtonImage(Bitmap bitmap, ThemeResourceKey backgroundColorKey)
 {
     return GetThemedButtonImage(bitmap, VSColorTheme.GetThemedColor(backgroundColorKey));
 }
示例#12
0
        /// <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;
        }
示例#13
0
 public ThemeColor(ThemeResourceKey foreground = null, ThemeResourceKey background = null)
 {
     _foregroundResourceKey = foreground;
     _backgroundResourceKey = background;
 }
示例#14
0
 private static Brush GetAppBrush([NotNull] ThemeResourceKey brushKey)
 => Application.Current.Resources[brushKey] as Brush;
示例#15
0
 public Color GetVsThemedColor(ThemeResourceKey resourceKey)
 {
     return(VSColorTheme.GetThemedColor(resourceKey));
 }
示例#16
0
 public static string VSColorThemeConverter(ThemeResourceKey color)
 {
     return($"#{VSColorTheme.GetThemedColor(color).ToArgb().ToString("X")}");
 }
示例#17
0
文件: Theme.cs 项目: mohsenmou/ui-wpf
 public static object GetResource(ThemeResourceKey resourceKey)
 {
     return(ResourceDictionary.Contains(resourceKey.ToString()) ?
            ResourceDictionary[resourceKey.ToString()] : null);
 }
示例#18
0
 public static WpfColor GetWpfColor(this ThemeResourceKey resourceKey)
 {
     return(resourceKey.GetGdiColor().ToWpfColor());
 }
示例#19
0
 public static GdiColor GetGdiColor(this ThemeResourceKey resourceKey)
 {
     return(VSColorTheme.GetThemedColor(resourceKey));
 }
示例#20
0
 internal static void SetResource(ThemeResourceKey resourceKey, object resource)
 {
     SetResource(resourceKey.ToString(), resource);
 }