Example #1
0
        public Form1()
        {
            // run config
            Cappy.Config();

            // init form
            InitializeComponent();

            // add app exit handler
            Application.ApplicationExit += new EventHandler(OnApplicationExit);

            // create context menu
            this.components   = new System.ComponentModel.Container(); // specifically declare namespace and class, as Container is also a method declared in Novacode
            this.contextMenu1 = new ContextMenu();
            this.menuItem0    = new MenuItem();
            this.menuItem1    = new MenuItem();
            this.menuItem2    = new MenuItem();
            this.menuItem3    = new MenuItem();
            this.menuItem4    = new MenuItem();
            this.menuItem5    = new MenuItem();
            this.menuItem6    = new MenuItem();

            // Initialize contextMenu1
            this.contextMenu1.MenuItems.AddRange(
                new MenuItem[] { this.menuItem0 });

            this.contextMenu1.MenuItems.AddRange(
                new MenuItem[] { this.menuItem1 });

            this.contextMenu1.MenuItems.AddRange(
                new MenuItem[] { this.menuItem2 });

            this.contextMenu1.MenuItems.AddRange(
                new MenuItem[] { this.menuItem3 });

            this.contextMenu1.MenuItems.AddRange(
                new MenuItem[] { this.menuItem4 });

            this.contextMenu1.MenuItems.AddRange(
                new MenuItem[] { this.menuItem5 });

            this.contextMenu1.MenuItems.AddRange(
                new MenuItem[] { this.menuItem6 });

            // Create the NotifyIcon.
            this.notifyIcon1 = new NotifyIcon(this.components);

            // The Icon property sets the icon that will appear
            // in the systray for this application.
            notifyIcon1.Icon            = offIco;
            notifyIcon1.Visible         = true;
            notifyIcon1.BalloonTipTitle = "CappyDoc";

            // The ContextMenu property sets the menu that will
            // appear when the systray icon is right clicked.
            notifyIcon1.ContextMenu = this.contextMenu1;

            // Initialize menuItem0
            this.menuItem0.Index  = 0;
            this.menuItem0.Text   = "Start Record";
            this.menuItem0.Click += new EventHandler(this.menuItem0_Click);

            // Initialize menuItem1
            this.menuItem1.Index  = 1;
            this.menuItem1.Text   = "Stop Record";
            this.menuItem1.Click += new EventHandler(this.menuItem1_Click);

            // Initialize menuItem2
            this.menuItem2.Index  = 2;
            this.menuItem2.Text   = "Create New Project";
            this.menuItem2.Click += new EventHandler(this.menuItem2_Click);

            // Initialize menuItem3
            this.menuItem3.Index  = 3;
            this.menuItem3.Text   = "Open Project";
            this.menuItem3.Click += new EventHandler(this.menuItem3_Click);

            // Initialize menuItem4
            this.menuItem4.Index  = 4;
            this.menuItem4.Text   = "Build Current Project";
            this.menuItem4.Click += new EventHandler(this.menuItem4_Click);

            // Initialize menuItem5
            this.menuItem5.Index  = 5;
            this.menuItem5.Text   = "Config Menu";
            this.menuItem5.Click += new EventHandler(this.menuItem5_Click);

            // Initialize menuItem6
            this.menuItem6.Index  = 6;
            this.menuItem6.Text   = "Exit";
            this.menuItem6.Click += new EventHandler(this.menuItem6_Click);

            // make sure stuff is greyed out
            menuItem0.Enabled = true;
            menuItem1.Enabled = false;
            menuItem4.Enabled = true;
        }