summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Converters/ValorTipoConverter.cs
blob: cf2719e3a0d6ffbce49b58575acddc00622d1d60 (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
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;

namespace Gestor.Application.Converters;

public class ValorTipoConverter : MarkupExtension, IMultiValueConverter
{
	object IMultiValueConverter.Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
	{
		if (values == null || values[1] == null || values[0] == DependencyProperty.UnsetValue)
		{
			return null;
		}
		if (values[0] != null)
		{
			string text = values[0].ToString();
			if (!(text == "VALOR"))
			{
				if (!(text == "PERCENTUAL"))
				{
					return values[1].ToString();
				}
				return ((decimal)values[1]).ToString("p2");
			}
			return ((decimal)values[1]).ToString("c2");
		}
		return values[1].ToString();
	}

	object[] IMultiValueConverter.ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
	{
		throw new NotImplementedException();
	}

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