1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
using Gestor.Common.Helpers;
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Markup;
using System.Windows.Media;
namespace Gestor.Common.Converters
{
public class TarefaBackgroundColorConverter : MarkupExtension, IValueConverter
{
public TarefaBackgroundColorConverter()
{
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null && !((DateTime)value < Functions.GetNetworkTime()))
{
return new SolidColorBrush(Colors.Black);
}
return new SolidColorBrush(this.ConvertStringToColor("#fc636b"));
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
public Color ConvertStringToColor(string hex)
{
hex = hex.Replace("#", "");
byte num = 255;
byte num1 = 255;
byte num2 = 255;
byte num3 = 255;
int num4 = 0;
if (hex.Length == 8)
{
num = byte.Parse(hex.Substring(0, 2), NumberStyles.HexNumber);
num4 = 2;
}
num1 = byte.Parse(hex.Substring(num4, 2), NumberStyles.HexNumber);
num2 = byte.Parse(hex.Substring(num4 + 2, 2), NumberStyles.HexNumber);
num3 = byte.Parse(hex.Substring(num4 + 4, 2), NumberStyles.HexNumber);
return Color.FromArgb(num, num1, num2, num3);
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}
|