private static void GetMenuItemsFromRoot(string RootPath, out MenuFilter OutMenu) { IEnumerable <ItemContainer> Items = GetItemsByRoot(RootPath); if (Items == null) { OutMenu = null; return; } MenuFilter RootMenu = new MenuFilter(); MenuFilter ActiveMenuThing = RootMenu; OutMenu = new MenuFilter(); OutMenu.ListItem = new Dictionary <string, string>(); string[] SubString; //Create the List of paths to use. foreach (ItemContainer ActiveItem in Items) { ActiveMenuThing = RootMenu; SubString = ActiveItem.ContainerGUIPath.Split('\\'); for (int s = 0; s < SubString.Count(); s++) { if (!ActiveMenuThing.ListMenu.ContainsKey(SubString[s])) { ActiveMenuThing.ListMenu.Add(SubString[s], new MenuFilter()); } ActiveMenuThing = ActiveMenuThing.ListMenu[SubString[s]]; } ActiveMenuThing.ListItem = ActiveItem.ListItem;//Assign the ListItem to last part of the path list. ActiveMenuThing.MenuCount = 1; } //Count sub MenuFilters UpdatePath(ref RootMenu); CreateListMenuRoot(ref OutMenu, ref RootMenu, false, null); }