initial
This commit is contained in:
102
UserControls/PasswordInputBox.xaml.cs
Normal file
102
UserControls/PasswordInputBox.xaml.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace C4IT_CustomerPanel.UserControls
|
||||
{
|
||||
public partial class PasswordInputBox : UserControl
|
||||
{
|
||||
|
||||
#region Password property
|
||||
public static readonly DependencyProperty PasswordProperty =
|
||||
DependencyProperty.Register(
|
||||
"Password", typeof(string),
|
||||
typeof(PasswordInputBox),
|
||||
new PropertyMetadata("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1", PasswordChangedCallback)
|
||||
);
|
||||
|
||||
public string Password
|
||||
{
|
||||
get { return (string)GetValue(PasswordProperty); }
|
||||
set {
|
||||
SetValue(PasswordProperty, value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public PasswordInputBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public static void PasswordChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is PasswordInputBox _me)
|
||||
{
|
||||
var pw = e.NewValue as string;
|
||||
|
||||
if (_me.txtBoxPassword?.Visibility == Visibility.Visible)
|
||||
{
|
||||
if (_me.txtBoxPassword?.Text != pw)
|
||||
_me.txtBoxPassword?.Text = pw;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_me.pwBoxPassword?.Password != pw)
|
||||
_me.pwBoxPassword?.Password = pw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void iconPasswordShow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (txtBoxPassword.Visibility == Visibility.Visible)
|
||||
{
|
||||
pwBoxPassword.Password = txtBoxPassword.Text;
|
||||
pwBoxPassword.Visibility = Visibility.Visible;
|
||||
iconShow.Visibility = Visibility.Visible;
|
||||
txtBoxPassword.Visibility = Visibility.Collapsed;
|
||||
iconHide.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
txtBoxPassword.Text = pwBoxPassword.Password;
|
||||
txtBoxPassword.Visibility = Visibility.Visible;
|
||||
iconHide.Visibility = Visibility.Visible;
|
||||
pwBoxPassword.Visibility = Visibility.Collapsed;
|
||||
iconShow.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
private void txtBoxPassword_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (sender is TextBox)
|
||||
{
|
||||
pwBoxPassword.Password = txtBoxPassword.Text;
|
||||
Password = txtBoxPassword.Text;
|
||||
}
|
||||
}
|
||||
|
||||
private void pwBoxPassword_PasswordChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is PasswordBox)
|
||||
{
|
||||
Password = pwBoxPassword.Password;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user