Beispiel #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var windowActivated = (bool)value;

            if (windowActivated)
            {
                if (_color1 == null)
                {
                    _color1 = ColorExtension.GetChromeColor();
                }
                if (_color1 != null)
                {
                    var color   = _color1.Value;
                    var average = (color.R + color.G + color.B) / 3f;
                    return(average >= 128
                        ? new SolidColorBrush(Color.FromRgb(0, 0, 0))
                        : new SolidColorBrush(Color.FromRgb(255, 255, 255)));
                }

                return(new SolidColorBrush(Color.FromRgb(255, 255, 255)));
            }

            return(new SolidColorBrush(Color.FromRgb(0, 0, 0)));
        }