-
Notifications
You must be signed in to change notification settings - Fork 5
/
PfxPasswordDialog.cs
89 lines (75 loc) · 2.35 KB
/
PfxPasswordDialog.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
namespace X509CertificateTool
{
using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public partial class PfxPasswordDialog : Form
{
private readonly Color m_regularBackgroundColor;
public PfxPasswordDialog()
{
InitializeComponent();
this.m_regularBackgroundColor = this.BackColor;
SetUiControlState();
}
private void SetUiControlState()
{
this.BackColor = AllowEmptyPassword ? Color.Red : m_regularBackgroundColor;
this.SecondPasswordEntryEnabled = !ShowTypedPasswordCharacters;
this.buttonOK.Enabled = PasswordsConsistent;
textBoxPassword1.UseSystemPasswordChar = !ShowTypedPasswordCharacters;
textBoxPassword2.UseSystemPasswordChar = !ShowTypedPasswordCharacters;
}
private void SetUiControlState(object sender, EventArgs e)
{
SetUiControlState();
}
private bool PasswordsConsistent
{
get
{
if (!ShowTypedPasswordCharacters &&
!textBoxPassword1.Text.Equals(textBoxPassword2.Text))
{
return false;
}
if (textBoxPassword1.Text.Length == 0 && !AllowEmptyPassword)
{
return false;
}
return true;
}
}
private void buttonOK_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
private void buttonCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
private bool SecondPasswordEntryEnabled
{
set
{
textBoxPassword2.Enabled = value;
labelSecondPasswordEntryLabel.Enabled = value;
}
}
public bool ShowTypedPasswordCharacters
{
get { return checkBoxShowPassword.Checked; }
}
public bool AllowEmptyPassword
{
get { return checkBoxAllowEmptyPassword.Checked; }
}
public string Password
{
get { return textBoxPassword1.Text; }
}
}
}