3
using System.Collections;
4
using System.ComponentModel;
5
using System.Windows.Forms;
10
/// Summary description for Credentials.
12
public class Credentials : System.Windows.Forms.Form
14
private System.Windows.Forms.Label label1;
15
private System.Windows.Forms.TextBox textBox1;
16
private System.Windows.Forms.Label label2;
17
private System.Windows.Forms.TextBox textBox2;
18
private System.Windows.Forms.Button button1;
19
private System.Windows.Forms.Button Button2;
20
private System.Windows.Forms.Label label3;
21
private System.Windows.Forms.TextBox textBox3;
23
private IStoreBrowser browser;
24
private bool checkAuthentication = false;
25
private bool authenticated = false;
28
/// Required designer variable.
30
private System.ComponentModel.Container components = null;
32
public string UserName
34
get { return this.textBox1.Text; }
35
set { this.textBox1.Text = value; }
38
public string Password
40
get { return this.textBox2.Text; }
41
set { this.textBox2.Text = value; }
44
public Credentials( string hostName, IStoreBrowser browser )
47
// Required for Windows Form Designer support
49
InitializeComponent();
52
// TODO: Add any constructor code after InitializeComponent call
54
this.browser = browser;
55
this.textBox3.Text = hostName;
59
/// Clean up any resources being used.
61
protected override void Dispose( bool disposing )
65
if(components != null)
70
base.Dispose( disposing );
73
#region Windows Form Designer generated code
75
/// Required method for Designer support - do not modify
76
/// the contents of this method with the code editor.
78
private void InitializeComponent()
80
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Credentials));
81
this.label1 = new System.Windows.Forms.Label();
82
this.textBox1 = new System.Windows.Forms.TextBox();
83
this.label2 = new System.Windows.Forms.Label();
84
this.textBox2 = new System.Windows.Forms.TextBox();
85
this.button1 = new System.Windows.Forms.Button();
86
this.Button2 = new System.Windows.Forms.Button();
87
this.label3 = new System.Windows.Forms.Label();
88
this.textBox3 = new System.Windows.Forms.TextBox();
93
this.label1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
94
this.label1.Location = new System.Drawing.Point(24, 48);
95
this.label1.Name = "label1";
96
this.label1.Size = new System.Drawing.Size(64, 16);
97
this.label1.TabIndex = 6;
98
this.label1.Text = "User Name:";
102
this.textBox1.Location = new System.Drawing.Point(88, 48);
103
this.textBox1.Name = "textBox1";
104
this.textBox1.Size = new System.Drawing.Size(256, 20);
105
this.textBox1.TabIndex = 0;
106
this.textBox1.Text = "";
107
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
111
this.label2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
112
this.label2.Location = new System.Drawing.Point(24, 80);
113
this.label2.Name = "label2";
114
this.label2.Size = new System.Drawing.Size(56, 23);
115
this.label2.TabIndex = 7;
116
this.label2.Text = "Password:";
120
this.textBox2.AcceptsReturn = true;
121
this.textBox2.Location = new System.Drawing.Point(88, 80);
122
this.textBox2.Name = "textBox2";
123
this.textBox2.PasswordChar = '*';
124
this.textBox2.Size = new System.Drawing.Size(256, 20);
125
this.textBox2.TabIndex = 1;
126
this.textBox2.Text = "";
130
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
131
this.button1.Enabled = false;
132
this.button1.Location = new System.Drawing.Point(184, 120);
133
this.button1.Name = "button1";
134
this.button1.TabIndex = 2;
135
this.button1.Text = "OK";
136
this.button1.Click += new System.EventHandler(this.button1_Click);
140
this.Button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
141
this.Button2.Location = new System.Drawing.Point(272, 120);
142
this.Button2.Name = "Button2";
143
this.Button2.TabIndex = 3;
144
this.Button2.Text = "Cancel";
145
this.Button2.Click += new System.EventHandler(this.Button2_Click);
149
this.label3.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
150
this.label3.Location = new System.Drawing.Point(24, 16);
151
this.label3.Name = "label3";
152
this.label3.Size = new System.Drawing.Size(56, 16);
153
this.label3.TabIndex = 4;
154
this.label3.Text = "Host:";
158
this.textBox3.Location = new System.Drawing.Point(88, 16);
159
this.textBox3.Name = "textBox3";
160
this.textBox3.ReadOnly = true;
161
this.textBox3.Size = new System.Drawing.Size(256, 20);
162
this.textBox3.TabIndex = 5;
163
this.textBox3.TabStop = false;
164
this.textBox3.Text = "";
168
this.AcceptButton = this.button1;
169
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
170
this.CancelButton = this.Button2;
171
this.ClientSize = new System.Drawing.Size(362, 158);
172
this.Controls.Add(this.textBox3);
173
this.Controls.Add(this.label3);
174
this.Controls.Add(this.Button2);
175
this.Controls.Add(this.button1);
176
this.Controls.Add(this.textBox2);
177
this.Controls.Add(this.label2);
178
this.Controls.Add(this.textBox1);
179
this.Controls.Add(this.label1);
180
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
181
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
182
this.Name = "Credentials";
183
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
184
this.Text = "Enter Credentials";
186
this.Closing += new System.ComponentModel.CancelEventHandler(this.Credentials_Closing);
187
this.ResumeLayout(false);
192
private void Credentials_Closing(object sender, System.ComponentModel.CancelEventArgs e)
194
if ( ( this.checkAuthentication == true ) && ( this.authenticated == false ) )
196
MessageBox.Show( "The user name or password is invalid.", "Error", MessageBoxButtons.OK );
205
private void button1_Click(object sender, System.EventArgs e)
207
this.Cursor = Cursors.WaitCursor;
209
// Verify that the user can be authenticated.
210
this.authenticated = this.browser.ValidateCredentials( this.textBox1.Text, this.textBox2.Text );
211
this.checkAuthentication = true;
213
this.Cursor = Cursors.Default;
216
private void textBox1_TextChanged(object sender, System.EventArgs e)
218
this.button1.Enabled = !this.textBox1.Text.Equals( String.Empty );
221
private void Button2_Click(object sender, System.EventArgs e)
223
this.checkAuthentication = false;