using System;
|
using System.Collections.Generic;
|
using System.Configuration;
|
using System.Linq;
|
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.Shapes;
|
using System.Windows.Threading;
|
|
namespace XHandler.View
|
{
|
/// <summary>
|
/// PlsLookWin.xaml 的交互逻辑
|
/// </summary>
|
public partial class PlsLookWin : Window
|
{
|
int errorCount = 0;
|
int count = 5;
|
string password = string.Empty;
|
DispatcherTimer timer;//定时器用于界面锁屏检测
|
|
public PlsLookWin()
|
{
|
InitializeComponent();
|
}
|
|
public PlsLookWin(string title, string username, string pwd)
|
{
|
InitializeComponent();
|
tbxTitle.Text = title + "" + username;
|
password = pwd;
|
}
|
|
private void btnRetry_Click(object sender, RoutedEventArgs e)
|
{
|
string pwd = textblockMsg.Password;
|
if (!string.IsNullOrEmpty(pwd))
|
{
|
if (password == pwd)
|
{
|
this.Close();
|
}
|
else
|
{
|
PwdErrorCount();
|
}
|
}
|
}
|
|
private void PwdErrorCount()
|
{
|
errorCount++;
|
|
if (errorCount < count)
|
{
|
tbError.Text = $"密码错误,请重新输入,当前剩余次数[{count - errorCount}]";
|
}
|
else
|
{
|
tbError.Text = $"账号锁定,15分钟后重试";
|
textblockMsg.Password = "";
|
textblockMsg.IsEnabled = false;
|
btnRetry.IsEnabled = false;
|
|
timer = new DispatcherTimer();
|
timer.Interval = TimeSpan.FromMilliseconds(15000); //TimeSpan.FromMilliseconds(Convert.ToInt32(ConfigurationManager.AppSettings["mouseMoveCheckTime"].ToString()));//15分钟
|
timer.Tick += timer_Tick;
|
timer.Start();
|
}
|
}
|
|
private void timer_Tick(object sender, EventArgs e)
|
{
|
tbError.Text = "";
|
textblockMsg.IsEnabled = true;
|
btnRetry.IsEnabled = true;
|
errorCount = 0;
|
timer.Stop();
|
}
|
}
|
}
|