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


           

Главная форма mainForm.cs


Главная форма программы представляет собой контейнер для других форм и поэтому содержит сравнительно мало элементов управления. Значения свойства Name элементов управления приведены на рис. 3.30.


Рис. 3.30.  Форма mainForm

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

using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Threading; using System.Security.Principal;

namespace MailApplication { /// <summary> /// Summary description for Form1. /// </summary> public class mainForm : System.Windows.Forms.Form { private System.Windows.Forms.MainMenu mainMenu; private System.Windows.Forms.MenuItem itemFile; private System.Windows.Forms.MenuItem itemUsers; private System.Windows.Forms.MenuItem itemNewUser; private System.Windows.Forms.MenuItem itemExit; private System.Windows.Forms.MenuItem itemEvent; private System.Windows.Forms.MenuItem itemGet; private System.Windows.Forms.MenuItem itemSend; private System.Windows.Forms.MenuItem itemSetting; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null;

public mainForm() { // // 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(mainForm)); this.mainMenu = new System.Windows.Forms.MainMenu(); this.itemFile = new System.Windows.Forms.MenuItem(); this.itemNewUser = new System.Windows.Forms.MenuItem(); this.itemUsers = new System.Windows.Forms.MenuItem(); this.itemExit = new System.Windows.Forms.MenuItem(); this.itemEvent = new System.Windows.Forms.MenuItem(); this.itemGet = new System.Windows.Forms.MenuItem(); this.itemSend = new System.Windows.Forms.MenuItem(); this.itemSetting = new System.Windows.Forms.MenuItem(); // // mainMenu // this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.itemFile, this.itemEvent}); // // itemFile // this.itemFile.Index = 0; this.itemFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.itemNewUser, this.itemUsers, this.itemExit}); this.itemFile.Text = "Файл"; // // itemNewUser // this.itemNewUser.Index = 0; this.itemNewUser.Shortcut = System.Windows.Forms.Shortcut.CtrlN; this.itemNewUser.Text = "Новый пользователь"; this.itemNewUser.Click += new System.EventHandler(this.itemNewUser_Click); // // itemUsers // this.itemUsers.Index = 1; this.itemUsers.Shortcut = System.Windows.Forms.Shortcut.CtrlL; this.itemUsers.Text = "Смена пользователя"; this.itemUsers.Click += new System.EventHandler(this.itemUsers_Click); // // itemExit // this.itemExit.Index = 2; this.itemExit.Shortcut = System.Windows.Forms.Shortcut.AltF4; this.itemExit.Text = "Выход"; this.itemExit.Click += new System.EventHandler(this.itemExit_Click); // // itemEvent // this.itemEvent.Enabled = false; this.itemEvent.Index = 1; this.itemEvent.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.itemGet, this.itemSend, this.itemSetting}); this.itemEvent.Text = "Действия"; // // itemGet // this.itemGet.Index = 0; this.itemGet.Shortcut = System.Windows.Forms.Shortcut.CtrlG; this.itemGet.Text = "Получить почту"; this.itemGet.Click += new System.EventHandler(this.itemGet_Click); // // itemSend // this.itemSend.Index = 1; this.itemSend.Shortcut = System.Windows.Forms.Shortcut.CtrlS; this.itemSend.Text = "Отправить письмо"; this.itemSend.Click += new System.EventHandler(this.itemSend_Click); // // itemSetting // this.itemSetting.Index = 2; this.itemSetting.Shortcut = System.Windows.Forms.Shortcut.CtrlO; this.itemSetting.Text = "Настройки"; this.itemSetting.Visible = false; // // mainForm // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(792, 545); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.IsMdiContainer = true; this.Menu = this.mainMenu; this.Name = "mainForm"; this.Text = "Ballet"; this.Closing += new System.ComponentModel.CancelEventHandler(this.mainForm_Closing); this.Load += new System.EventHandler(this.itemUsers_Click);



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