summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Helpers/PasswordBoxAssistant.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.Helpers/PasswordBoxAssistant.cs')
-rw-r--r--Decompiler/Gestor.Application.Helpers/PasswordBoxAssistant.cs92
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);
+ }
+}