Ejemplo n.º 1
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            SeverityIgnoreToColorConverter conv = new SeverityIgnoreToColorConverter();

            ViolationType           violationState = (ViolationType)values[0];
            ICollection <Violation> violations     = values[1] as ICollection <Violation>;

            decimal maxSeverity = violations.Max(vi => vi.Severity);
            decimal minSeverity = violations.Min(vi => vi.Severity);

            object[] objs = new object[2];
            objs[0] = maxSeverity;
            objs[1] = violationState;
            Color maxColor = (Color)conv.Convert(objs, typeof(System.Windows.Media.Color), parameter, culture);

            objs[0] = minSeverity;
            Color minColor            = (Color)conv.Convert(objs, typeof(System.Windows.Media.Color), parameter, culture);
            LinearGradientBrush brush = new LinearGradientBrush();

            brush.StartPoint = new Point(0, 1);
            brush.EndPoint   = new Point(0, 0);
            brush.GradientStops.Add(new GradientStop(minColor, 0));
            brush.GradientStops.Add(new GradientStop(maxColor, 1));
            return(brush);
        }
Ejemplo n.º 2
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            SeverityIgnoreToColorConverter conv = new SeverityIgnoreToColorConverter();

            ViolationType violationState = (ViolationType)values[0];
            ICollection<Violation> violations = values[1] as ICollection<Violation>;
            SolidColorBrush brush = new SolidColorBrush();
            brush.Color= Colors.White;
            if (violations != null && violations.Any())
            {
                decimal maxSeverity = violations.Max(vi => vi.Severity);
                decimal minSeverity = violations.Min(vi => vi.Severity);
                object[] objs = new object[2];
                objs[0] = maxSeverity;
                objs[1] = violationState;
                Color maxColor = (Color)conv.Convert(objs, typeof(Color), parameter, culture);
                objs[0] = minSeverity;
                //Color minColor = (Color)conv.Convert(objs, typeof(Color), parameter, culture);
                brush.Color = maxColor;
            }
            return brush;
        }
Ejemplo n.º 3
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            SeverityIgnoreToColorConverter conv = new SeverityIgnoreToColorConverter();

            ViolationType violationState = (ViolationType)values[0];
            ICollection<Violation> violations = values[1] as ICollection<Violation>;

            decimal maxSeverity = violations.Max(vi => vi.Severity);
            decimal minSeverity = violations.Min(vi => vi.Severity);
            object[] objs = new object[2];
            objs[0] = maxSeverity;
            objs[1] = violationState;
            Color maxColor = (Color)conv.Convert(objs, typeof(System.Windows.Media.Color), parameter, culture);
            objs[0] = minSeverity;
            Color minColor = (Color)conv.Convert(objs, typeof(System.Windows.Media.Color), parameter, culture);
            LinearGradientBrush brush = new LinearGradientBrush();
            brush.StartPoint = new Point(0, 1);
            brush.EndPoint = new Point(0, 0);
            brush.GradientStops.Add(new GradientStop(minColor, 0));
            brush.GradientStops.Add(new GradientStop(maxColor, 1));
            return brush;
        }