schangxiang@126.com
2025-11-04 ca398287db3f5ea01f03aac4a85edb13b28100a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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();
        }
    }
}