forked from JanisEst/KeePassQuickUnlock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuickUnlockPromptForm.cs
68 lines (51 loc) · 1.35 KB
/
QuickUnlockPromptForm.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
using System;
using System.Windows.Forms;
using KeePass.UI;
using KeePass.App;
namespace KeePassQuickUnlock
{
public partial class QuickUnlockPromptForm : Form
{
private bool m_bInitializing = true;
public string QuickUnlockKey
{
get { return keyTextBox.Text; }
}
public QuickUnlockPromptForm()
{
InitializeComponent();
m_bInitializing = true;
GlobalWindowManager.AddWindow(this);
string strTitle = KeePassQuickUnlockExt.ShortProductName;
string strDesc = "Unlock using QuickUnlock.";
Text = strTitle;
BannerFactory.CreateBannerEx(this, bannerImagePictureBox, Properties.Resources.B48x48_TimeLock, strTitle, strDesc);
hideKeyCheckBox.Checked = true;
keyTextBox.Text = string.Empty;
OnCheckedHideKey(null, null);
m_bInitializing = false;
}
private void OnFormShown(object sender, EventArgs e)
{
UIUtil.SetFocus(keyTextBox, this);
}
private void OnFormClosed(object sender, FormClosedEventArgs e)
{
GlobalWindowManager.RemoveWindow(this);
}
private void OnCheckedHideKey(object sender, EventArgs e)
{
bool hide = hideKeyCheckBox.Checked;
if (!hide && !AppPolicy.Try(AppPolicyId.UnhidePasswords))
{
hideKeyCheckBox.Checked = true;
return;
}
keyTextBox.UseSystemPasswordChar = hide;
if (!m_bInitializing)
{
UIUtil.SetFocus(keyTextBox, this);
}
}
}
}