/// <summary> /// Creates the solution tab. /// </summary> /// <param name="solution">The solution.</param> /// <param name="consoleOrder">The console order.</param> private static void CreateTab(Solution solution, int consoleOrder) { var tab = new TopMenu(); tab.InSolution = solution; tab.Name = solution.Name; tab.ConsoleOrder = consoleOrder; tab.HideOnDesktop = solution.HideOnDesktop; tab.HideOnTablet = solution.HideOnTablet; tab.HideOnMobile = solution.HideOnMobile; tab.NavigationElementIcon = solution.ApplicationIcon; tab.IsTopMenuVisible = true; tab.Save(); var appTabSection = CreateSection(tab.As <NavContainer>(), solution, solution.Name, true); appTabSection.Save(); }
/// <summary> /// Upgrades the top menu navigation sections. /// </summary> /// <param name="topMenu">The top menu.</param> private static void UpgradeTopMenuNavSections(TopMenu topMenu) { NavSection appTabNavSection = null; var resourcesToMove = new List <Resource>(); bool saveAppTab = false; if (topMenu.FolderContents == null) { return; } // Get all the immediate children of the top menu foreach (Resource resource in topMenu.FolderContents) { bool isAppTab = false; var navSection = resource.As <NavSection>(); if (navSection != null && ((navSection.IsAppTab ?? false) || navSection.Name == topMenu.Name)) { isAppTab = true; } if (!isAppTab) { resourcesToMove.Add(resource); } else { if (appTabNavSection == null) { appTabNavSection = navSection.AsWritable <NavSection>(); } } } if (resourcesToMove.Count > 0) { // Clear the existing top menu items var topMenuWritable = topMenu.AsWritable <TopMenu>(); var folderContents = topMenuWritable.FolderContents; folderContents.RemoveRange(resourcesToMove); topMenuWritable.FolderContents = folderContents; topMenuWritable.Save(); } if (appTabNavSection == null) { // Create a new app tab as a child of the top menu appTabNavSection = CreateSection(topMenu.As <NavContainer>(), topMenu.InSolution, topMenu.Name, true); appTabNavSection.Name = topMenu.Name; saveAppTab = true; } if (resourcesToMove.Count > 0) { var folderContents = appTabNavSection.FolderContents; folderContents.AddRange(resourcesToMove); appTabNavSection.FolderContents = folderContents; saveAppTab = true; } if (saveAppTab) { appTabNavSection.Save(); } }