Exemplo n.º 1
0
        private void ShowSubMenu(IGuiMenuItem mainmenuItem)
        {
            if (mainmenuItem == null || mainmenuItem.Children.IsNullOrEmpty())
            {
                return;
            }

            if (SubMenu != null)
            {
                CloseSubMenu();
            }

            SubMenu = new SubMenuOverlay("sub", mainmenuItem.Children);

            SubMenu.ZIndex = Math.Max(SubMenu.ZIndex, this.ZIndex + 1);
            SubMenu.SetBounds(GetSubMenuBounds(SubMenu));
            this.AddChild(SubMenu);

            SubMenu.Closing += delegate {
                CloseSubMenu();
                m_LastActiveItemIndex = ActiveItem == null ? -1 : Menu.IndexOf(ActiveItem);
                ActiveItem            = null;
                Invalidate();
            };

            //SubMenu.Focus ();
            //this.Focus();
            this.Select();

            //bool bTest = SubMenu.CanFocus;

            Expanded = true;
            Invalidate();
        }
Exemplo n.º 2
0
        public void ShowContextMenu(PointF location, IGuiMenu menu)
        {
            lock (contextMenuLock) {
                if (ContextMenuOverlay != null)
                {
                    CloseContextMenu();
                }

                ContextMenuOverlay          = new SubMenuOverlay("contextmenu", menu);
                ContextMenuOverlay.Closing += delegate {
                    CloseContextMenu();
                };

                AddChild(ContextMenuOverlay);
                ContextMenuOverlay.SetBounds(GetContextMenuBounds(ContextMenuOverlay, location));
                ContextMenuOverlay.CanFocus = false;
                ContextMenuOverlay.Visible  = true;
                ContextMenuOverlay.Selected = true;
                Invalidate();
            }
        }