Exemplo n.º 1
0
        internal LocalizedToolStripMenuItem InitializedMenuItem()
        {
            if (MenuItem == null)
            {
                MenuItem = LocalizedToolStripMenuItem.CreateFrom(ContainerNode);
                UIMenuBuilder.BuildMenu(DropDownItemsActionHandler, MenuItem.DropDownItems);
                MenuItem.Visible          = UpdateMenu();
                MenuItem.DropDownOpening += (_, __) => UpdateMenu();
                MenuItem.Disposed        += (_, __) => MenuItem = null;
            }

            return(MenuItem);
        }
Exemplo n.º 2
0
            protected override void OnOpening(CancelEventArgs e)
            {
                base.OnOpening(e);

                // Dynamically build the context menu here.
                base.Items.Clear();
                if (ownerControl != null && ownerControl.IsHandleCreated)
                {
                    UIMenuBuilder.BuildMenu(ActionHandler, Items);
                }

                // If no items, add the dummy item again, or else no context menu strip will be opened even if the opening event is fired.
                if (Items.Count == 0)
                {
                    Items.Add(dummyItem);
                    e.Cancel = true;
                }
            }