38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using System.Windows.Data;
|
|
using SWS.Model;
|
|
|
|
namespace SWS.Commons.Helper.Converter
|
|
{
|
|
public class TimeSpanToColourValueConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value is TimeSpan timeSpan)
|
|
{
|
|
//小于十五天
|
|
if (timeSpan< TimeSpan.FromDays(15)&& timeSpan >= TimeSpan.FromDays(2))
|
|
{
|
|
return "#FFD4AF37";
|
|
}
|
|
else if (timeSpan < TimeSpan.FromDays(2)&& timeSpan >= TimeSpan.Zero)
|
|
{
|
|
return "#fc7c2c";
|
|
}
|
|
else if ( timeSpan < TimeSpan.Zero)
|
|
{
|
|
return "Red";
|
|
}
|
|
}
|
|
|
|
return "Green";
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|