-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathQuickUnlockPromptForm.cs
67 lines (52 loc) · 1.43 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
using System;
using System.Diagnostics;
using System.Windows.Forms;
using KeePass.App;
using KeePass.UI;
using KeePassLib.Security;
namespace KeePassQuickUnlock
{
public partial class QuickUnlockPromptForm : Form
{
private readonly bool initializing;
public byte[] QuickUnlockKey
{
get { return keyTextBox.TextEx.ReadUtf8(); }
}
public QuickUnlockPromptForm(bool isOnSecureDesktop)
{
InitializeComponent();
initializing = true;
GlobalWindowManager.AddWindow(this);
Text = KeePassQuickUnlockExt.ShortProductName;
BannerFactory.CreateBannerEx(this, bannerImagePictureBox, Properties.Resources.B48x48_TimeLock, KeePassQuickUnlockExt.ShortProductName, "Unlock using QuickUnlock.");
SecureTextBoxEx.InitEx(ref keyTextBox);
keyTextBox.Text = string.Empty;
hideKeyCheckBox.Checked = true;
OnCheckedHideKey(null, null);
initializing = 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)
{
var hide = hideKeyCheckBox.Checked;
if (!hide && !AppPolicy.Try(AppPolicyId.UnhidePasswords))
{
hideKeyCheckBox.Checked = true;
return;
}
keyTextBox.EnableProtection(hide);
if (!initializing)
{
UIUtil.SetFocus(keyTextBox, this);
}
}
}
}