using System; using System.Windows.Data; using System.Windows.Media; using IssueVision.Data.Web; namespace IssueVision.Common { /// <summary> /// One way IValueConverter that returns a SolidColorBrush based on Issue.Priority /// </summary> public class IssueBrushConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { SolidColorBrush brush; if ((value as Issue).ResolutionID == null || (value as Issue).ResolutionID == 0) { switch ((value as Issue).Priority) { case 1: brush = new SolidColorBrush(Colors.Red); break; case 2: brush = new SolidColorBrush(Colors.Orange); break; case 3: brush = new SolidColorBrush(Colors.Blue); break; case 4: brush = new SolidColorBrush(Colors.Green); break; default: brush = new SolidColorBrush(Colors.White); break; } brush.Color = new Color { A = (byte)(brush.Color.A / 2), B = brush.Color.B, G = brush.Color.G, R = brush.Color.R }; return brush; } else { return null; } } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotSupportedException(); } } }
By viewing downloads associated with this article you agree to the Terms of use and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Math Primers for Programmers