Beispiel #1
0
        static void InitializeIcons()
        {
            if (null != icons)
            {
                return;
            }

            ResourceDictionary resources = new ResourceDictionary
            {
                Source = Helpers.MakePackUri("View/Resources.xaml")
            };

            icons = new Dictionary <string, Icon>();
            foreach (Case @case in Enum.GetValues(typeof(Case)))
            {
                string key = GetResourceKey(@case);
                if (!icons.ContainsKey("Dark." + key))
                {
                    icons.Add("Dark." + key, WpfToGdipHelper.RenderToIcon(
                                  (Geometry)resources[key], Brushes.White, new Size(24, 24), new Size(48, 48)));
                }
                if (!icons.ContainsKey("Light." + key))
                {
                    icons.Add("Light." + key, WpfToGdipHelper.RenderToIcon(
                                  (Geometry)resources[key], Brushes.Black, new Size(24, 24), new Size(48, 48)));
                }
            }
        }
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            bool             isDark  = System.Convert.ToBoolean(values[0]);
            FrameworkElement element = (FrameworkElement)values[1];

            return(WpfToGdipHelper.Render((Geometry)element.FindResource("MainIcon"), isDark ? Brushes.White : Brushes.Black, new Size(24, 24), new Size(96, 96)));
        }