更新项目配置,新增设备同步模块,优化WebSocket和Swagger配置,增强SCADA系统的免登录接口,支持数据字典项和登录日志的免登录查询与记录。调整Java编译设置,确保更好的开发体验。
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace YY.Admin.Core.FluentValidation
|
||||
{
|
||||
public static class PasswordBoxHelper
|
||||
{
|
||||
public static readonly DependencyProperty PasswordProperty =
|
||||
DependencyProperty.RegisterAttached(
|
||||
"Password",
|
||||
typeof(string),
|
||||
typeof(PasswordBoxHelper),
|
||||
new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnPasswordPropertyChanged));
|
||||
|
||||
public static readonly DependencyProperty AttachProperty =
|
||||
DependencyProperty.RegisterAttached(
|
||||
"Attach",
|
||||
typeof(bool),
|
||||
typeof(PasswordBoxHelper),
|
||||
new System.Windows.PropertyMetadata(false, OnAttachChanged));
|
||||
|
||||
public static void SetAttach(DependencyObject dp, bool value)
|
||||
{
|
||||
dp.SetValue(AttachProperty, value);
|
||||
}
|
||||
|
||||
public static bool GetAttach(DependencyObject dp)
|
||||
{
|
||||
return (bool)dp.GetValue(AttachProperty);
|
||||
}
|
||||
|
||||
public static string GetPassword(DependencyObject dp)
|
||||
{
|
||||
return (string)dp.GetValue(PasswordProperty);
|
||||
}
|
||||
|
||||
public static void SetPassword(DependencyObject dp, string value)
|
||||
{
|
||||
dp.SetValue(PasswordProperty, value);
|
||||
}
|
||||
|
||||
private static void OnAttachChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is PasswordBox passwordBox)
|
||||
{
|
||||
if ((bool)e.OldValue)
|
||||
{
|
||||
passwordBox.PasswordChanged -= PasswordChanged;
|
||||
}
|
||||
|
||||
if ((bool)e.NewValue)
|
||||
{
|
||||
passwordBox.PasswordChanged += PasswordChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnPasswordPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is PasswordBox passwordBox)
|
||||
{
|
||||
// 防止无限循环
|
||||
passwordBox.PasswordChanged -= PasswordChanged;
|
||||
|
||||
if (passwordBox.Password != (e.NewValue ?? ""))
|
||||
{
|
||||
passwordBox.Password = e.NewValue?.ToString() ?? "";
|
||||
}
|
||||
|
||||
passwordBox.PasswordChanged += PasswordChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private static void PasswordChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is PasswordBox passwordBox)
|
||||
{
|
||||
SetPassword(passwordBox, passwordBox.Password);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user