diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 17:17:46 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 17:17:46 +0000 |
| commit | 0440c722a221b8068bbf388c1c0c51f0faff0451 (patch) | |
| tree | 169cbf90c50ff7961db82ecb606c50c2a45a1688 /Gestor.Common/Gestor.Common.Converters | |
| parent | 225aa1499e37faf9d38257caabbadc68d78b427e (diff) | |
| download | gestor-master.tar.gz gestor-master.zip | |
Diffstat (limited to 'Gestor.Common/Gestor.Common.Converters')
52 files changed, 1726 insertions, 0 deletions
diff --git a/Gestor.Common/Gestor.Common.Converters/ApolicePendenteConverter.cs b/Gestor.Common/Gestor.Common.Converters/ApolicePendenteConverter.cs new file mode 100644 index 0000000..066a108 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ApolicePendenteConverter.cs @@ -0,0 +1,28 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class ApolicePendenteConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null || string.IsNullOrEmpty((string)value)) + { + return "PENDENTE DE EMISSÃO"; + } + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ArquivoDigitalToolTipConverter.cs b/Gestor.Common/Gestor.Common.Converters/ArquivoDigitalToolTipConverter.cs new file mode 100644 index 0000000..f53e93a --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ArquivoDigitalToolTipConverter.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Windows.Data; +using System.Windows.Markup; +using Gestor.Model.Domain.Common; + +namespace Gestor.Common.Converters; + +public class ArquivoDigitalToolTipConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && ((List<IndiceArquivoDigital>)value).Count != 0) + { + return string.Join(Environment.NewLine, ((List<IndiceArquivoDigital>)value).Select((IndiceArquivoDigital v) => v.Descricao)); + } + return ""; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/AtivoConverterColor.cs b/Gestor.Common/Gestor.Common.Converters/AtivoConverterColor.cs new file mode 100644 index 0000000..02d727a --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/AtivoConverterColor.cs @@ -0,0 +1,36 @@ +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 AtivoConverterColor : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + //IL_002a: Unknown result type (might be due to invalid IL or missing references) + //IL_002f: Unknown result type (might be due to invalid IL or missing references) + //IL_0035: Expected O, but got Unknown + //IL_001f: Unknown result type (might be due to invalid IL or missing references) + //IL_0024: Unknown result type (might be due to invalid IL or missing references) + //IL_002a: Expected O, but got Unknown + if (value != null && (bool)value) + { + return (object)new SolidColorBrush((Color)Application.Current.Resources[(object)"AggerBlue"]); + } + return (object)new SolidColorBrush(Colors.Red); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/AtivoVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/AtivoVisibilityConverter.cs new file mode 100644 index 0000000..72bc781 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/AtivoVisibilityConverter.cs @@ -0,0 +1,32 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace Gestor.Common.Converters; + +public class AtivoVisibilityConverter : IMultiValueConverter +{ + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + object obj = values[0]; + if (obj is bool && (bool)obj) + { + return (object)(Visibility)2; + } + if (values[1] == null) + { + return (object)(Visibility)0; + } + if (values[1] is long num && num > 0) + { + return (object)(Visibility)2; + } + return (object)(Visibility)0; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/BoolToEyeConverter.cs b/Gestor.Common/Gestor.Common.Converters/BoolToEyeConverter.cs new file mode 100644 index 0000000..4baccf6 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/BoolToEyeConverter.cs @@ -0,0 +1,32 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class BoolToEyeConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return "Eye"; + } + if (!(bool)value) + { + return "Eye"; + } + return "EyeOff"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value != null && !string.IsNullOrEmpty(value.ToString())) ? int.Parse(value.ToString()) : 0; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/BoolToYesNoConverter.cs b/Gestor.Common/Gestor.Common.Converters/BoolToYesNoConverter.cs new file mode 100644 index 0000000..37dba8d --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/BoolToYesNoConverter.cs @@ -0,0 +1,28 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class BoolToYesNoConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && (bool)value) + { + return "SIM"; + } + return "NÃO"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ComissaoColorConverter.cs b/Gestor.Common/Gestor.Common.Converters/ComissaoColorConverter.cs new file mode 100644 index 0000000..7317a5f --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ComissaoColorConverter.cs @@ -0,0 +1,43 @@ +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 ComissaoColorConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + //IL_0003: Unknown result type (might be due to invalid IL or missing references) + //IL_0008: Unknown result type (might be due to invalid IL or missing references) + //IL_000e: Expected O, but got Unknown + //IL_0054: Unknown result type (might be due to invalid IL or missing references) + //IL_0059: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Expected O, but got Unknown + //IL_0035: Unknown result type (might be due to invalid IL or missing references) + //IL_003a: Unknown result type (might be due to invalid IL or missing references) + //IL_0040: Expected O, but got Unknown + if (value != null) + { + if ((int)Math.Round(double.Parse(value.ToString())) >= 0 && (int)Math.Round(double.Parse(value.ToString())) != 0) + { + return (object)new SolidColorBrush(Colors.Red); + } + return (object)new SolidColorBrush((Color)Application.Current.Resources[(object)"AggerBlue"]); + } + return (object)new SolidColorBrush(Colors.Red); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value != null && !string.IsNullOrEmpty(value.ToString())) ? int.Parse(value.ToString()) : 0; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ComissaoConverter.cs b/Gestor.Common/Gestor.Common.Converters/ComissaoConverter.cs new file mode 100644 index 0000000..2a8338c --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ComissaoConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class ComissaoConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return ((decimal?)value / (decimal?)100).GetValueOrDefault(); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ComissaoConverterMulti.cs b/Gestor.Common/Gestor.Common.Converters/ComissaoConverterMulti.cs new file mode 100644 index 0000000..2812699 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ComissaoConverterMulti.cs @@ -0,0 +1,62 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using Gestor.Model.Common; + +namespace Gestor.Common.Converters; + +public class ComissaoConverterMulti : IMultiValueConverter +{ + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + //IL_002b: Unknown result type (might be due to invalid IL or missing references) + //IL_0030: Unknown result type (might be due to invalid IL or missing references) + //IL_00d5: Unknown result type (might be due to invalid IL or missing references) + //IL_00d7: Invalid comparison between Unknown and I4 + //IL_00e1: Unknown result type (might be due to invalid IL or missing references) + //IL_00e3: Invalid comparison between Unknown and I4 + //IL_0084: Unknown result type (might be due to invalid IL or missing references) + //IL_0086: Invalid comparison between Unknown and I4 + if (values[0] == DependencyProperty.UnsetValue && values[1] == DependencyProperty.UnsetValue) + { + return null; + } + if (values[1] == DependencyProperty.UnsetValue) + { + return values[0]; + } + object obj = values[0]; + TipoRepasse val = (TipoRepasse)values[1]; + switch (parameter.ToString().ToLower()) + { + default: + if ((int)val == 1) + { + return "--"; + } + return ((decimal?)obj / (decimal?)100).GetValueOrDefault(); + case "tipovendedorcolumn": + if ((int)val == 3) + { + return "CO-CORRETAGEM"; + } + return obj; + case "formapagamentocolumn": + case "incidenciacolumn": + if ((int)val == 3) + { + return "--"; + } + return obj; + case "pagamentosvalorrepassecolumn": + case "repassevendedor": + return obj; + } + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ComparativoColorConverter.cs b/Gestor.Common/Gestor.Common.Converters/ComparativoColorConverter.cs new file mode 100644 index 0000000..235f0a3 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ComparativoColorConverter.cs @@ -0,0 +1,56 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media; + +namespace Gestor.Common.Converters; + +public class ComparativoColorConverter : IMultiValueConverter +{ + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + try + { + 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 Brushes.DarkGoldenrod; + } + if (num == 0m && num2 > 0m) + { + return Brushes.Red; + } + if (num2 == 0m && num > 0m) + { + return Brushes.Green; + } + if (num == 0m && num2 < 0m) + { + return Brushes.Green; + } + if (num2 == 0m && num < 0m) + { + return Brushes.Red; + } + return (num / num2 - 1m > 0m) ? Brushes.Green : Brushes.Red; + } + catch (Exception) + { + return Brushes.Black; + } + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ComparativoConverter.cs b/Gestor.Common/Gestor.Common.Converters/ComparativoConverter.cs new file mode 100644 index 0000000..55df688 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ComparativoConverter.cs @@ -0,0 +1,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; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ComparativoPercentualToolTipConverter.cs b/Gestor.Common/Gestor.Common.Converters/ComparativoPercentualToolTipConverter.cs new file mode 100644 index 0000000..4949f85 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ComparativoPercentualToolTipConverter.cs @@ -0,0 +1,26 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace Gestor.Common.Converters; + +public class ComparativoPercentualToolTipConverter : IMultiValueConverter +{ + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + try + { + decimal num = (decimal)values[1] * 100m; + return $"VALOR EM {values[0]}: {num}%"; + } + catch (Exception) + { + return ""; + } + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ComparativoToolTipConverter.cs b/Gestor.Common/Gestor.Common.Converters/ComparativoToolTipConverter.cs new file mode 100644 index 0000000..a995ab6 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ComparativoToolTipConverter.cs @@ -0,0 +1,19 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace Gestor.Common.Converters; + +public class ComparativoToolTipConverter : IMultiValueConverter +{ + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + string arg = ((!(values[0] is int)) ? "R$" : ""); + return $"VALOR EM {values[0]}: {arg} {values[1]}"; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/EnumDescriptionConverter.cs b/Gestor.Common/Gestor.Common.Converters/EnumDescriptionConverter.cs new file mode 100644 index 0000000..70a9094 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/EnumDescriptionConverter.cs @@ -0,0 +1,29 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; +using Gestor.Common.Validation; + +namespace Gestor.Common.Converters; + +public class EnumDescriptionConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is Enum) + { + return ((Enum)value).GetDescription(); + } + return ""; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ExpanderHeaderConverter.cs b/Gestor.Common/Gestor.Common.Converters/ExpanderHeaderConverter.cs new file mode 100644 index 0000000..e6cb7ff --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ExpanderHeaderConverter.cs @@ -0,0 +1,28 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class ExpanderHeaderConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && (bool)value) + { + return "MENOS INFORMAÇÕES"; + } + return "MAIS INFORMAÇÕES"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/IdToVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/IdToVisibilityConverter.cs new file mode 100644 index 0000000..ad727b8 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/IdToVisibilityConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class IdToVisibilityConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (object)(Visibility)((value != null && (int)Math.Round(double.Parse(value.ToString())) != 0) ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value != null && !string.IsNullOrEmpty(value.ToString())) ? int.Parse(value.ToString()) : 0; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/InativoVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/InativoVisibilityConverter.cs new file mode 100644 index 0000000..87a117d --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/InativoVisibilityConverter.cs @@ -0,0 +1,32 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace Gestor.Common.Converters; + +public class InativoVisibilityConverter : IMultiValueConverter +{ + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + object obj = values[0]; + if (obj is bool && (bool)obj) + { + return (object)(Visibility)0; + } + if (values[1] == null) + { + return (object)(Visibility)2; + } + if (values[1] is long num && num > 0) + { + return (object)(Visibility)0; + } + return (object)(Visibility)2; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/InvertedBooleanConverter.cs b/Gestor.Common/Gestor.Common.Converters/InvertedBooleanConverter.cs new file mode 100644 index 0000000..e0d5826 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/InvertedBooleanConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class InvertedBooleanConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value != null && !(bool)value; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/InvertedBooleanToVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/InvertedBooleanToVisibilityConverter.cs new file mode 100644 index 0000000..30fda38 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/InvertedBooleanToVisibilityConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class InvertedBooleanToVisibilityConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (object)(Visibility)((value != null && (bool)value) ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/InvertedVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/InvertedVisibilityConverter.cs new file mode 100644 index 0000000..aef3395 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/InvertedVisibilityConverter.cs @@ -0,0 +1,26 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class InvertedVisibilityConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + //IL_0004: Unknown result type (might be due to invalid IL or missing references) + return (object)(Visibility)((value != null && (int)(Visibility)value == 0) ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/IsInsertedBoolConverter.cs b/Gestor.Common/Gestor.Common.Converters/IsInsertedBoolConverter.cs new file mode 100644 index 0000000..724481a --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/IsInsertedBoolConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class IsInsertedBoolConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value != null && (long)value != 0; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/IsNotNullBoolConverter.cs b/Gestor.Common/Gestor.Common.Converters/IsNotNullBoolConverter.cs new file mode 100644 index 0000000..069e68e --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/IsNotNullBoolConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class IsNotNullBoolConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value != null; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/MesConverter.cs b/Gestor.Common/Gestor.Common.Converters/MesConverter.cs new file mode 100644 index 0000000..e3b8e80 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/MesConverter.cs @@ -0,0 +1,35 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; +using Gestor.Common.Validation; +using Gestor.Model.Common; + +namespace Gestor.Common.Converters; + +public class MesConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + if (value == null) + { + return ""; + } + if (value is Mes) + { + return ((Enum)(object)(Mes)value).GetDescription(); + } + return ""; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/MultiBoolAndConverter.cs b/Gestor.Common/Gestor.Common.Converters/MultiBoolAndConverter.cs new file mode 100644 index 0000000..51cb583 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/MultiBoolAndConverter.cs @@ -0,0 +1,26 @@ +using System; +using System.Globalization; +using System.Linq; +using System.Windows.Data; + +namespace Gestor.Common.Converters; + +public class MultiBoolAndConverter : IMultiValueConverter +{ + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + try + { + return values.All((object value) => (bool)value); + } + catch + { + return false; + } + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/NegativoColorConverter.cs b/Gestor.Common/Gestor.Common.Converters/NegativoColorConverter.cs new file mode 100644 index 0000000..9c7abf7 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/NegativoColorConverter.cs @@ -0,0 +1,42 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; +using System.Windows.Media; + +namespace Gestor.Common.Converters; + +public class NegativoColorConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + //IL_0010: Unknown result type (might be due to invalid IL or missing references) + //IL_0015: Unknown result type (might be due to invalid IL or missing references) + //IL_001b: Expected O, but got Unknown + //IL_0038: Unknown result type (might be due to invalid IL or missing references) + //IL_003d: Unknown result type (might be due to invalid IL or missing references) + //IL_0043: Expected O, but got Unknown + //IL_002d: Unknown result type (might be due to invalid IL or missing references) + //IL_0032: Unknown result type (might be due to invalid IL or missing references) + //IL_0038: Expected O, but got Unknown + if (value != null && !string.IsNullOrEmpty(value.ToString())) + { + if (value.ToString().Contains("-")) + { + return (object)new SolidColorBrush(Colors.Red); + } + return (object)new SolidColorBrush(Colors.Black); + } + return (object)new SolidColorBrush(Colors.Black); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/NullVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/NullVisibilityConverter.cs new file mode 100644 index 0000000..fb6d8a5 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/NullVisibilityConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class NullVisibilityConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (object)(Visibility)((value == null) ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/NullVisibilityInvertedConverter.cs b/Gestor.Common/Gestor.Common.Converters/NullVisibilityInvertedConverter.cs new file mode 100644 index 0000000..2d4b917 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/NullVisibilityInvertedConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class NullVisibilityInvertedConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (object)(Visibility)((value != null) ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ObjectToStringConverter.cs b/Gestor.Common/Gestor.Common.Converters/ObjectToStringConverter.cs new file mode 100644 index 0000000..2748ce0 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ObjectToStringConverter.cs @@ -0,0 +1,41 @@ +using System; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Reflection; +using System.Windows.Data; + +namespace Gestor.Common.Converters; + +public class ObjectToStringConverter : IValueConverter +{ + public static readonly ObjectToStringConverter Instance = new ObjectToStringConverter(); + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is Enum @enum) + { + MemberInfo[] member = @enum.GetType().GetMember(@enum.ToString()); + if (member.Length == 0) + { + return @enum.ToString(); + } + object[] customAttributes = member[0].GetCustomAttributes(typeof(DescriptionAttribute), inherit: false); + if (!customAttributes.Any()) + { + return @enum.ToString().Trim(); + } + return ((DescriptionAttribute)customAttributes.ElementAt(0)).Description.Trim(); + } + if (value is DateTime dateTime) + { + return dateTime.ToShortDateString(); + } + return value?.ToString(); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ObjectVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/ObjectVisibilityConverter.cs new file mode 100644 index 0000000..67fbf0f --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ObjectVisibilityConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; +using Gestor.Model.Common; + +namespace Gestor.Common.Converters; + +public class ObjectVisibilityConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + //IL_0004: Unknown result type (might be due to invalid IL or missing references) + //IL_000b: Invalid comparison between Unknown and I4 + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_0015: Invalid comparison between Unknown and I4 + return (object)(Visibility)((value != null && ((int)(TipoTelefone)value == 10 || (int)(TipoTelefone)value == 11)) ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/PagamentoVendedorCorretoraVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/PagamentoVendedorCorretoraVisibilityConverter.cs new file mode 100644 index 0000000..8eb4a0d --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/PagamentoVendedorCorretoraVisibilityConverter.cs @@ -0,0 +1,23 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace Gestor.Common.Converters; + +public class PagamentoVendedorCorretoraVisibilityConverter : IMultiValueConverter +{ + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values[1] is bool && values[0] == null && (bool)values[1]) + { + return (object)(Visibility)2; + } + return (object)(Visibility)0; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ParcelaVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/ParcelaVisibilityConverter.cs new file mode 100644 index 0000000..cf0011c --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ParcelaVisibilityConverter.cs @@ -0,0 +1,28 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; +using Gestor.Model.Common; + +namespace Gestor.Common.Converters; + +public class ParcelaVisibilityConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + //IL_0004: Unknown result type (might be due to invalid IL or missing references) + //IL_000a: Invalid comparison between Unknown and I4 + return (object)(Visibility)((value != null && (int)(TipoRecebimento)value == 2) ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/PendenciaConverter.cs b/Gestor.Common/Gestor.Common.Converters/PendenciaConverter.cs new file mode 100644 index 0000000..1d24905 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/PendenciaConverter.cs @@ -0,0 +1,29 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; +using Gestor.Common.Helpers; + +namespace Gestor.Common.Converters; + +public class PendenciaConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return ""; + } + return $"{(Functions.GetNetworkTime().Date - ((DateTime)value).Date).TotalDays:N0} DIAS"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/PendenciaVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/PendenciaVisibilityConverter.cs new file mode 100644 index 0000000..13876dc --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/PendenciaVisibilityConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; +using Gestor.Common.Helpers; + +namespace Gestor.Common.Converters; + +public class PendenciaVisibilityConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return ""; + } + return (object)(Visibility)((Functions.GetNetworkTime().Date < (DateTime)value) ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/RamoAutoVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/RamoAutoVisibilityConverter.cs new file mode 100644 index 0000000..618c35d --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/RamoAutoVisibilityConverter.cs @@ -0,0 +1,42 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Common.Converters; + +public class RamoAutoVisibilityConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_0021: Unknown result type (might be due to invalid IL or missing references) + //IL_003a: Unknown result type (might be due to invalid IL or missing references) + Documento val = (Documento)value; + object obj; + if (val == null) + { + obj = null; + } + else + { + Controle controle = val.Controle; + obj = ((controle != null) ? controle.Ramo : null); + } + return (object)(Visibility)((obj == null || (((DomainBase)((Documento)value).Controle.Ramo).Id != 5 && ((DomainBase)((Documento)value).Controle.Ramo).Id != 2)) ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/RecebidoColorConverter.cs b/Gestor.Common/Gestor.Common.Converters/RecebidoColorConverter.cs new file mode 100644 index 0000000..fb0146a --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/RecebidoColorConverter.cs @@ -0,0 +1,36 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media; + +namespace Gestor.Common.Converters; + +public class RecebidoColorConverter : IMultiValueConverter +{ + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_000a: Unknown result type (might be due to invalid IL or missing references) + //IL_0010: Expected O, but got Unknown + //IL_002f: Unknown result type (might be due to invalid IL or missing references) + //IL_0034: Unknown result type (might be due to invalid IL or missing references) + //IL_003a: Expected O, but got Unknown + //IL_0024: Unknown result type (might be due to invalid IL or missing references) + //IL_0029: Unknown result type (might be due to invalid IL or missing references) + //IL_002f: Expected O, but got Unknown + if (values[1] == null) + { + if ((DateTime)values[0] < DateTime.Today) + { + return (object)new SolidColorBrush(Colors.Red); + } + return (object)new SolidColorBrush(Colors.Black); + } + return (object)new SolidColorBrush(Colors.Green); + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/SaldoWeightConverter.cs b/Gestor.Common/Gestor.Common.Converters/SaldoWeightConverter.cs new file mode 100644 index 0000000..51fb8b4 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/SaldoWeightConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class SaldoWeightConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + //IL_000b: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + return (value != null && !(bool)value) ? FontWeights.Regular : FontWeights.Bold; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/SinalColorConverter.cs b/Gestor.Common/Gestor.Common.Converters/SinalColorConverter.cs new file mode 100644 index 0000000..aceadd3 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/SinalColorConverter.cs @@ -0,0 +1,38 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; +using System.Windows.Media; +using Gestor.Model.Common; + +namespace Gestor.Common.Converters; + +public class SinalColorConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + //IL_0011: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Expected O, but got Unknown + //IL_0004: Unknown result type (might be due to invalid IL or missing references) + //IL_000a: Invalid comparison between Unknown and I4 + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Expected O, but got Unknown + if (value != null && (int)(Sinal)value == 1) + { + return (object)new SolidColorBrush(Colors.Red); + } + return (object)new SolidColorBrush(Colors.Black); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/StatusExtratoColorConverter.cs b/Gestor.Common/Gestor.Common.Converters/StatusExtratoColorConverter.cs new file mode 100644 index 0000000..e1217f0 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/StatusExtratoColorConverter.cs @@ -0,0 +1,74 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; +using System.Windows.Media; +using Gestor.Model.Common; + +namespace Gestor.Common.Converters; + +public class StatusExtratoColorConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + //IL_000f: Unknown result type (might be due to invalid IL or missing references) + //IL_0014: Unknown result type (might be due to invalid IL or missing references) + //IL_0015: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_0071: Expected I4, but got Unknown + //IL_0003: Unknown result type (might be due to invalid IL or missing references) + //IL_0008: Unknown result type (might be due to invalid IL or missing references) + //IL_000e: Expected O, but got Unknown + //IL_007c: Unknown result type (might be due to invalid IL or missing references) + //IL_0081: Unknown result type (might be due to invalid IL or missing references) + //IL_0087: Expected O, but got Unknown + //IL_0087: Unknown result type (might be due to invalid IL or missing references) + //IL_008c: Unknown result type (might be due to invalid IL or missing references) + //IL_0092: Expected O, but got Unknown + //IL_0071: Unknown result type (might be due to invalid IL or missing references) + //IL_0076: Unknown result type (might be due to invalid IL or missing references) + //IL_007c: Expected O, but got Unknown + //IL_00b1: Unknown result type (might be due to invalid IL or missing references) + //IL_00b6: Unknown result type (might be due to invalid IL or missing references) + //IL_00bc: Expected O, but got Unknown + //IL_00a6: Unknown result type (might be due to invalid IL or missing references) + //IL_00ab: Unknown result type (might be due to invalid IL or missing references) + //IL_00b1: Expected O, but got Unknown + if (value == null) + { + return (object)new SolidColorBrush(Colors.Black); + } + StatusParcela val = (StatusParcela)value; + switch ((int)val - 1) + { + default: + return (object)new SolidColorBrush(Colors.Black); + case 0: + case 4: + case 9: + case 11: + case 20: + return (object)new SolidColorBrush(Colors.Green); + case 1: + case 2: + case 5: + case 6: + return (object)new SolidColorBrush(Colors.Red); + case 10: + return (object)new SolidColorBrush((Color)Application.Current.Resources[(object)"AggerYellow100"]); + case 7: + return (object)new SolidColorBrush(Colors.Gray); + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value != null && !string.IsNullOrEmpty(value.ToString())) ? int.Parse(value.ToString()) : 0; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/StatusParcelaVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/StatusParcelaVisibilityConverter.cs new file mode 100644 index 0000000..64be20d --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/StatusParcelaVisibilityConverter.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; +using Gestor.Model.Common; + +namespace Gestor.Common.Converters; + +public class StatusParcelaVisibilityConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + //IL_002f: Unknown result type (might be due to invalid IL or missing references) + if (value == null) + { + return (object)(Visibility)2; + } + return (object)(Visibility)((!new List<StatusParcela> + { + (StatusParcela)1, + (StatusParcela)10, + (StatusParcela)12, + (StatusParcela)13 + }.Contains((StatusParcela)value)) ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/StatusTarefaVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/StatusTarefaVisibilityConverter.cs new file mode 100644 index 0000000..466515c --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/StatusTarefaVisibilityConverter.cs @@ -0,0 +1,34 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; +using Gestor.Model.Common; + +namespace Gestor.Common.Converters; + +public class StatusTarefaVisibilityConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + //IL_0019: Unknown result type (might be due to invalid IL or missing references) + //IL_001f: Invalid comparison between Unknown and I4 + //IL_0025: Unknown result type (might be due to invalid IL or missing references) + //IL_002b: Unknown result type (might be due to invalid IL or missing references) + //IL_0028: Unknown result type (might be due to invalid IL or missing references) + bool result = default(bool); + bool num = parameter != null && bool.TryParse(parameter.ToString(), out result) && result; + Visibility val = (Visibility)((value != null && (int)(StatusTarefa)value != 2) ? 2 : 0); + return (object)(Visibility)((!num) ? ((int)val) : (((int)val == 0) ? 2 : 0)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/StringNullOrEmptyToVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/StringNullOrEmptyToVisibilityConverter.cs new file mode 100644 index 0000000..fa41f0b --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/StringNullOrEmptyToVisibilityConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class StringNullOrEmptyToVisibilityConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (object)(Visibility)(string.IsNullOrEmpty(value as string) ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/TarefaBackgroundColorConverter.cs b/Gestor.Common/Gestor.Common.Converters/TarefaBackgroundColorConverter.cs new file mode 100644 index 0000000..5332312 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/TarefaBackgroundColorConverter.cs @@ -0,0 +1,56 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; +using System.Windows.Media; +using Gestor.Common.Helpers; + +namespace Gestor.Common.Converters; + +public class TarefaBackgroundColorConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + //IL_0026: Unknown result type (might be due to invalid IL or missing references) + //IL_002b: Unknown result type (might be due to invalid IL or missing references) + //IL_0031: Expected O, but got Unknown + //IL_0015: Unknown result type (might be due to invalid IL or missing references) + //IL_001a: Unknown result type (might be due to invalid IL or missing references) + //IL_0020: Expected O, but got Unknown + if (value != null && !((DateTime)value < Functions.GetNetworkTime())) + { + return (object)new SolidColorBrush(Colors.Black); + } + return (object)new SolidColorBrush(ConvertStringToColor("#fc636b")); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + + public Color ConvertStringToColor(string hex) + { + //IL_0090: Unknown result type (might be due to invalid IL or missing references) + hex = hex.Replace("#", ""); + byte b = byte.MaxValue; + byte b2 = byte.MaxValue; + byte b3 = byte.MaxValue; + byte b4 = byte.MaxValue; + int num = 0; + if (hex.Length == 8) + { + b = byte.Parse(hex.Substring(0, 2), NumberStyles.HexNumber); + num = 2; + } + b2 = byte.Parse(hex.Substring(num, 2), NumberStyles.HexNumber); + b3 = byte.Parse(hex.Substring(num + 2, 2), NumberStyles.HexNumber); + b4 = byte.Parse(hex.Substring(num + 4, 2), NumberStyles.HexNumber); + return Color.FromArgb(b, b2, b3, b4); + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/TemTarefaVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/TemTarefaVisibilityConverter.cs new file mode 100644 index 0000000..c4a4202 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/TemTarefaVisibilityConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; +using Gestor.Model.Domain.Ferramentas; + +namespace Gestor.Common.Converters; + +public class TemTarefaVisibilityConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (object)(Visibility)((value == null || ((ObservableCollection<Tarefa>)value).Count == 0) ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/TipoCriticaConverter.cs b/Gestor.Common/Gestor.Common.Converters/TipoCriticaConverter.cs new file mode 100644 index 0000000..b45f5d3 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/TipoCriticaConverter.cs @@ -0,0 +1,34 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace Gestor.Common.Converters; + +public class TipoCriticaConverter : IMultiValueConverter +{ + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + try + { + string text = (string)values[0]; + if (!(text == "0")) + { + if (!(text == "1")) + { + return ""; + } + return (string)values[2]; + } + return (string)values[1]; + } + catch (Exception) + { + return ""; + } + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/TipoSinistroConverter.cs b/Gestor.Common/Gestor.Common.Converters/TipoSinistroConverter.cs new file mode 100644 index 0000000..f344ca9 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/TipoSinistroConverter.cs @@ -0,0 +1,39 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using Gestor.Model.Common; + +namespace Gestor.Common.Converters; + +public class TipoSinistroConverter : IMultiValueConverter +{ + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_001b: Unknown result type (might be due to invalid IL or missing references) + if (!(values[0] is TipoSinistro val)) + { + return ""; + } + if ((int)val == 0) + { + return "CLIENTE"; + } + object obj = values[1]; + if (obj != null) + { + if (obj is string text) + { + return "TERCEIRO Nº " + text; + } + return ""; + } + return "TERCEIRO"; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/TipoTelefoneVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/TipoTelefoneVisibilityConverter.cs new file mode 100644 index 0000000..d857625 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/TipoTelefoneVisibilityConverter.cs @@ -0,0 +1,37 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using Gestor.Model.Common; + +namespace Gestor.Common.Converters; + +public class TipoTelefoneVisibilityConverter : IMultiValueConverter +{ + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + //IL_0019: Unknown result type (might be due to invalid IL or missing references) + //IL_001e: Unknown result type (might be due to invalid IL or missing references) + //IL_001f: Unknown result type (might be due to invalid IL or missing references) + //IL_0021: Invalid comparison between Unknown and I4 + if (values[0] == null) + { + return (object)(Visibility)2; + } + if (values[0] is TipoTelefone val && (int)val != 3) + { + return (object)(Visibility)2; + } + object obj = values[1]; + if (obj is bool && (bool)obj) + { + return (object)(Visibility)2; + } + return (object)(Visibility)0; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/TotalizacaoExpanderConverter.cs b/Gestor.Common/Gestor.Common.Converters/TotalizacaoExpanderConverter.cs new file mode 100644 index 0000000..53f02ac --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/TotalizacaoExpanderConverter.cs @@ -0,0 +1,28 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class TotalizacaoExpanderConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && (bool)value) + { + return "ESCONDER TOTALIZAÇÃO"; + } + return "MOSTRAR TOTALIZAÇÃO"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ValorTipoConverter.cs b/Gestor.Common/Gestor.Common.Converters/ValorTipoConverter.cs new file mode 100644 index 0000000..69ee2d1 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ValorTipoConverter.cs @@ -0,0 +1,42 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.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; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ZeroToEmptyConverter.cs b/Gestor.Common/Gestor.Common.Converters/ZeroToEmptyConverter.cs new file mode 100644 index 0000000..7d3be65 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ZeroToEmptyConverter.cs @@ -0,0 +1,36 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class ZeroToEmptyConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null) + { + if (value is string) + { + return value; + } + if (!(Math.Abs(System.Convert.ToDouble(value)) < 0.01)) + { + return value.ToString(); + } + return ""; + } + return ""; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value != null && !string.IsNullOrEmpty(value.ToString())) ? int.Parse(value.ToString()) : 0; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityConverter.cs b/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityConverter.cs new file mode 100644 index 0000000..21d99b6 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class ZeroToVisibilityConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (object)(Visibility)((value == null || (int)Math.Round(double.Parse(value.ToString())) == 0) ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value != null && !string.IsNullOrEmpty(value.ToString())) ? int.Parse(value.ToString()) : 0; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityInvertedConverter.cs b/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityInvertedConverter.cs new file mode 100644 index 0000000..3680fcc --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityInvertedConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class ZeroToVisibilityInvertedConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (object)(Visibility)((value != null && (int)Math.Round(double.Parse(value.ToString())) != 0) ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value != null && !string.IsNullOrEmpty(value.ToString())) ? int.Parse(value.ToString()) : 0; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} diff --git a/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityValorConverter.cs b/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityValorConverter.cs new file mode 100644 index 0000000..4665173 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/ZeroToVisibilityValorConverter.cs @@ -0,0 +1,26 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class ZeroToVisibilityValorConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + decimal result; + return (object)(Visibility)((value == null || (!decimal.TryParse(value.ToString(), out result) && decimal.Parse(value.ToString()) <= 0m)) ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value != null && !string.IsNullOrEmpty(value.ToString())) ? int.Parse(value.ToString()) : 0; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} |