AddControlMenuItems() public static method

public static AddControlMenuItems ( Menu pParent, AemInstance pInstance ) : void
pParent System.Windows.Forms.Menu
pInstance AemInstance
return void
Example #1
0
        private void InitializeNotifyIcon()
        {
            if (mNotifyIcon == null)
            {
                mNotifyIcon = new NotifyIcon();

                mNotifyIcon.DoubleClick += new EventHandler(mNotifyIcon_DoubleClick);
            }

            ContextMenu contextMenu = new ContextMenu();

            MenuItem nameMenuItem = new MenuItem(this.Name + " (" + AemInstanceTypeUtil.GetLabel(this.AemInstanceType) + ")");

            nameMenuItem.Enabled = false;
            contextMenu.MenuItems.Add(nameMenuItem);

            contextMenu.MenuItems.Add(new MenuItem("-"));
            AemActions.AddControlMenuItems(contextMenu.MenuItems, this);

            contextMenu.MenuItems.Add(new MenuItem("-"));
            AemActions.AddLogMenuItems(contextMenu.MenuItems, this);

            contextMenu.MenuItems.Add(new MenuItem("-"));
            AemActions.AddOpenMenuItems(contextMenu.MenuItems, this, true);

            contextMenu.MenuItems.Add(new MenuItem("-"));
            contextMenu.MenuItems.Add(new MenuItem("Properties", propertiesMenuItem_Click));

            this.NotifyIcon.ContextMenu = contextMenu;

            mNotifyIcon.Text    = this.Name;
            mNotifyIcon.Visible = this.ShowInTaskbar;

            string trayIcon = "trayicon_disabled";

            mNotifyIcon.Icon = IconCache.GetIcon(this.IconSet, this.CustomIconPath, trayIcon);
        }
Example #2
0
        private void dgInstances_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                // select instance below mousepointer
                DataGridView.HitTestInfo hitTestInfo = this.dgInstances.HitTest(e.X, e.Y);
                if (hitTestInfo.RowIndex >= 0)
                {
                    dgInstances.CurrentCell.Selected = false;
                    dgInstances.CurrentCell          = dgInstances[0, hitTestInfo.RowIndex];
                }

                AemInstance instance = this.SelectedInstanceInListview;
                if (instance == null)
                {
                    return;
                }

                // Context-MenĂ¼ initialisieren
                List <MenuItem> menuItems = new List <MenuItem>();
                MenuItem        item;

                item        = new MenuItem();
                item.Text   = "&Add...";
                item.Click += new EventHandler(addToolStripMenuItem_Click);
                menuItems.Add(item);

                item             = new MenuItem();
                item.Text        = "&Edit...";
                item.DefaultItem = true;
                item.Click      += new EventHandler(editToolStripMenuItem_Click);
                menuItems.Add(item);

                item        = new MenuItem();
                item.Text   = "&Duplicate...";
                item.Click += new EventHandler(copyToolStripMenuItem_Click);
                menuItems.Add(item);

                item        = new MenuItem();
                item.Text   = "&Remove";
                item.Click += new EventHandler(removeToolStripMenuItem_Click);
                menuItems.Add(item);

                item      = new MenuItem();
                item.Text = "-";
                menuItems.Add(item);

                item         = new MenuItem();
                item.Text    = "&Show in Taskbar";
                item.Click  += new EventHandler(setShowInTaskbarToolStripMenuItem_Click);
                item.Checked = instance.ShowInTaskbar;
                menuItems.Add(item);

                dgInstances.ContextMenu = new ContextMenu(menuItems.ToArray());

                dgInstances.ContextMenu.MenuItems.Add("-");
                AemActions.AddControlMenuItems(dgInstances.ContextMenu.MenuItems, instance);

                dgInstances.ContextMenu.MenuItems.Add("-");
                AemActions.AddOpenMenuItems(dgInstances.ContextMenu.MenuItems, instance, false);

                dgInstances.ContextMenu.MenuItems.Add("-");
                AemActions.AddLogMenuItems(dgInstances.ContextMenu.MenuItems, instance);

                dgInstances.ContextMenu.Show(dgInstances, e.Location);
            }
        }