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

namespace MDIApplication
{
	
	public class MDI: System.Windows.Forms.Form
	{
		private MainMenu mainMenu;
		private int Count=0;
		private System.ComponentModel.Container components = null;

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

			this.IsMdiContainer=true;
			this.Text="Mdi Demo";
			mainMenu = new MainMenu();
			MenuItem File = mainMenu.MenuItems.Add("&File");

			File.MenuItems.Add(new MenuItem("&New",new EventHandler(this.FileNew_clicked),Shortcut.CtrlN));

			File.MenuItems.Add(new MenuItem("&Active Child",new EventHandler(this.FindActive_clicked),Shortcut.CtrlA));

			File.MenuItems.Add(new MenuItem("-"));

			File.MenuItems.Add(new MenuItem("&Exit",new EventHandler(this.FileExit_clicked),Shortcut.CtrlX));


			MenuItem Arrange = mainMenu.MenuItems.Add("&Arrange");
			Arrange.MenuItems.Add(new MenuItem("&Cascade",new EventHandler(this.Cascade_clicked),Shortcut.F1));
			Arrange.MenuItems.Add(new MenuItem("&Horizontal",new EventHandler(this.Horizontal_clicked),Shortcut.F2));
			Arrange.MenuItems.Add(new MenuItem("&Vertical",new EventHandler(this.Vertical_clicked),Shortcut.F3));

			this.Menu=mainMenu;
			mainMenu.GetForm().BackColor = Color.Indigo ;
		}

		/// <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()
		{
			this.components = new System.ComponentModel.Container();
			this.Size = new System.Drawing.Size(300,300);
			this.Text = "Form1";
		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new MDI());
		}

		private void FileExit_clicked(object sender, EventArgs e) 
		{
			this.Close();
		}
		private void FindActive_clicked(object sender, EventArgs e) 
		{
			MessageBox.Show(this.ActiveMdiChild.Text,"Mdi FORM"); 
		}
		private void FileNew_clicked(object sender, EventArgs e) 
		{

			Form frmchild=new Form();
			frmchild.MdiParent=this;
			frmchild.Show();
			frmchild.Text="Child Form" + Count.ToString();
			Count++;
		}

		private void pop_Clicked(object sender, EventArgs e) 
		{

			MessageBox.Show("Popupmenu","MENU_CREATION");
		}
		private void Cascade_clicked(object sender, EventArgs e) 
		{

			this.LayoutMdi(MdiLayout.Cascade ); 

		}

		private void Horizontal_clicked(object sender, EventArgs e) 
		{

			this.LayoutMdi(MdiLayout.TileHorizontal); 

		}
		private void Vertical_clicked(object sender, EventArgs e) 
		{

			this.LayoutMdi(MdiLayout.TileVertical); 

		}
	}
}
