/// <summary> /// /// </summary> /// <param name="cat"></param> /// <param name="nodes"></param> /// <returns></returns> protected TreeNode GetNode(StructCategory cat, TreeNodeCollection nodes) { // Create new node TreeNode node = new TreeNode(cat.name, cat.iconIdx, cat.iconIdx); node.Tag = cat.idnum; for (int i = 0; i < nodes.Count; i++) { if ((int)nodes[i].Tag == cat.idnum) { return(nodes[i]); } } //nodes.Insert(0,node); int j = 0; // find nearest below node for (int i = 0; i < nodes.Count; i++) { if ((int)nodes[i].Tag < (int)cat.idnum) { j++; } } nodes.Insert(j, node); return(node); }
private void categoryTree_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { MultiSelectorController.create(); //will show if created, create and show if not. StructCategory cat = StructCategoryTree.theInstance[(int)categoryTree.SelectedNode.Tag]; OnNodeSelected(cat, 0); }
private void BuildCategories() { IEnumerator ie = StructCategoryTree.theInstance.Categories.GetEnumerator(); while (ie.MoveNext()) { StructCategory cat = (StructCategory)ie.Current; GetNode(cat); } }
private void makeRoot(XmlDocument e) { String fn = Path.Combine(BaseDir, "icons.bmp"); StructCategory.ImageBaseInt(fn); StructCategory cat = new StructCategory(0, "Uncategorized", 0); //! StructCategory cat = new StructCategory(0, "未分類", 0); idTbl.Add(cat.idnum, cat); nameTbl.Add(cat.name, cat); }
/// <summary> /// /// </summary> /// <param name="cat"></param> /// <returns></returns> public TreeNode GetNode(StructCategory cat) { if (cat.HasParent()) { TreeNode p = GetNode(cat.Parent); return(GetNode(cat, p.Nodes)); } else { return(GetNode(cat, categoryTree.Nodes)); } }
/// <summary> /// /// </summary> /// <param name="nd"></param> /// <param name="level"></param> protected void parseTree(XmlNode nd, int level) { XmlNodeList xnl = nd.ChildNodes; foreach (XmlNode cn in xnl) { if (cn.Name.Equals("category")) { StructCategory cat = new StructCategory(cn); idTbl.Add(cat.idnum, cat); nameTbl.Add(cat.name, cat); parseTree(cn, level + 1); } } }
// callback from StructureCategoryWindow internal void OnNodeSelected(StructCategory cat, int option) { typeBox.Items.Clear(); typeBox.Text = ""; typeList.Items.Clear(); typeMap.Clear(); SetCategoryEntries(cat, typeMap); if (typeBox.Items.Count > 0) { typeBox.SelectedIndex = 0; typeList.SelectedIndex = 0; } else { current = dummy; } UpdateContribution(); }
// give <structure> tag, which contains <category> as children. /// <summary> /// /// </summary> /// <param name="node"></param> /// <param name="idContrib"></param> public StructCategories(XmlNode node, string idContrib) { foreach (XmlNode cn in node) { if (cn.Name.Equals("category")) { XmlAttribute a = cn.Attributes["byid"]; StructCategory cat = null; if (a != null) { cat = StructCategoryTree.theInstance[int.Parse(a.Value, NumberStyles.HexNumber)]; } else { a = cn.Attributes["byname"]; if (a != null) { cat = StructCategoryTree.theInstance[a.Value]; } } if (cat == null) { cat = StructCategory.Root; } if (!array.Contains(cat.idnum)) { array.Add(cat.idnum); } a = cn.Attributes["hide"]; if (a == null || !a.Value.Equals("true")) { cat.Entries.Add(idContrib); } } } }
/// <summary> /// /// </summary> /// <param name="cat"></param> /// <param name="worktable"></param> protected void SetCategoryEntries(StructCategory cat, Hashtable worktable) { int n = cat.Entries.Count; for (int i = 0; i < n; i++) { GenericStructureContribution contrib = (GenericStructureContribution)PluginManager.GetContribution((string)cat.Entries[i]); string key = contrib.Name; if (!worktable.ContainsKey(key)) { typeBox.Items.Add(contrib); typeList.Items.Add(contrib); worktable.Add(key, new ArrayList()); } designMap = (ArrayList)worktable[key]; designMap.Add(contrib); } n = cat.Subcategories.Count; for (int i = 0; i < n; i++) { SetCategoryEntries(cat.Subcategories[i], typeMap); } }
/// <summary> /// /// </summary> /// <param name="cat"></param> public StructCategories(StructCategory cat) { this.Add(cat); }
/// <summary> /// /// </summary> /// <param name="cat"></param> /// <returns></returns> public bool Contains(StructCategory cat) { return(array.Contains(cat.idnum)); }
/// <summary> /// /// </summary> /// <param name="cat"></param> /// <returns></returns> public int Add(StructCategory cat) { return(array.Add(cat.idnum)); }
/// <summary> /// /// </summary> /// <param name="cat"></param> /// <returns></returns> public StructCategory getParent(StructCategory cat) { int pid = cat.idnum >> 8; return(this[pid]); }