|
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 (((Issue) value).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;
}
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 Service 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.
Weidong has been an information system professional since 1990. He has a Master's degree in Computer Science, and is currently a MCSD .NET