Exemplo n.º 1
0
        public virtual object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string[] strArray = parameter.ToString().Split(',');
            int      length   = strArray.Length;

            if (HighContrastHelper.CurrentTheme == HighContrastTheme.None && value is Color)
            {
                return(value);
            }
            return((object)ConverterUtils.GetColorFromString(HighContrastHelper.GetTheme(value) == HighContrastTheme.None && !false ? strArray[0].Trim() : (length != 3 || !HighContrastHelper.IsHighContrastWhiteOn() ? strArray[1].Trim() : strArray[2].Trim())));
        }
Exemplo n.º 2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string[]          strArray = parameter.ToString().Split(',');
            HighContrastTheme theme    = HighContrastHelper.GetTheme(value);

            if (theme != HighContrastTheme.None)
            {
                if (strArray[0] == "HighContrastBlackAndWhiteEffect")
                {
                    HighContrastBlackAndWhiteEffect blackAndWhiteEffect = new HighContrastBlackAndWhiteEffect();
                    blackAndWhiteEffect.Invert = theme == HighContrastTheme.White ? 1.0 : 0.0;
                    if (strArray.Length == 2)
                    {
                        blackAndWhiteEffect.Amount = double.Parse(strArray[1], (IFormatProvider)CultureInfo.InvariantCulture);
                    }
                    return((object)blackAndWhiteEffect);
                }
                if (strArray[0] == "HighContrastInvertColorsEffect")
                {
                    HighContrastInvertColorsEffect invertColorsEffect = new HighContrastInvertColorsEffect();
                    invertColorsEffect.Invert = theme == HighContrastTheme.White ? 1.0 : 0.0;
                    if (strArray.Length == 3)
                    {
                        invertColorsEffect.Brightness = double.Parse(strArray[1], (IFormatProvider)CultureInfo.InvariantCulture);
                        invertColorsEffect.Contrast   = double.Parse(strArray[2], (IFormatProvider)CultureInfo.InvariantCulture);
                    }
                    return((object)invertColorsEffect);
                }
                if (strArray[0] == "MonochromeEffect")
                {
                    return (object)new MonochromeEffect()
                           {
                               Invert = (theme == HighContrastTheme.White ? 1.0 : 0.0)
                           }
                }
                ;
            }
            return((object)null);
        }