[UI.Client]

修正PanelLocker无法自动将焦点设置到秘密输入框的问题。
修正PanelLocker无法重置密码的问题。
PanelLocker解锁后移除Host控件的Blur效果,避免造成UI性能问题。
修正PanelLockerPasswordChanger窗口打开时未将焦点设置到密码输入框的问题。
This commit is contained in:
Liang Su 2023-06-13 10:28:46 +08:00
parent 510a421805
commit 6f013ec600
2 changed files with 39 additions and 23 deletions

View File

@ -20,6 +20,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation; using System.Windows.Media.Animation;
using System.Windows.Media.Effects; using System.Windows.Media.Effects;
using Aitex.Core.Util; using Aitex.Core.Util;
@ -61,7 +62,7 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
_timPassAttackDetector = new DeviceTimer(); _timPassAttackDetector = new DeviceTimer();
_retryTimes = 0; _retryTimes = 0;
_pjobAutoLock = new PeriodicJob(int.MaxValue, ()=> _pjobAutoLock = new PeriodicJob(int.MaxValue, () =>
{ {
Dispatcher.Invoke(Lock); Dispatcher.Invoke(Lock);
return true; return true;
@ -72,14 +73,6 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
{ {
txtPass.Focus(); txtPass.Focus();
}; };
IsVisibleChanged += (sender, args) =>
{
if (args.NewValue is bool isVis && isVis)
{
txtPass.Focus();
}
};
} }
#region Dps #region Dps
@ -141,11 +134,26 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
set => SetValue(OpPathSetNewPasswordProperty, value); set => SetValue(OpPathSetNewPasswordProperty, value);
} }
public static readonly DependencyProperty OpPathResetPasswordToDefaultProperty = DependencyProperty.Register(
nameof(OpPathResetPasswordToDefault), typeof(string), typeof(PanelLocker), new PropertyMetadata("System.ResetRecipeEditorPassword"));
public string OpPathResetPasswordToDefault
{
get => (string)GetValue(OpPathResetPasswordToDefaultProperty);
set => SetValue(OpPathResetPasswordToDefaultProperty, value);
}
#endregion #endregion
#region Methods #region Methods
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
txtPass.Focus();
}
public void Lock() public void Lock()
{ {
txtPass.Password = ""; txtPass.Password = "";
@ -180,7 +188,7 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
if (reqResetPass) if (reqResetPass)
{ {
// 密码重置为admin // 密码重置为admin
InvokeClient.Instance.Service.DoOperation(OpPathSetNewPassword, DEF_PASSWORD); InvokeClient.Instance.Service.DoOperation(OpPathResetPasswordToDefault, DEF_PASSWORD);
} }
// 读取系统配置中的Password如果读取失败使用默认密码admin // 读取系统配置中的Password如果读取失败使用默认密码admin
@ -250,8 +258,11 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
private void BtnUnlock_OnClick(object sender, RoutedEventArgs e) private void BtnUnlock_OnClick(object sender, RoutedEventArgs e)
{ {
if(!CheckPassword()) if (!CheckPassword())
{
txtPass.Focus();
return; return;
}
if (LockTarget.Effect is BlurEffect eff) if (LockTarget.Effect is BlurEffect eff)
{ {
@ -259,6 +270,7 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
eff.BeginAnimation(BlurEffect.RadiusProperty, aniBlurFadeOut); eff.BeginAnimation(BlurEffect.RadiusProperty, aniBlurFadeOut);
} }
LockTarget.Effect = null;
this.Visibility = Visibility.Collapsed; this.Visibility = Visibility.Collapsed;

View File

@ -12,10 +12,8 @@
// * // *
// * *****************************************************************************/ // * *****************************************************************************/
using System;
using System.Security.Cryptography;
using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Media;
using MECF.Framework.Common.OperationCenter; using MECF.Framework.Common.OperationCenter;
using MECF.Framework.Common.Utilities; using MECF.Framework.Common.Utilities;
@ -28,6 +26,12 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
InitializeComponent(); InitializeComponent();
} }
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
txtOldPass.Focus();
}
private void btnOk_Click(object sender, RoutedEventArgs e) private void btnOk_Click(object sender, RoutedEventArgs e)
{ {
#region Validation #region Validation