summaryrefslogtreecommitdiff
path: root/Gestor.Common/Gestor.Common.Converters/ComparativoConverter.cs
blob: 55df688b1ccc0af85fbfca47f5e1e20de23b0337 (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
using System;
using System.Globalization;
using System.Windows.Data;

namespace Gestor.Common.Converters;

public class ComparativoConverter : IMultiValueConverter
{
	public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
	{
		if (values[0] == null)
		{
			return 0;
		}
		if (values[1] == null)
		{
			return 0;
		}
		decimal num = ((!(values[0] is int)) ? ((decimal?)values[0]).GetValueOrDefault() : ((decimal)(int)values[0]));
		decimal num2 = ((!(values[1] is int)) ? ((decimal?)values[1]).GetValueOrDefault() : ((decimal)(int)values[1]));
		if (num == 0m && num2 == 0m)
		{
			return 0;
		}
		if (num == 0m && num2 > 0m)
		{
			return -1;
		}
		if (num2 == 0m && num > 0m)
		{
			return 1;
		}
		if (num == 0m && num2 < 0m)
		{
			return 1;
		}
		if (num2 == 0m && num < 0m)
		{
			return -1;
		}
		decimal num3 = ((num2 > 0m) ? num2 : (-num2));
		return (num - num2) / num3;
	}

	public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
	{
		return null;
	}
}