~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to tools/FormsStoreBrowser/.svn/text-base/Credentials.cs.svn-base

  • Committer: Jorge O. Castro
  • Date: 2007-12-03 06:56:46 UTC
  • Revision ID: jorge@ubuntu.com-20071203065646-mupcnjcwgm5mnhyt
* Remove a bunch of .svn directories we no longer need.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
using System;
2
 
using System.Drawing;
3
 
using System.Collections;
4
 
using System.ComponentModel;
5
 
using System.Windows.Forms;
6
 
 
7
 
namespace StoreBrowser
8
 
{
9
 
        /// <summary>
10
 
        /// Summary description for Credentials.
11
 
        /// </summary>
12
 
        public class Credentials : System.Windows.Forms.Form
13
 
        {
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;
22
 
 
23
 
                private IStoreBrowser browser;
24
 
                private bool checkAuthentication = false;
25
 
                private bool authenticated = false;
26
 
 
27
 
                /// <summary>
28
 
                /// Required designer variable.
29
 
                /// </summary>
30
 
                private System.ComponentModel.Container components = null;
31
 
 
32
 
                public string UserName
33
 
                {
34
 
                        get { return this.textBox1.Text; }
35
 
                        set { this.textBox1.Text = value; }
36
 
                }
37
 
 
38
 
                public string Password
39
 
                {
40
 
                        get { return this.textBox2.Text; }
41
 
                        set { this.textBox2.Text = value; }
42
 
                }
43
 
 
44
 
                public Credentials( string hostName, IStoreBrowser browser )
45
 
                {
46
 
                        //
47
 
                        // Required for Windows Form Designer support
48
 
                        //
49
 
                        InitializeComponent();
50
 
 
51
 
                        //
52
 
                        // TODO: Add any constructor code after InitializeComponent call
53
 
                        //
54
 
                        this.browser = browser;
55
 
                        this.textBox3.Text = hostName;
56
 
                }
57
 
 
58
 
                /// <summary>
59
 
                /// Clean up any resources being used.
60
 
                /// </summary>
61
 
                protected override void Dispose( bool disposing )
62
 
                {
63
 
                        if( disposing )
64
 
                        {
65
 
                                if(components != null)
66
 
                                {
67
 
                                        components.Dispose();
68
 
                                }
69
 
                        }
70
 
                        base.Dispose( disposing );
71
 
                }
72
 
 
73
 
                #region Windows Form Designer generated code
74
 
                /// <summary>
75
 
                /// Required method for Designer support - do not modify
76
 
                /// the contents of this method with the code editor.
77
 
                /// </summary>
78
 
                private void InitializeComponent()
79
 
                {
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();
89
 
                        this.SuspendLayout();
90
 
                        // 
91
 
                        // label1
92
 
                        // 
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:";
99
 
                        // 
100
 
                        // textBox1
101
 
                        // 
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);
108
 
                        // 
109
 
                        // label2
110
 
                        // 
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:";
117
 
                        // 
118
 
                        // textBox2
119
 
                        // 
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 = "";
127
 
                        // 
128
 
                        // button1
129
 
                        // 
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);
137
 
                        // 
138
 
                        // Button2
139
 
                        // 
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);
146
 
                        // 
147
 
                        // label3
148
 
                        // 
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:";
155
 
                        // 
156
 
                        // textBox3
157
 
                        // 
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 = "";
165
 
                        // 
166
 
                        // Credentials
167
 
                        // 
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";
185
 
                        this.TopMost = true;
186
 
                        this.Closing += new System.ComponentModel.CancelEventHandler(this.Credentials_Closing);
187
 
                        this.ResumeLayout(false);
188
 
 
189
 
                }
190
 
                #endregion
191
 
 
192
 
                private void Credentials_Closing(object sender, System.ComponentModel.CancelEventArgs e)
193
 
                {
194
 
                        if ( ( this.checkAuthentication == true ) && ( this.authenticated == false ) )
195
 
                        {
196
 
                                MessageBox.Show( "The user name or password is invalid.", "Error", MessageBoxButtons.OK );
197
 
                                e.Cancel = true;
198
 
                        }
199
 
                        else
200
 
                        {
201
 
                                e.Cancel = false;
202
 
                        }
203
 
                }
204
 
 
205
 
                private void button1_Click(object sender, System.EventArgs e)
206
 
                {
207
 
                        this.Cursor = Cursors.WaitCursor;
208
 
 
209
 
                        // Verify that the user can be authenticated.
210
 
                        this.authenticated = this.browser.ValidateCredentials( this.textBox1.Text, this.textBox2.Text );
211
 
                        this.checkAuthentication = true;
212
 
 
213
 
                        this.Cursor = Cursors.Default;
214
 
                }
215
 
 
216
 
                private void textBox1_TextChanged(object sender, System.EventArgs e)
217
 
                {
218
 
                        this.button1.Enabled = !this.textBox1.Text.Equals( String.Empty );
219
 
                }
220
 
 
221
 
                private void Button2_Click(object sender, System.EventArgs e)
222
 
                {
223
 
                        this.checkAuthentication = false;
224
 
                }
225
 
        }
226
 
}