diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
| commit | 225aa1499e37faf9d38257caabbadc68d78b427e (patch) | |
| tree | 102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.Helpers/PasswordBoxAssistant.cs | |
| parent | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff) | |
| download | gestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip | |
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.Helpers/PasswordBoxAssistant.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.Helpers/PasswordBoxAssistant.cs | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Helpers/PasswordBoxAssistant.cs b/Decompiler/Gestor.Application.Helpers/PasswordBoxAssistant.cs new file mode 100644 index 0000000..46104bd --- /dev/null +++ b/Decompiler/Gestor.Application.Helpers/PasswordBoxAssistant.cs @@ -0,0 +1,92 @@ +using System.Windows; +using System.Windows.Controls; + +namespace Gestor.Application.Helpers; + +public static class PasswordBoxAssistant +{ + public static readonly DependencyProperty BoundPassword = DependencyProperty.RegisterAttached("BoundPassword", typeof(string), typeof(PasswordBoxAssistant), new PropertyMetadata((object)string.Empty, new PropertyChangedCallback(OnBoundPasswordChanged))); + + public static readonly DependencyProperty BindPassword = DependencyProperty.RegisterAttached("BindPassword", typeof(bool), typeof(PasswordBoxAssistant), new PropertyMetadata((object)false, new PropertyChangedCallback(OnBindPasswordChanged))); + + private static readonly DependencyProperty UpdatingPassword = DependencyProperty.RegisterAttached("UpdatingPassword", typeof(bool), typeof(PasswordBoxAssistant), new PropertyMetadata((object)false)); + + private static void OnBoundPasswordChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + //IL_001b: Unknown result type (might be due to invalid IL or missing references) + //IL_0025: Expected O, but got Unknown + //IL_0049: Unknown result type (might be due to invalid IL or missing references) + //IL_0053: Expected O, but got Unknown + PasswordBox val = (PasswordBox)(object)((d is PasswordBox) ? d : null); + if (d != null && GetBindPassword(d)) + { + val.PasswordChanged -= new RoutedEventHandler(HandlePasswordChanged); + string password = (string)((DependencyPropertyChangedEventArgs)(ref e)).NewValue; + if (!GetUpdatingPassword((DependencyObject)(object)val)) + { + val.Password = password; + } + val.PasswordChanged += new RoutedEventHandler(HandlePasswordChanged); + } + } + + private static void OnBindPasswordChanged(DependencyObject dp, DependencyPropertyChangedEventArgs e) + { + //IL_002e: Unknown result type (might be due to invalid IL or missing references) + //IL_0038: Expected O, but got Unknown + //IL_0043: Unknown result type (might be due to invalid IL or missing references) + //IL_004d: Expected O, but got Unknown + PasswordBox val = (PasswordBox)(object)((dp is PasswordBox) ? dp : null); + if (val != null) + { + bool num = (bool)((DependencyPropertyChangedEventArgs)(ref e)).OldValue; + bool flag = (bool)((DependencyPropertyChangedEventArgs)(ref e)).NewValue; + if (num) + { + val.PasswordChanged -= new RoutedEventHandler(HandlePasswordChanged); + } + if (flag) + { + val.PasswordChanged += new RoutedEventHandler(HandlePasswordChanged); + } + } + } + + private static void HandlePasswordChanged(object sender, RoutedEventArgs e) + { + PasswordBox val = (PasswordBox)((sender is PasswordBox) ? sender : null); + SetUpdatingPassword((DependencyObject)(object)val, value: true); + SetBoundPassword((DependencyObject)(object)val, val.Password); + SetUpdatingPassword((DependencyObject)(object)val, value: false); + } + + public static void SetBindPassword(DependencyObject dp, bool value) + { + dp.SetValue(BindPassword, (object)value); + } + + public static bool GetBindPassword(DependencyObject dp) + { + return (bool)dp.GetValue(BindPassword); + } + + public static string GetBoundPassword(DependencyObject dp) + { + return (string)dp.GetValue(BoundPassword); + } + + public static void SetBoundPassword(DependencyObject dp, string value) + { + dp.SetValue(BoundPassword, (object)value); + } + + private static bool GetUpdatingPassword(DependencyObject dp) + { + return (bool)dp.GetValue(UpdatingPassword); + } + + private static void SetUpdatingPassword(DependencyObject dp, bool value) + { + dp.SetValue(UpdatingPassword, (object)value); + } +} |