Example #1
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            WSolidColorBrush brush = null;

            var element = value as FrameworkElement;

            if (element != null)
            {
                while (brush == null && element != null)
                {
                    DependencyProperty property = GetBackgroundProperty(element);
                    if (property != null)
                    {
                        value = element.GetValue(property);
                        brush = value as WSolidColorBrush;
                        if (brush != null && brush.Color == Colors.Transparent)
                        {
                            brush = null;
                        }
                    }

                    element = VisualTreeHelper.GetParent(element) as FrameworkElement;
                }
            }

            brush = value as WSolidColorBrush;
            if (brush != null)
            {
                Maui.Graphics.Color color = brush.ToFormsColor();

                double delta = Shift;
                if (color.GetLuminosity() > .6)
                {
                    delta = -Shift;
                }

                color = color.AddLuminosity((float)delta);

                return(new WSolidColorBrush(color.ToWindowsColor()));
            }

            return(null);
        }