[UI.Client]
修正PanelLocker无法自动将焦点设置到秘密输入框的问题。 修正PanelLocker无法重置密码的问题。 PanelLocker解锁后移除Host控件的Blur效果,避免造成UI性能问题。 修正PanelLockerPasswordChanger窗口打开时未将焦点设置到密码输入框的问题。
This commit is contained in:
parent
510a421805
commit
6f013ec600
|
@ -20,6 +20,7 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Effects;
|
||||
using Aitex.Core.Util;
|
||||
|
@ -46,12 +47,12 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
|||
|
||||
// 密码连续重试次数
|
||||
private int _retryTimes;
|
||||
|
||||
|
||||
// 自动锁定计时器
|
||||
private readonly Stopwatch _swAutoLock;
|
||||
|
||||
private PeriodicJob _pjobAutoLock;
|
||||
|
||||
|
||||
private int _timeoutAutoLock = int.MaxValue;
|
||||
|
||||
public PanelLocker()
|
||||
|
@ -61,7 +62,7 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
|||
_timPassAttackDetector = new DeviceTimer();
|
||||
_retryTimes = 0;
|
||||
|
||||
_pjobAutoLock = new PeriodicJob(int.MaxValue, ()=>
|
||||
_pjobAutoLock = new PeriodicJob(int.MaxValue, () =>
|
||||
{
|
||||
Dispatcher.Invoke(Lock);
|
||||
return true;
|
||||
|
@ -72,14 +73,6 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
|||
{
|
||||
txtPass.Focus();
|
||||
};
|
||||
|
||||
IsVisibleChanged += (sender, args) =>
|
||||
{
|
||||
if (args.NewValue is bool isVis && isVis)
|
||||
{
|
||||
txtPass.Focus();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#region Dps
|
||||
|
@ -141,11 +134,26 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
|||
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
|
||||
|
||||
#region Methods
|
||||
|
||||
|
||||
protected override void OnRender(DrawingContext drawingContext)
|
||||
{
|
||||
base.OnRender(drawingContext);
|
||||
txtPass.Focus();
|
||||
}
|
||||
|
||||
public void Lock()
|
||||
{
|
||||
txtPass.Password = "";
|
||||
|
@ -180,9 +188,9 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
|||
if (reqResetPass)
|
||||
{
|
||||
// 密码重置为admin
|
||||
InvokeClient.Instance.Service.DoOperation(OpPathSetNewPassword, DEF_PASSWORD);
|
||||
InvokeClient.Instance.Service.DoOperation(OpPathResetPasswordToDefault, DEF_PASSWORD);
|
||||
}
|
||||
|
||||
|
||||
// 读取系统配置中的Password,如果读取失败,使用默认密码admin
|
||||
var passInSc = QueryDataClient.Instance.Service.GetConfig(ScPathPassword).ToString();
|
||||
if (string.IsNullOrEmpty(passInSc))
|
||||
|
@ -223,7 +231,7 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
|||
{
|
||||
txtInfo.Text = $"You have retried too many times, try again in {deniedSec} seconds";
|
||||
});
|
||||
|
||||
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
|
@ -238,7 +246,7 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
txtInfo.Text = "Incorrect Password";
|
||||
txtPass.Password = "";
|
||||
return false;
|
||||
|
@ -250,8 +258,11 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
|||
|
||||
private void BtnUnlock_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(!CheckPassword())
|
||||
if (!CheckPassword())
|
||||
{
|
||||
txtPass.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (LockTarget.Effect is BlurEffect eff)
|
||||
{
|
||||
|
@ -259,9 +270,10 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
|||
eff.BeginAnimation(BlurEffect.RadiusProperty, aniBlurFadeOut);
|
||||
}
|
||||
|
||||
LockTarget.Effect = null;
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
|
||||
|
||||
|
||||
|
||||
// 启动自动锁定计时器
|
||||
/*var autoLockTimeout = (int)QueryDataClient.Instance.Service.GetConfig("System.RecipeEditorAutoLockTimeout");
|
||||
if (autoLockTimeout <= 0)
|
||||
|
@ -269,7 +281,7 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
|||
_swAutoLock.Interval = autoLockTimeout;
|
||||
_swAutoLock.Start();*/
|
||||
}
|
||||
|
||||
|
||||
private void TxtPass_OnPreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
|
@ -279,6 +291,6 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
|||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -12,10 +12,8 @@
|
|||
// *
|
||||
// * *****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using MECF.Framework.Common.OperationCenter;
|
||||
using MECF.Framework.Common.Utilities;
|
||||
|
||||
|
@ -28,6 +26,12 @@ namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnRender(DrawingContext drawingContext)
|
||||
{
|
||||
base.OnRender(drawingContext);
|
||||
txtOldPass.Focus();
|
||||
}
|
||||
|
||||
private void btnOk_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
#region Validation
|
||||
|
|
Loading…
Reference in New Issue