private Dictionary <GroupHeader, Dictionary <GroupedCheckBoxTreeItem, List <GroupedCheckBoxTreeItem> > > BuildTree() { Dictionary <string, GroupedCheckBoxTreeItem> hash = this.BuildDictionary(this.results.Output); Dictionary <GroupHeader, Dictionary <GroupedCheckBoxTreeItem, List <GroupedCheckBoxTreeItem> > > dictionary = new Dictionary <GroupHeader, Dictionary <GroupedCheckBoxTreeItem, List <GroupedCheckBoxTreeItem> > >(); foreach (GroupedCheckBoxTreeItem groupedCheckBoxTreeItem in this.results.Output) { if (string.IsNullOrEmpty(groupedCheckBoxTreeItem.Parent)) { GroupHeader headerFor = this.GetHeaderFor(groupedCheckBoxTreeItem); if (!dictionary.ContainsKey(headerFor)) { dictionary[headerFor] = new Dictionary <GroupedCheckBoxTreeItem, List <GroupedCheckBoxTreeItem> >(); } if (!dictionary[headerFor].ContainsKey(groupedCheckBoxTreeItem)) { dictionary[headerFor].Add(groupedCheckBoxTreeItem, new List <GroupedCheckBoxTreeItem>()); } } } foreach (GroupedCheckBoxTreeItem groupedCheckBoxTreeItem2 in this.results.Output) { if (!string.IsNullOrEmpty(groupedCheckBoxTreeItem2.Parent)) { GroupedCheckBoxTreeItem rootFor = this.GetRootFor(groupedCheckBoxTreeItem2, hash); dictionary[this.GetHeaderFor(groupedCheckBoxTreeItem2)][rootFor].Add(groupedCheckBoxTreeItem2); } } return(dictionary); }
private GroupedCheckBoxTreeItem GetRootFor(GroupedCheckBoxTreeItem item, Dictionary <string, GroupedCheckBoxTreeItem> hash) { if (item.Parent == null) { return(item); } return(hash[item.Group]); }
private CheckBox CreateCheckboxControl(GroupedCheckBoxTreeItem item, HtmlGenericControl parent, bool root) { CheckBox checkBox = new CheckBox(); string value = " GroupedCheckBox " + (root ? " GroupedCheckBoxParent" : string.Empty); checkBox.InputAttributes.Add("class", value); checkBox.InputAttributes.Add("value", item.Identity.ToJsonString(null)); checkBox.ID = item.Identity.RawIdentity; parent.Controls.Add(checkBox); return(checkBox); }
private GroupHeader GetHeaderFor(GroupedCheckBoxTreeItem item) { IEnumerable <GroupHeader> source = from x in this.Groups where x.ID == item.Group select x; if (source.Count <GroupHeader>() <= 0) { return(this.DefaultGroup); } return(source.First <GroupHeader>()); }
private void CreateItemControl(GroupedCheckBoxTreeItem item, HtmlGenericControl parent) { Panel panel = new Panel(); Panel panel2 = panel; panel2.CssClass += " GroupedCheckBoxItem"; panel.ID = item.Identity.RawIdentity + "_label"; panel.Attributes.Add("aria-hidden", "false"); parent.Controls.Add(panel); Panel child = GroupedCheckBoxList.CreateSimplePanel("GroupedCheckBoxItemCaption", item.Name); panel.Controls.Add(child); Panel child2 = GroupedCheckBoxList.CreateSimplePanel("GroupedCheckBoxItemDescription", item.Description); panel.Controls.Add(child2); }
private void CreateGroupItemControls(GroupedCheckBoxTreeItem root, IEnumerable <GroupedCheckBoxTreeItem> children, Control parent) { HtmlGenericControl htmlGenericControl = new HtmlGenericControl("ul"); htmlGenericControl.Attributes.Add("role", "group"); parent.Controls.Add(htmlGenericControl); HtmlGenericControl htmlGenericControl2 = new HtmlGenericControl("li"); htmlGenericControl.Controls.Add(htmlGenericControl2); CheckBox checkBox = this.CreateCheckboxControl(root, htmlGenericControl2, true); this.CreateItemControl(root, htmlGenericControl2); this.CreateFooterControl(htmlGenericControl2); if (children.Count <GroupedCheckBoxTreeItem>() > 0) { this.CreateGroupSubList(children, checkBox.ID, htmlGenericControl2); } }