コード例 #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;
 }
コード例 #8
0
 public static Bitmap GetThemedButtonImage(Bitmap bitmap, ThemeResourceKey backgroundColorKey)
 {
     return(GetThemedButtonImage(bitmap, VSColorTheme.GetThemedColor(backgroundColorKey)));
 }
コード例 #9
0
ファイル: ThemeHelper.cs プロジェクト: molongwudi/Codist
 public static WpfBrush GetWpfBrush(this ThemeResourceKey resourceKey)
 {
     return(new WpfBrush(resourceKey.GetWpfColor()));
 }
コード例 #10
0
 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
ファイル: ThemeColors.cs プロジェクト: kazu46/VSSpellChecker
        /// <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
ファイル: Converters.cs プロジェクト: ryanToth/HockeyScoresVS
 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
ファイル: ThemeHelper.cs プロジェクト: molongwudi/Codist
 public static WpfColor GetWpfColor(this ThemeResourceKey resourceKey)
 {
     return(resourceKey.GetGdiColor().ToWpfColor());
 }
コード例 #19
0
ファイル: ThemeHelper.cs プロジェクト: molongwudi/Codist
 public static GdiColor GetGdiColor(this ThemeResourceKey resourceKey)
 {
     return(VSColorTheme.GetThemedColor(resourceKey));
 }
コード例 #20
0
ファイル: Theme.cs プロジェクト: mgnslndh/ControlzExWindow
 internal static void SetResource(ThemeResourceKey resourceKey, object resource)
 {
     SetResource(resourceKey.ToString(), resource);
 }