private static Dictionary <int, HashSet <TreeNode> > GetModuleNodes(int portalId, ModuleController moduleController, List <EditorHostSetting> editorHostSettings) { var portalModules = moduleController.GetModules(portalId).Cast <ModuleInfo>(); Dictionary <int, HashSet <TreeNode> > modulesNodes = new Dictionary <int, HashSet <TreeNode> >(); foreach (var m in portalModules) { var moduleNode = new TreeNode { Value = $"m{m.ModuleID}", Text = m.ModuleTitle, ImageUrl = SettingsUtil.CheckSettingsExistByKey(editorHostSettings, $"DNNCKMI#{m.ModuleID}#INS#") ? "../js/ckeditor/4.5.3/images/ModuleHasSetting.png" : "../js/ckeditor/4.5.3/images/ModuleNoSetting.png" }; if (modulesNodes.ContainsKey(m.TabID)) { var nodes = modulesNodes[m.TabID]; nodes.Add(moduleNode); } else { var nodes = new HashSet <TreeNode>(); nodes.Add(moduleNode); modulesNodes.Add(m.TabID, nodes); } } return(modulesNodes); }
/// <summary> /// Renders the <paramref name="portal" /> node. /// </summary> /// <param name="portal">The <paramref name="portal" />.</param> /// <param name="moduleController">The module controller.</param> /// <param name="editorHostSettings">The editor host settings.</param> /// <param name="parentNode">The parent node.</param> private void RenderPortalNode(PortalInfo portal, ModuleController moduleController, List <EditorHostSetting> editorHostSettings, TreeNode parentNode = null) { var portalKey = $"DNNCKP#{portal.PortalID}#"; var portalSettingsExists = SettingsUtil.CheckSettingsExistByKey(editorHostSettings, portalKey); // Portals var portalNode = new TreeNode { Text = portal.PortalName, Value = $"p{portal.PortalID}", ImageUrl = portalSettingsExists ? "../js/ckeditor/4.5.3/images/PortalHasSetting.png" : "../js/ckeditor/4.5.3/images/PortalNoSetting.png", Expanded = PortalOnly.Checked }; Dictionary <int, HashSet <TreeNode> > modulesNodes = GetModuleNodes(portal.PortalID, moduleController, editorHostSettings); var tabs = TabController.GetPortalTabs(portal.PortalID, -1, false, null, true, false, true, true, false); LoadNodesByTreeViewHelper(editorHostSettings, portalNode, modulesNodes, tabs); if (parentNode == null) { PortalTabsAndModulesTree.Nodes.Add(portalNode); } else { parentNode.ChildNodes.Add(portalNode); } }
private static void LoadNodesByTreeViewHelper( List <EditorHostSetting> editorHostSettings, TreeNode portalNode, Dictionary <int, HashSet <TreeNode> > modulesNodes, List <TabInfo> tabs) { Func <TabInfo, int> getNodeId = x => x.TabID; Func <TabInfo, int> getParentId = x => x.ParentId; Func <TabInfo, string> getNodeText = x => x.TabName; Func <TabInfo, string> getNodeValue = x => $"t{x.TabID}"; Func <int, bool> getParentIdCheck = x => x != -1; Func <TabInfo, string> getNodeImageURL = x => SettingsUtil.CheckSettingsExistByKey(editorHostSettings, $"DNNCKT#{x.TabID}#") ? "../js/ckeditor/4.5.3/images/PageHasSetting.png" : "../js/ckeditor/4.5.3/images/PageNoSetting.png"; TreeViewHelper <int> tvh = new TreeViewHelper <int>(); tvh.LoadNodes(tabs, portalNode.ChildNodes, getNodeId, getParentId, getNodeText, getNodeValue, getNodeImageURL, getParentIdCheck, modulesNodes); }
private void RenderHostNode(IEnumerable <PortalInfo> portals, ModuleController moduleController, List <EditorHostSetting> editorHostSettings) { const string hostKey = "DNNCKH#"; var hostSettingsExist = SettingsUtil.CheckSettingsExistByKey(editorHostSettings, hostKey); var hostNode = new TreeNode() { Text = Localization.GetString("AllPortals.Text", ResXFile, LangCode), Value = "h", ImageUrl = hostSettingsExist ? "../js/ckeditor/4.5.3/images/HostHasSetting.png" : "../js/ckeditor/4.5.3/images/HostNoSetting.png", Expanded = true, }; foreach (var portal in portals) { RenderPortalNode(portal, moduleController, editorHostSettings, hostNode); } PortalTabsAndModulesTree.Nodes.Add(hostNode); }