Exemplo n.º 1
0
        /// <summary>
        /// Populates the specified shell with sub-menus.
        /// </summary>
        /// <param name="shell">The shell.</param>
        public void Populate(
            ActionManager manager,
            MenuShell shell)
        {
            // Create a new submenu for ourselves.
            var menu = new Menu();

            var menuItem = new MenuItem(Label);

            menuItem.Submenu        = menu;
            menuItem.RightJustified = RightAligned;

            // If we have a group name, add it to the list.
            if (!String.IsNullOrEmpty(GroupName))
            {
                ActionSet group = manager.GetOrCreateGroup(GroupName);

                group.Add(menuItem);
            }

            // Attach our menu to the shell.
            shell.Append(menuItem);

            // Go through all of our elements and add them to our menu.
            foreach (ILayoutListItem item in this)
            {
                // Go through and populate the menu itself.
                item.Populate(manager, menu);
            }
        }
Exemplo n.º 2
0
        public static void BuildMenu(MenuShell menu, ActionModelNode node)
        {
            if (node.PathSegment != null)
            {
                MenuItem menuItem;
                if (node.Action != null)
                {
                    // this is a leaf node (terminal menu item)
                    menuItem = new ActiveMenuItem((IClickAction)node.Action);
                }
                else
                {
                    // this menu item has a sub menu
                    string menuText = node.PathSegment.LocalizedText.Replace('&', '_');
                    menuItem         = new MenuItem(menuText);
                    menuItem.Submenu = new Menu();
                }

                menu.Append(menuItem);
                menu = (MenuShell)menuItem.Submenu;
            }

            foreach (ActionModelNode child in node.ChildNodes)
            {
                BuildMenu(menu, child);
            }
        }
Exemplo n.º 3
0
        public CheckMenuItem AddCheck(string label, EventHandler toggled)
        {
            CheckMenuItem item = new CheckMenuItem(label);

            item.Toggled += toggled;

            if (stack.Count > 0)
            {
                MenuShell parent = stack.Peek();
                parent.Append(item);
            }

            return(item);
        }
Exemplo n.º 4
0
        public MenuItem Add(string label, EventHandler activated)
        {
            MenuItem item = new MenuItem(label);

            item.Activated += activated;

            if (stack.Count > 0)
            {
                MenuShell parent = stack.Peek();
                parent.Append(item);
            }

            return(item);
        }
Exemplo n.º 5
0
        public Menu StartMenu(string title)
        {
            Menu menu = new Menu();

            if ((stack.Count > 0) && (title != null))
            {
                MenuShell parent = stack.Peek();

                MenuItem item = new MenuItem(title);
                item.Submenu = menu;
                parent.Append(item);
            }

            stack.Push(menu);

            return(menu);
        }
Exemplo n.º 6
0
        public MenuItemWrapper Add(MenuItemWrapper item, bool createRestriction)
        {
            LoadSubItems();
            EnsureMenu();

            items.Add(item);
            if (menu != null)
            {
                menu.Append(item.Item);
            }

            if (!createRestriction)
            {
                return(item);
            }

            RestrictionNode node = BusinessDomain.RestrictionTree.FindNode(parent.Name);

            node.Children.Add(new RestrictionNode(item.Name, item.Translate));
            return(item);
        }
Exemplo n.º 7
0
        public void Separate()
        {
            MenuShell parent = stack.Peek();

            parent.Append(new SeparatorMenuItem());
        }