[go: up one dir, main page]

Menu

[r91]: / frmPassword.cs  Maximize  Restore  History

Download this file

194 lines (175 with data), 5.5 kB

  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
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows.Forms;
namespace RDPManager
{
public partial class frmPassword : Form
{
private List<String> machineList = null;
private string selectedMachine = "";
private string userName = "";
private string password = "";
private string domain = "";
private bool passwordChanged = false;
#region properties
public string SelectedMachine
{
get { return selectedMachine; }
set { selectedMachine = value; }
}
public string UserName
{
get { return userName; }
set { userName = value; }
}
public string Password
{
get { return password; }
set { password = value; }
}
public string Domain
{
get { return domain; }
set { domain = value; }
}
public bool PasswordChanged
{
get { return passwordChanged; }
set { passwordChanged = value; }
}
#endregion
public frmPassword()
{
InitializeComponent();
if (!RdpManager.ShowPasswords)
{
txtPass.UseSystemPasswordChar = true;
}
else
{
cbDisplayPassword.Checked = true;
}
#if DEBUG
this.Text = this.Text + " *";
#endif
}
public frmPassword(List<String> List)
{
InitializeComponent();
machineList = List;
if (!RdpManager.ShowPasswords)
{
txtPass.UseSystemPasswordChar = true;
}
else
{
cbDisplayPassword.Checked = true;
}
}
private void btnOK_Click(object sender, EventArgs e)
{
userName = txtUsername.Text;
password = txtPass.Text;
domain = txtDomain.Text;
selectedMachine = ddlMachines.SelectedItem.ToString();
if (userName == "")
{
MessageBox.Show("Username can not be empty", "Username Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
/*
if (password == "")
{
MessageBox.Show("Password can not be empty", "Password Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (password != "Default123") passwordChanged = true;
*/
DialogResult = DialogResult.OK;
Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
userName = "";
password = "";
domain = "";
DialogResult = DialogResult.Cancel;
Close();
}
private void PasswordForm_Load(object sender, EventArgs e)
{
txtUsername.Text = userName;
txtPass.Text = password;
txtDomain.Text = domain;
if (machineList == null) throw new ArgumentException("machineList is null");
foreach (string machName in machineList)
{
ddlMachines.Items.Add(machName);
ddlMachines.SelectedIndex = 0;
}
}
private void txtPass_MouseClick(object sender, MouseEventArgs e)
{
if (txtPass.Text.Length > 0)
{
txtPass.SelectAll();
}
}
private void txtPass_Enter(object sender, EventArgs e)
{
if (txtPass.Text.Length > 0)
{
txtPass.SelectAll();
}
}
private void txtUsername_MouseClick(object sender, MouseEventArgs e)
{
if (txtUsername.Text.Length > 0)
{
txtUsername.SelectAll();
}
}
private void txtUsername_Enter(object sender, EventArgs e)
{
if (txtUsername.Text.Length > 0)
{
txtUsername.SelectAll();
}
}
private void txtDomain_MouseClick(object sender, MouseEventArgs e)
{
if (txtDomain.Text.Length > 0)
{
txtDomain.SelectAll();
}
}
private void txtDomain_Enter(object sender, EventArgs e)
{
if (txtDomain.Text.Length > 0)
{
txtDomain.SelectAll();
}
}
private void txtPass_TextChanged(object sender, EventArgs e)
{
passwordChanged = true;
}
private void cbDisplayPassword_CheckedChanged(object sender, EventArgs e)
{
if (!cbDisplayPassword.Checked)
{
txtPass.UseSystemPasswordChar = true;
}
else
{
txtPass.UseSystemPasswordChar = false;
}
}
}
}