summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Common/Gestor.Common.Converters/StatusExtratoColorConverter.cs
blob: d6e2fba38b4e9f15556844159d672409cc12efa3 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
using Gestor.Model.Common;
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;
using System.Windows.Media;

namespace Gestor.Common.Converters
{
	public class StatusExtratoColorConverter : MarkupExtension, IValueConverter
	{
		public StatusExtratoColorConverter()
		{
		}

		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (value == null)
			{
				return new SolidColorBrush(Colors.Black);
			}
			switch ((StatusParcela)value)
			{
				case StatusParcela.Baixada:
				case StatusParcela.BaixadaAnteriormente:
				case StatusParcela.BaixadaDiferencaPercentual:
				case StatusParcela.BaixadaManualmente:
				case StatusParcela.ParcelaEspecialBaixadaAnteriormente:
				{
					return new SolidColorBrush(Colors.Green);
				}
				case StatusParcela.DocumentoNaoEncontrado:
				case StatusParcela.ParcelaNaoEncontrada:
				case StatusParcela.DesconsideradaUsuario:
				case StatusParcela.ParcelaAnteriorNaoBaixada:
				{
					return new SolidColorBrush(Colors.Red);
				}
				case StatusParcela.DesconsideradaSistema:
				{
					return new SolidColorBrush(Colors.Gray);
				}
				case StatusParcela.ApoliceDuplicada:
				{
					return new SolidColorBrush((Color)Application.Current.Resources["AggerYellow100"]);
				}
				default:
				{
					return new SolidColorBrush(Colors.Black);
				}
			}
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			return (value == null || string.IsNullOrEmpty(value.ToString()) ? 0 : int.Parse(value.ToString()));
		}

		public override object ProvideValue(IServiceProvider serviceProvider)
		{
			return this;
		}
	}
}