From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- Gestor.Application/Helpers/BindingHelper.cs | 239 ---------------------------- 1 file changed, 239 deletions(-) delete mode 100644 Gestor.Application/Helpers/BindingHelper.cs (limited to 'Gestor.Application/Helpers/BindingHelper.cs') diff --git a/Gestor.Application/Helpers/BindingHelper.cs b/Gestor.Application/Helpers/BindingHelper.cs deleted file mode 100644 index 3c9d76e..0000000 --- a/Gestor.Application/Helpers/BindingHelper.cs +++ /dev/null @@ -1,239 +0,0 @@ -using CurrencyTextBoxControl; -using Gestor.Common.Helpers; -using Gestor.Model.Helper; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Controls.Primitives; -using System.Windows.Data; - -namespace Gestor.Application.Helpers -{ - public static class BindingHelper - { - public static void AddBinding(object control, string path, ValidationRule rule = null) - { - Type type = control.GetType(); - Binding binding = new Binding() - { - Mode = BindingMode.TwoWay, - UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, - Path = new PropertyPath(path, Array.Empty()) - }; - if (rule != null) - { - binding.ValidationRules.Add(rule); - binding.ValidationRules[0].ValidatesOnTargetUpdated = true; - } - string name = type.Name; - if (name == "TextBox") - { - ((TextBox)control).SetBinding(TextBox.TextProperty, binding); - return; - } - if (name == "DatePicker") - { - ((DatePicker)control).SetBinding(DatePicker.SelectedDateProperty, binding); - return; - } - if (name != "CurrencyTextBox") - { - return; - } - ((CurrencyTextBox)control).SetBinding(CurrencyTextBox.NumberProperty, binding); - } - - public static void AddValidationRule(object control, ValidationRule rule = null) - { - // - // Current member / type: System.Void Gestor.Application.Helpers.BindingHelper::AddValidationRule(System.Object,System.Windows.Controls.ValidationRule) - // File path: C:\AggerSeguros\Gestor.Application.exe - // - // Product version: 0.0.0.0 - // Exception in: System.Void AddValidationRule(System.Object,System.Windows.Controls.ValidationRule) - // - // Object reference not set to an instance of an object. - // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.FindLowestCommonAncestor(ICollection`1 typeNodes) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 515 - // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.MergeWithLowestCommonAncestor() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 459 - // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.ProcessSingleConstraints() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 378 - // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.InferTypes() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 331 - // at Telerik.JustDecompiler.Decompiler.ExpressionDecompilerStep.Process(DecompilationContext theContext, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\ExpressionDecompilerStep.cs:line 104 - // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100 - // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72 - // at Telerik.JustDecompiler.Decompiler.Extensions.Decompile(MethodBody body, ILanguage language, DecompilationContext& context, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 61 - // at Telerik.JustDecompiler.Decompiler.WriterContextServices.BaseWriterContextService.DecompileMethod(ILanguage language, MethodDefinition method, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\WriterContextServices\BaseWriterContextService.cs:line 133 - // - // mailto: JustDecompilePublicFeedback@telerik.com - - } - - private static List> AfterTreatment(bool withSelect, bool orderByLabel, List> comboData, List> comboValues, bool orderbyAttr = false) - { - List> list = comboData; - if (!withSelect) - { - list.RemoveAt(0); - } - list.AddRange(comboValues); - if (orderbyAttr) - { - Type type = typeof(T); - list = list.OrderBy, int?>((KeyValuePair s) => { - if (s.Key == string.Empty) - { - return new int?(0); - } - return EnumHelper.GetOrder((T)Enum.Parse(type, s.Key)); - }).ToList>(); - return list; - } - if (!orderByLabel) - { - return list; - } - list = ( - from in list - orderby Math.Sign(ValidationHelper.ToFloat(x.Key)), Math.Abs(ValidationHelper.ToFloat(x.Key)) - select ).ToList>(); - list = ( - from in list - orderby list.IndexOf(s) != 0, s.Value - select ).ToList>(); - return list; - } - - private static List> BeforeTreatment(string defaultValue, string defaultText) - { - defaultText = (defaultText == string.Empty ? "Selecione" : defaultText); - return new List>() - { - new KeyValuePair(defaultValue, defaultText) - }; - } - - public static List> BindingData(bool withSelect = true, bool enumDefault = true, string defaultValue = "", string defaultText = "", bool orderByLabel = false, bool showAll = false, bool orderbyAttr = false) - { - List> keyValuePairs = BindingHelper.BeforeTreatment(defaultValue, defaultText); - Type type = typeof(T); - List> list = Enum.GetNames(type).AsEnumerable().Where((string x) => { - if (showAll) - { - return true; - } - T t = (T)Enum.Parse(type, x); - bool? @default = EnumHelper.GetDefault(t); - bool hidden = EnumHelper.GetHidden(t); - if (@default.HasValue && @default.Value != enumDefault) - { - return false; - } - return !hidden; - }).Select>((string x) => { - T t = (T)Enum.Parse(type, x); - return new KeyValuePair(EnumHelper.Value(t), EnumHelper.GetDescription(t)); - }).ToList>(); - return BindingHelper.AfterTreatment(withSelect, orderByLabel, keyValuePairs, list, orderbyAttr); - } - - public static void DeleteValidationRule(object control) - { - Binding binding; - string name = control.GetType().Name; - if (name == "TextBox") - { - binding = BindingOperations.GetBinding((TextBox)control, TextBox.TextProperty) ?? new Binding() - { - Mode = BindingMode.TwoWay, - UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged - }; - binding.ValidationRules.Clear(); - ((TextBox)control).SetBinding(TextBox.TextProperty, binding); - return; - } - if (name == "DatePicker") - { - binding = BindingOperations.GetBinding((DatePicker)control, DatePicker.SelectedDateProperty) ?? new Binding() - { - Mode = BindingMode.TwoWay, - UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged - }; - binding.ValidationRules.Clear(); - ((DatePicker)control).SetBinding(DatePicker.SelectedDateProperty, binding); - return; - } - if (name != "CurrencyTextBox") - { - return; - } - binding = BindingOperations.GetBinding((CurrencyTextBox)control, CurrencyTextBox.NumberProperty) ?? new Binding() - { - Mode = BindingMode.TwoWay, - UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged - }; - binding.ValidationRules.Clear(); - ((CurrencyTextBox)control).SetBinding(CurrencyTextBox.NumberProperty, binding); - } - - public static string GetPath(object control) - { - Binding binding; - PropertyPath path; - string name = control.GetType().Name; - if (name == "TextBox") - { - binding = BindingOperations.GetBinding((TextBox)control, TextBox.TextProperty); - if (binding == null) - { - return ""; - } - path = binding.Path; - } - else if (name == "DatePicker") - { - binding = BindingOperations.GetBinding((DatePicker)control, DatePicker.SelectedDateProperty); - if (binding == null) - { - return ""; - } - path = binding.Path; - } - else if (name == "CurrencyTextBox") - { - binding = BindingOperations.GetBinding((CurrencyTextBox)control, CurrencyTextBox.NumberProperty); - if (binding == null) - { - return ""; - } - path = binding.Path; - } - else if (name == "ComboBox") - { - binding = BindingOperations.GetBinding((ComboBox)control, Selector.SelectedItemProperty); - if (binding == null) - { - return ""; - } - path = binding.Path; - } - else - { - if (name != "AutoCompleteBox") - { - return ""; - } - binding = BindingOperations.GetBinding((AutoCompleteBox)control, AutoCompleteBox.SelectedItemProperty); - if (binding == null) - { - return ""; - } - path = binding.Path; - } - return path.Path; - } - } -} \ No newline at end of file -- cgit v1.2.3