예제 #1
0
 /// <summary>
 /// Constructor with parent, text, and description</summary>
 /// <param name="parent">Parent MenuModel</param>
 /// <param name="text">Menu text</param>
 /// <param name="description">Menu description</param>
 public MenuModel(MenuModel parent, string text, string description)
 {
     m_parent      = parent;
     m_text        = text;
     m_description = description;
 }
예제 #2
0
 private static IEnumerable<MenuModel> GetLineage(MenuModel menuModel)
 {
     while(menuModel != null)
     {
         yield return menuModel;
         menuModel = menuModel.Parent;
     }
 }
예제 #3
0
        private void BuildSubMenus(IMenuItem menuItem)
        {
            var children = base.GetChildren();
            MenuModel menu = this;

            foreach (string segment in menuItem.MenuPath)
            {
                // Try and find an existing submenu
                MenuModel subMenu = (MenuModel)children.FirstOrDefault(x => (x is MenuModel) && (((MenuModel)x).Text == segment));
                if (subMenu == null)
                {
                    // No existing submenu found - add a new one
                    subMenu = new MenuModel(menu, segment, segment);
                    children.Add(subMenu);
                }
                children = subMenu.Children;
                menu = subMenu;
            }

            children.Add(menuItem);
        }
예제 #4
0
 private static void GetCommandsInSubtree(MenuModel menuModel, IList<Tuple<ICommandItem, MenuModel>> commands)
 {
     foreach (object child in menuModel.Children)
     {
         if (child is ICommandItem)
         {
             commands.Add(new Tuple<ICommandItem, MenuModel>((ICommandItem)child, menuModel));
         }
         else if (child is MenuModel)
         {
             GetCommandsInSubtree((MenuModel)child, commands);
         }
     }
 }
예제 #5
0
 public MenuModel(MenuModel parent, string text, string description)
 {
     m_parent = parent;
     m_text = text;
     m_description = description;
 }