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


           

Первый шаг Мастера. Форма CUWStep1.cs


Значения свойства Name элементов управления этой формы приведены на рис. 3.27:


Рис. 3.27.  Форма CUWStep1

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

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

namespace MailApplication { /// <summary> /// Summary description for CUWStep1. /// </summary> public class CUWStep1 : System.Windows.Forms.Form { private UserIdentity identity; private System.Windows.Forms.Label lblEmail; private System.Windows.Forms.TextBox txbEmail; private System.Windows.Forms.Label lblMailSample; private System.Windows.Forms.Label lblAliasSample; private System.Windows.Forms.TextBox txbAlias; private System.Windows.Forms.Label lblAlias; private System.Windows.Forms.Button btnNext; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null;

public CUWStep1(UserIdentity identity) { InitializeComponent();

this.identity = identity; }

/// <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(CUWStep1)); this.lblEmail = new System.Windows.Forms.Label(); this.txbEmail = new System.Windows.Forms.TextBox(); this.lblMailSample = new System.Windows.Forms.Label(); this.lblAliasSample = new System.Windows.Forms.Label(); this.txbAlias = new System.Windows.Forms.TextBox(); this.lblAlias = new System.Windows.Forms.Label(); this.btnNext = new System.Windows.Forms.Button(); this.SuspendLayout(); // // lblEmail // this.lblEmail.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lblEmail.Location = new System.Drawing.Point(24, 16); this.lblEmail.Name = "lblEmail"; this.lblEmail.Size = new System.Drawing.Size(240, 23); this.lblEmail.TabIndex = 0; this.lblEmail.Text = "Введите адрес электронной почты"; this.lblEmail.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // txbEmail // this.txbEmail.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.txbEmail.Location = new System.Drawing.Point(24, 48); this.txbEmail.Name = "txbEmail"; this.txbEmail.Size = new System.Drawing.Size(240, 20); this.txbEmail.TabIndex = 1; this.txbEmail.Text = ""; // // lblMailSample // this.lblMailSample.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lblMailSample.ForeColor = System.Drawing.SystemColors.AppWorkspace; this.lblMailSample.Location = new System.Drawing.Point(24, 72); this.lblMailSample.Name = "lblMailSample"; this.lblMailSample.Size = new System.Drawing.Size(240, 23); this.lblMailSample.TabIndex = 2; this.lblMailSample.Text = "Например, address@mail.com"; this.lblMailSample.TextAlign = System.Drawing.ContentAlignment.TopRight; // // lblAliasSample // this.lblAliasSample.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lblAliasSample.ForeColor = System.Drawing.SystemColors.AppWorkspace; this.lblAliasSample.Location = new System.Drawing.Point(26, 160); this.lblAliasSample.Name = "lblAliasSample"; this.lblAliasSample.Size = new System.Drawing.Size(240, 23); this.lblAliasSample.TabIndex = 5; this.lblAliasSample.Text = "Например, Иван Васильевич"; this.lblAliasSample.TextAlign = System.Drawing.ContentAlignment.TopRight; // // txbAlias // this.txbAlias.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.txbAlias.Location = new System.Drawing.Point(26, 136); this.txbAlias.Name = "txbAlias"; this.txbAlias.Size = new System.Drawing.Size(240, 20); this.txbAlias.TabIndex = 2; this.txbAlias.Text = ""; // // lblAlias // this.lblAlias.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lblAlias.Location = new System.Drawing.Point(26, 104); this.lblAlias.Name = "lblAlias"; this.lblAlias.Size = new System.Drawing.Size(240, 23); this.lblAlias.TabIndex = 3; this.lblAlias.Text = "Введите ваше имя "; this.lblAlias.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // btnNext // this.btnNext.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnNext.Location = new System.Drawing.Point(192, 192); this.btnNext.Name = "btnNext"; this.btnNext.TabIndex = 3; this.btnNext.Text = "Далее"; this.btnNext.Click += new System.EventHandler(this.btnNext_Click); // // CUWStep1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(292, 238); this.ControlBox = false; this.Controls.Add(this.btnNext); this.Controls.Add(this.lblAliasSample); this.Controls.Add(this.txbAlias); this.Controls.Add(this.txbEmail); this.Controls.Add(this.lblAlias); this.Controls.Add(this.lblMailSample); this.Controls.Add(this.lblEmail); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "CUWStep1"; this.Text = "Шаг 1 из 3"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.ResumeLayout(false);

} #endregion

private void btnNext_Click(object sender, System.EventArgs e) { if(txbEmail.Text == "") { MessageBox.Show("Введите адрес электронной почты."); return; } else { identity.Alias = txbAlias.Text; identity.Mail = txbEmail.Text;

CUWStep2 step2 = new CUWStep2(this.identity); step2.MdiParent = this.MdiParent; this.Close(); step2.Show(); } }

} }

Листинг 3.19.



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