Создание Windows-приложений на основе Visual C#


           

Форма ввода пароля PasswordPromt.cs


Для получения почты необходимо ввести пароль к своей учетной записи. Значения свойства Name элементов управления этой формы приведены на рис. 3.32.


Рис. 3.32.  Форма PasswordPromt.

Полный листинг формы:

using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms;

namespace MailApplication { /// <summary> /// Summary description for PasswordPromt. /// </summary> public class PasswordPromt : System.Windows.Forms.Form { private System.Windows.Forms.Label lblPassword; private System.Windows.Forms.TextBox txbPassword; private System.Windows.Forms.Button btnSubmit; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null;

public PasswordPromt() { // // Required for Windows Form Designer support // InitializeComponent();

// // TODO: Add any constructor code after InitializeComponent call // }

/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); }

#region Windows Form Designer generated code /// <summary> /// Required method for Designer support — do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(PasswordPromt)); this.lblPassword = new System.Windows.Forms.Label(); this.txbPassword = new System.Windows.Forms.TextBox(); this.btnSubmit = new System.Windows.Forms.Button(); this.SuspendLayout(); // // lblPassword // this.lblPassword.Location = new System.Drawing.Point(16, 8); this.lblPassword.Name = "lblPassword"; this.lblPassword.Size = new System.Drawing.Size(296, 23); this.lblPassword.TabIndex = 0; this.lblPassword.Text = "Введите пароль от почтового ящика"; this.lblPassword.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // txbPassword // this.txbPassword.Location = new System.Drawing.Point(16, 40); this.txbPassword.Name = "txbPassword"; this.txbPassword.PasswordChar = '*'; this.txbPassword.Size = new System.Drawing.Size(296, 20); this.txbPassword.TabIndex = 1; this.txbPassword.Text = ""; // // btnSubmit // this.btnSubmit.Location = new System.Drawing.Point(240, 72); this.btnSubmit.Name = "btnSubmit"; this.btnSubmit.TabIndex = 2; this.btnSubmit.Text = "ОК"; this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click); // // PasswordPromt // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(328, 110); this.Controls.Add(this.btnSubmit); this.Controls.Add(this.txbPassword); this.Controls.Add(this.lblPassword); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "PasswordPromt"; this.Text = "Запрос пароля"; this.ResumeLayout(false); } #endregion

private void btnSubmit_Click(object sender, System.EventArgs e) { if(txbPassword.Text == "") { MessageBox.Show("Пароль не может быть пустым"); } else { this.DialogResult = DialogResult.OK; ((UserIdentity)System.Threading.Thread.CurrentPrincipal.Identity).Password = txbPassword.Text; this.Close(); } } } }

Листинг 3.24.



Содержание  Назад  Вперед