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);
            }
        }
Beispiel #2
0
 protected void AppendItems(MenuShell shell, WindowContext context)
 {
     if(this.MenuItems != null)
         foreach(MenuExpression expr in this.MenuItems)
             shell.Append(expr.Build(context));
 }
Beispiel #3
0
        /* Creates the popup menu.*/
        private void CreatePopupMenu()
        {
            /*
            * Shapes submenu.
            */

            Menu shapes_menu = new Menu ();
            MenuShell shell = new MenuShell (shapes_menu.Raw);

            for (int i = 0; i < shapeArray.Length; i++) {
                MenuItem menu_item = new MenuItem (shapeArray[i].name);
                shell.Append (menu_item);
                menu_item.Activated += new EventHandler (OnChangeShape);
                shapeArray[i].menu_item = menu_item;
                menu_item.Show ();
            }

            /*
            * Materials submenu.
            */

            Menu materials_menu = new Menu ();
            shell = new MenuShell (materials_menu.Raw);

            for (int i = 0; i < materialList.Count; i++) {
                MenuItem menu_item = new MenuItem (((MaterialProp)materialList[i]).name);
                shell.Append (menu_item);
                menu_item.Activated += new EventHandler (OnChangeMaterial);
                ((MaterialProp)materialList[i]).menu_item = menu_item;
                menu_item.Show ();
            }

            /*
            * Root popup menu.
            */

            menu = new Menu ();
            shell = new MenuShell (menu.Raw);

            /* Shapes */
            MenuItem item = new MenuItem ("Shapes");
            item.Submenu = shapes_menu;
            shell.Append (item);
            item.Show ();

            /* Materials */
            item = new MenuItem ("Materials");
            item.Submenu = materials_menu;
            shell.Append (item);
            item.Show ();

            /* Quit */
            item = new MenuItem ("Quit");
            shell.Append (item);
            item.Activated += new EventHandler (MainApp.OnQuit);
            item.Show ();
        }