summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Componentes/CustomPasswordBox.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.Componentes/CustomPasswordBox.cs')
-rw-r--r--Decompiler/Gestor.Application.Componentes/CustomPasswordBox.cs199
1 files changed, 199 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Componentes/CustomPasswordBox.cs b/Decompiler/Gestor.Application.Componentes/CustomPasswordBox.cs
new file mode 100644
index 0000000..39b5a0b
--- /dev/null
+++ b/Decompiler/Gestor.Application.Componentes/CustomPasswordBox.cs
@@ -0,0 +1,199 @@
+using System;
+using System.CodeDom.Compiler;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Markup;
+
+namespace Gestor.Application.Componentes;
+
+public class CustomPasswordBox : UserControl, IComponentConnector
+{
+ public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.Register("IsReadOnly", typeof(bool), typeof(CustomPasswordBox), new PropertyMetadata((object)false, new PropertyChangedCallback(OnBoundIsReadOnlyChanged)));
+
+ public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(CustomPasswordBox), new PropertyMetadata((object)string.Empty, new PropertyChangedCallback(OnBoundPasswordChanged)));
+
+ public static readonly DependencyProperty PasswordViewProperty = DependencyProperty.Register("PasswordViewProperty", typeof(bool), typeof(CustomPasswordBox), new PropertyMetadata((object)false, new PropertyChangedCallback(OnBoundPasswordViewChanged)));
+
+ private bool _typing;
+
+ internal Grid LayoutRoot;
+
+ internal TextBox TextRead;
+
+ internal TextBox TextMask;
+
+ internal PasswordBox PasswordBox;
+
+ private bool _contentLoaded;
+
+ public bool IsReadOnly
+ {
+ get
+ {
+ return (bool)((DependencyObject)this).GetValue(IsReadOnlyProperty);
+ }
+ set
+ {
+ ((DependencyObject)this).SetValue(IsReadOnlyProperty, (object)value);
+ }
+ }
+
+ public string Text
+ {
+ get
+ {
+ return (string)((DependencyObject)this).GetValue(TextProperty);
+ }
+ set
+ {
+ ((DependencyObject)this).SetValue(TextProperty, (object)value);
+ }
+ }
+
+ public bool PasswordView
+ {
+ get
+ {
+ return (bool)((DependencyObject)this).GetValue(PasswordViewProperty);
+ }
+ set
+ {
+ ((DependencyObject)this).SetValue(PasswordViewProperty, (object)value);
+ }
+ }
+
+ private static void OnBoundIsReadOnlyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ CustomPasswordBox customPasswordBox = d as CustomPasswordBox;
+ if (d != null && customPasswordBox != null)
+ {
+ bool flag = (bool)((DependencyPropertyChangedEventArgs)(ref e)).NewValue;
+ ((UIElement)customPasswordBox.PasswordBox).Visibility = (Visibility)(flag ? 2 : 0);
+ ((UIElement)customPasswordBox.TextRead).Visibility = (Visibility)((!flag) ? 2 : 0);
+ ((UIElement)customPasswordBox.TextMask).Visibility = (Visibility)((!flag) ? 2 : 0);
+ }
+ }
+
+ private static void OnBoundPasswordChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ CustomPasswordBox customPasswordBox = d as CustomPasswordBox;
+ if (d != null && customPasswordBox != null)
+ {
+ string text = ((string)((DependencyPropertyChangedEventArgs)(ref e)).NewValue) ?? "";
+ if (!customPasswordBox._typing)
+ {
+ customPasswordBox.TextMask.Text = "".PadLeft(text.Length, '•');
+ customPasswordBox.PasswordBox.Password = text;
+ }
+ }
+ }
+
+ private static void OnBoundPasswordViewChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ //IL_007c: Unknown result type (might be due to invalid IL or missing references)
+ CustomPasswordBox customPasswordBox = d as CustomPasswordBox;
+ if (d != null && customPasswordBox != null)
+ {
+ bool flag = (bool)((DependencyPropertyChangedEventArgs)(ref e)).NewValue;
+ if (flag)
+ {
+ customPasswordBox.TextRead.Text = customPasswordBox.PasswordBox.Password;
+ }
+ else
+ {
+ customPasswordBox.PasswordBox.Password = customPasswordBox.TextRead.Text;
+ }
+ ((UIElement)customPasswordBox.PasswordBox).Visibility = (Visibility)(flag ? 2 : 0);
+ ((UIElement)customPasswordBox.TextRead).Visibility = (Visibility)((!flag) ? 2 : 0);
+ ((UIElement)customPasswordBox.TextMask).Visibility = ((UIElement)customPasswordBox.PasswordBox).Visibility;
+ }
+ }
+
+ public CustomPasswordBox()
+ {
+ InitializeComponent();
+ ((FrameworkElement)LayoutRoot).DataContext = this;
+ PasswordView = false;
+ }
+
+ private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
+ {
+ _typing = true;
+ Text = PasswordBox.Password;
+ _typing = false;
+ TextMask.Text = "".PadLeft(PasswordBox.Password.Length, '•');
+ }
+
+ private void Eye_Click(object sender, RoutedEventArgs e)
+ {
+ if (!IsReadOnly)
+ {
+ PasswordView = !PasswordView;
+ }
+ }
+
+ private void TextRead_PasswordChanged(object sender, TextChangedEventArgs e)
+ {
+ Text = TextRead.Text;
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ public void InitializeComponent()
+ {
+ if (!_contentLoaded)
+ {
+ _contentLoaded = true;
+ Uri uri = new Uri("/Gestor.Application;component/componentes/custompasswordbox.xaml", UriKind.Relative);
+ Application.LoadComponent((object)this, uri);
+ }
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ void IComponentConnector.Connect(int connectionId, object target)
+ {
+ //IL_0020: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002a: Expected O, but got Unknown
+ //IL_002d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0037: Expected O, but got Unknown
+ //IL_0044: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004e: Expected O, but got Unknown
+ //IL_0051: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005b: Expected O, but got Unknown
+ //IL_005e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0068: Expected O, but got Unknown
+ //IL_0075: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007f: Expected O, but got Unknown
+ //IL_0081: Unknown result type (might be due to invalid IL or missing references)
+ //IL_008d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0097: Expected O, but got Unknown
+ switch (connectionId)
+ {
+ case 1:
+ LayoutRoot = (Grid)target;
+ break;
+ case 2:
+ TextRead = (TextBox)target;
+ ((TextBoxBase)TextRead).TextChanged += new TextChangedEventHandler(TextRead_PasswordChanged);
+ break;
+ case 3:
+ TextMask = (TextBox)target;
+ break;
+ case 4:
+ PasswordBox = (PasswordBox)target;
+ PasswordBox.PasswordChanged += new RoutedEventHandler(PasswordBox_PasswordChanged);
+ break;
+ case 5:
+ ((ButtonBase)(Button)target).Click += new RoutedEventHandler(Eye_Click);
+ break;
+ default:
+ _contentLoaded = true;
+ break;
+ }
+ }
+}