forked from ispysoftware/iSpy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CheckPassword.cs
74 lines (62 loc) · 2.06 KB
/
CheckPassword.cs
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
using System;
using System.Linq;
using System.Windows.Forms;
using iSpyApplication.Utilities;
namespace iSpyApplication
{
public partial class CheckPassword : Form
{
public CheckPassword()
{
InitializeComponent();
RenderResources();
}
private void DoCheckPassword()
{
var g = MainForm.Conf.Permissions.First(p => p.name == ddlAccount.SelectedItem.ToString());
if (txtPassword.Text == EncDec.DecryptData(g.password, MainForm.Conf.EncryptCode))
{
if (MainForm.Group != g.name)
MainForm.NeedsResourceUpdate = true;
MainForm.Group = g.name;
DialogResult = DialogResult.OK;
Logger.LogMessage("Login: "+g.name);
Close();
return;
}
DialogResult = DialogResult.Cancel;
MessageBox.Show(LocRm.GetString("PasswordIncorrect"), LocRm.GetString("Note"));
Close();
}
private void CheckPasswordLoad(object sender, EventArgs e)
{
txtPassword.Focus();
}
private void RenderResources() {
Text = LocRm.GetString("ApplicationHasBeenLocked");
button1.Text = LocRm.GetString("Unlock");
lblPassword.Text = LocRm.GetString("Password");
lblAccount.Text = LocRm.GetString("Account");
}
private void TxtPasswordKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
DoCheckPassword();
}
}
private void CheckPassword_Shown(object sender, EventArgs e)
{
foreach (var g in MainForm.Conf.Permissions)
{
ddlAccount.Items.Add(g.name);
}
ddlAccount.SelectedItem = MainForm.Group;
this.Activate();
}
private void button1_Click(object sender, EventArgs e)
{
DoCheckPassword();
}
}
}