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


           

Required for Windows Form Designer


using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms;
namespace MailApplication { /// <summary> /// Summary description for ViewMessage. /// </summary> public class ViewMessage : System.Windows.Forms.Form { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null;
private System.Windows.Forms.Label lblAttachments; private System.Windows.Forms.Panel pblAttachments; private System.Windows.Forms.Label lblBody; private System.Windows.Forms.Label lblSubject; private System.Windows.Forms.Label lblCopy; private System.Windows.Forms.Label lblMessageBody; private System.Windows.Forms.Label lblFrom; private Mail.Message message;
public ViewMessage(Mail.Message msg) { // // Required for Windows Form Designer support // InitializeComponent();
this.message = msg; }
/// <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(ViewMessage)); this.lblAttachments = new System.Windows.Forms.Label(); this.pblAttachments = new System.Windows.Forms.Panel(); this.lblBody = new System.Windows.Forms.Label(); this.lblSubject = new System.Windows.Forms.Label(); this.lblCopy = new System.Windows.Forms.Label(); this.lblFrom = new System.Windows.Forms.Label(); this.lblMessageBody = new System.Windows.Forms.Label(); this.SuspendLayout(); // // lblAttachments // this.lblAttachments.Location = new System.Drawing.Point(24, 280); this.lblAttachments.Name = "lblAttachments"; this.lblAttachments.Size = new System.Drawing.Size(64, 23); this.lblAttachments.TabIndex = 29; this.lblAttachments.Text = "Вложения:"; this.lblAttachments.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // pblAttachments // this.pblAttachments.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.pblAttachments.AutoScroll = true; this.pblAttachments.Location = new System.Drawing.Point(128, 280); this.pblAttachments.Name = "pblAttachments"; this.pblAttachments.Size = new System.Drawing.Size(544, 178); this.pblAttachments.TabIndex = 28; // // lblBody // this.lblBody.Location = new System.Drawing.Point(24, 96); this.lblBody.Name = "lblBody"; this.lblBody.TabIndex = 26; this.lblBody.Text = "Текст сообщения:"; this.lblBody.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // lblSubject // this.lblSubject.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lblSubject.AutoSize = true; this.lblSubject.Location = new System.Drawing.Point(352, 16); this.lblSubject.Name = "lblSubject"; this.lblSubject.Size = new System.Drawing.Size(35, 16); this.lblSubject.TabIndex = 24; this.lblSubject.Text = "Тема:"; this.lblSubject.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // lblCopy // this.lblCopy.AutoSize = true; this.lblCopy.Location = new System.Drawing.Point(24, 56); this.lblCopy.Name = "lblCopy"; this.lblCopy.Size = new System.Drawing.Size(40, 16); this.lblCopy.TabIndex = 20; this.lblCopy.Text = "Копия:"; this.lblCopy.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // lblFrom // this.lblFrom.AutoSize = true; this.lblFrom.Location = new System.Drawing.Point(24, 24); this.lblFrom.Name = "lblFrom"; this.lblFrom.Size = new System.Drawing.Size(47, 16); this.lblFrom.TabIndex = 18; this.lblFrom.Text = "От кого:"; this.lblFrom.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // lblMessageBody // this.lblMessageBody.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lblMessageBody.Location = new System.Drawing.Point(136, 96); this.lblMessageBody.Name = "lblMessageBody"; this.lblMessageBody.Size = new System.Drawing.Size(536, 176); this.lblMessageBody.TabIndex = 30; // // ViewMessage // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(694, 476); this.Controls.Add(this.lblMessageBody); this.Controls.Add(this.lblAttachments); this.Controls.Add(this.pblAttachments); this.Controls.Add(this.lblBody); this.Controls.Add(this.lblSubject); this.Controls.Add(this.lblCopy); this.Controls.Add(this.lblFrom); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "ViewMessage"; this.Text = "Просмотр сообщения"; this.Load += new System.EventHandler(this.ViewMessage_Load); this.ResumeLayout(false);
} #endregion
private void ViewMessage_Load(object sender, System.EventArgs e) { lblMessageBody.Text = this.message.Text; lblCopy.Text += this.message.CC; lblSubject.Text += this.message.Subject; lblFrom.Text += this.message.FromEmail; }
private void AddAttachmentsToPanel() { pblAttachments.Controls.Clear(); for(int i = message.Attachments.Length -1; i >= 0; i--) { //MailAttachment attach = (MailAttachment)message.Attachments[i]; Mail.AttachDescriptor attach = this.message.Attachments[i]; Label lblNumber = new Label(); Label lblAttachName = new Label(); lblNumber.Text = String.Format("#{0}", i + 1); lblAttachName.Text = attach.Name; lblAttachName.TextAlign = lblNumber.TextAlign = ContentAlignment.MiddleLeft; lblAttachName.Anchor = lblNumber.Anchor = AnchorStyles.Top | AnchorStyles.Left; lblNumber.Location = new Point(15, i*25); lblAttachName.Location = new Point(50, i*25); lblNumber.Size = new Size(20, 20); lblAttachName.Size = new Size(500, 20); //lblNumber.ContextMenu = lblAttachName.ContextMenu = contextMenuDeleteAttach; lblNumber.Tag = lblAttachName.Tag = i; pblAttachments.Controls.Add(lblNumber); pblAttachments.Controls.Add(lblAttachName); } } } }
Листинг 3.27.
Закрыть окно
Содержание  Назад  Вперед