/// <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; }
private static IEnumerable<MenuModel> GetLineage(MenuModel menuModel) { while(menuModel != null) { yield return menuModel; menuModel = menuModel.Parent; } }
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); }
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); } } }
public MenuModel(MenuModel parent, string text, string description) { m_parent = parent; m_text = text; m_description = description; }