// project created on 7/26/2003 at 11:28 AM
using System;
using System.Windows.Forms;
using Crownwood.Magic.Menus;

namespace MyFormProject 
{
        class MainForm : System.Windows.Forms.Form
        {
                private Crownwood.Magic.Menus.MenuControl mclMain;

                public MainForm()
                {
                        InitializeComponent();
                        BuildMainMenu();
                }
        
                // THIS METHOD IS MAINTAINED BY THE FORM DESIGNER
                // DO NOT EDIT IT MANUALLY! YOUR CHANGES ARE LIKELY TO BE LOST
                void InitializeComponent() {
                        this.SuspendLayout();
                        // 
                        // MainForm
                        // 
                        this.ClientSize = new System.Drawing.Size(230, 100);
                        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
                        this.Text = "Magic Menu Example";
                        this.ResumeLayout(false);
                }
                
                
                /// <summary>
                /// Build the Main menu and add it to the main Form
                /// </summary>
                private void BuildMainMenu()
                {
                        //
                        //Create the main menu
                        //
                        mclMain = new MenuControl();
                        
                        //
                        //Create the File menu and add to Main
                        //
                        MenuCommand mcFile = new MenuCommand("&File");
                        mcFile.Description = "File related commands";
                        //
                        //  Create the Open menu item
                        //
                        MenuCommand mcFile_Open = new MenuCommand("&Open",
                                                                  Shortcut.CtrlO,
                                                                  new EventHandler(mcFile_Open_Click)
                                                                  );
                        mcFile_Open.Description = "Open a file.";
                        //
                        //      Create the Save menu item
                        //
                        MenuCommand mcFile_Save = new MenuCommand("&Save");
                        mcFile_Save.Shortcut = Shortcut.CtrlS;
                        mcFile_Save.Click += new EventHandler(mcFile_Save_Click);
                        mcFile_Save.Description = "Save the selected file.";

                        //
                        //      Add Open and Save to the File menu
                        //
                        mcFile.MenuCommands.AddRange(new MenuCommand[]{mcFile_Open,
                                                     mcFile_Save
                                                     });
                        //
                        //      Add File to the Main menu
                        //
                        mclMain.MenuCommands.Add(mcFile);
                        
                        //
                        //      Add the Main menu to the form.
                        //
                        this.Controls.Add(mclMain);
                }

                /// <summary>
                /// Click event handler for the File_Open menu item
                /// </summary>
                /// <param name="sender">The sender of the Event</param>
                /// <param name="e">The arguments for the Event</param>
                private void mcFile_Open_Click(object sender, EventArgs e)
                {
                        MessageBox.Show("File_Open");
                }

                /// <summary>
                /// Click event handler for the File_Save menu item
                /// </summary>
                /// <param name="sender">The sender of the Event</param>
                /// <param name="e">The arguments for the Event</param>
                private void mcFile_Save_Click(object sender, EventArgs e)
                {
                        MessageBox.Show("File_Save");
                }

                [STAThread]
                public static void Main(string[] args)
                {
                        Application.Run(new MainForm());
                }
        }                       
}