BaconographyWP8.Converters.ColorBrightnessConverter.Convert C# (CSharp) Method

Convert() public method

public Convert ( object value, Type targetType, object parameter, System culture ) : object
value object
targetType System.Type
parameter object
culture System
return object
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            // parameter should be the brightness factor in double.
            var factor = System.Convert.ToDouble(parameter, CultureInfo.InvariantCulture);
            var brush = (SolidColorBrush)value;

            var newColor = new System.Windows.Media.Color() { A = brush.Color.A, B = System.Convert.ToByte(brush.Color.B * factor, CultureInfo.InvariantCulture), G = System.Convert.ToByte(brush.Color.G * factor, CultureInfo.InvariantCulture), R = System.Convert.ToByte(brush.Color.R * factor, CultureInfo.InvariantCulture) };

            return new SolidColorBrush(newColor);
        }
ColorBrightnessConverter