summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Componentes/PassBox.cs
blob: 7c25773565af89ca67d4af154e9f779f22a8e391 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Markup;
using Gestor.Common.Validation;

namespace Gestor.Application.Componentes;

public class PassBox : UserControl, IComponentConnector
{
	public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(string), typeof(PassBox), (PropertyMetadata)new FrameworkPropertyMetadata((object)null, (FrameworkPropertyMetadataOptions)256));

	public static readonly DependencyProperty HintProperty = DependencyProperty.Register("Hint", typeof(string), typeof(PassBox), (PropertyMetadata)new FrameworkPropertyMetadata((object)"SENHA", (FrameworkPropertyMetadataOptions)256));

	public static readonly DependencyProperty PasswordWidthProperty = DependencyProperty.Register("PasswordWidth", typeof(string), typeof(PassBox), new PropertyMetadata((object)null, new PropertyChangedCallback(OnBoundWidthChanged)));

	private bool _hidePasswordView;

	internal Grid LayoutRoot;

	internal Button ShowHidePassword;

	internal PasswordBox TextPassword;

	internal TextBox TextPasswordVisible;

	private bool _contentLoaded;

	public bool Visible { get; set; }

	public string Value
	{
		get
		{
			return (string)((DependencyObject)this).GetValue(ValueProperty);
		}
		set
		{
			((DependencyObject)this).SetValue(ValueProperty, (object)value);
		}
	}

	public string Hint
	{
		get
		{
			return (string)((DependencyObject)this).GetValue(HintProperty);
		}
		set
		{
			((DependencyObject)this).SetValue(HintProperty, (object)value);
		}
	}

	public string PasswordWidth
	{
		get
		{
			return (string)((DependencyObject)this).GetValue(PasswordWidthProperty);
		}
		set
		{
			((DependencyObject)this).SetValue(PasswordWidthProperty, (object)value);
		}
	}

	public bool HidePasswordView
	{
		get
		{
			return _hidePasswordView;
		}
		set
		{
			if (value)
			{
				HidePassword();
			}
		}
	}

	private static void OnBoundWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
	{
		PassBox passBox = d as PassBox;
		if (d != null && passBox != null)
		{
			string text = (string)((DependencyPropertyChangedEventArgs)(ref e)).NewValue;
			if (ValidationHelper.ValidateDouble(text))
			{
				((FrameworkElement)passBox.TextPassword).MinWidth = double.Parse(text);
				((FrameworkElement)passBox.TextPasswordVisible).MinWidth = double.Parse(text);
			}
		}
	}

	public PassBox()
	{
		InitializeComponent();
		((FrameworkElement)LayoutRoot).DataContext = this;
	}

	public void ShowPassword()
	{
		((UIElement)TextPasswordVisible).Visibility = (Visibility)0;
		((UIElement)TextPassword).Visibility = (Visibility)1;
		((UIElement)TextPasswordVisible).Focus();
		Visible = true;
	}

	public void HidePassword()
	{
		((UIElement)TextPasswordVisible).Visibility = (Visibility)1;
		((UIElement)TextPassword).Visibility = (Visibility)0;
		((UIElement)TextPassword).Focus();
		Visible = false;
	}

	private void TextPassword_PasswordChanged(object sender, RoutedEventArgs e)
	{
	}

	private void ShowHidePassword_OnClick(object sender, RoutedEventArgs e)
	{
		if (Visible)
		{
			HidePassword();
		}
		else
		{
			ShowPassword();
		}
	}

	private void ShowHidePassword_OnMouseDown(object sender, MouseButtonEventArgs e)
	{
		ShowPassword();
	}

	private void ShowHidePassword_OnMouseUp(object sender, MouseButtonEventArgs e)
	{
		HidePassword();
	}

	[DebuggerNonUserCode]
	[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
	public void InitializeComponent()
	{
		if (!_contentLoaded)
		{
			_contentLoaded = true;
			Uri uri = new Uri("/Gestor.Application;component/componentes/passbox.xaml", UriKind.Relative);
			Application.LoadComponent((object)this, uri);
		}
	}

	[DebuggerNonUserCode]
	[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
	internal Delegate _CreateDelegate(Type delegateType, string handler)
	{
		return Delegate.CreateDelegate(delegateType, this, handler);
	}

	[DebuggerNonUserCode]
	[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
	[EditorBrowsable(EditorBrowsableState.Never)]
	void IComponentConnector.Connect(int connectionId, object target)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Expected O, but got Unknown
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Expected O, but got Unknown
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Expected O, but got Unknown
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Expected O, but got Unknown
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Expected O, but got Unknown
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Expected O, but got Unknown
		switch (connectionId)
		{
		case 1:
			LayoutRoot = (Grid)target;
			break;
		case 2:
			ShowHidePassword = (Button)target;
			((UIElement)ShowHidePassword).PreviewMouseDown += new MouseButtonEventHandler(ShowHidePassword_OnMouseDown);
			((UIElement)ShowHidePassword).PreviewMouseUp += new MouseButtonEventHandler(ShowHidePassword_OnMouseUp);
			break;
		case 3:
			TextPassword = (PasswordBox)target;
			TextPassword.PasswordChanged += new RoutedEventHandler(TextPassword_PasswordChanged);
			break;
		case 4:
			TextPasswordVisible = (TextBox)target;
			break;
		default:
			_contentLoaded = true;
			break;
		}
	}
}