/// <summary> /// Recursively builds the toc tree and fills the treeview /// </summary> /// <param name="tocItems">list of toc-items</param> /// <param name="col">treenode collection of the current level</param> /// <param name="filter">information type/category filter</param> private void BuildTOC(ArrayList tocItems, TreeNodeCollection col, InfoTypeCategoryFilter filter) { foreach (TOCItem curItem in tocItems) { bool bAdd = true; if (filter != null) { bAdd = false; if (curItem.InfoTypeStrings.Count <= 0) { bAdd = true; } else { for (int i = 0; i < curItem.InfoTypeStrings.Count; i++) { bAdd |= filter.Match(curItem.InfoTypeStrings[i].ToString()); } } } if (bAdd) { TreeNode newNode = new TreeNode(curItem.Name, curItem.ImageIndex, curItem.ImageIndex); newNode.Tag = curItem; if (curItem.Children.Count > 0) { BuildTOC(curItem.Children, newNode.Nodes, filter); } // check if we have a book/folder which doesn't have any children // after applied filter. if ((curItem.Children.Count > 0) && (newNode.Nodes.Count <= 0)) { // check if the item has a local value // if not, this don't display this item in the tree if (curItem.Local.Length > 0) { col.Add(newNode); } } else { col.Add(newNode); } } } }
/// <summary> /// Call this method to build the help-index and fill the internal list box /// </summary> /// <param name="index">Index instance extracted from the chm file(s)</param> /// <param name="typeOfIndex">type of index to display</param> /// <param name="filter">information type/category filter</param> public void BuildIndex(Index index, IndexType typeOfIndex, InfoTypeCategoryFilter filter) { switch (typeOfIndex) { case IndexType.AssiciativeLinks: _arrIndex = index.ALinks; break; case IndexType.KeywordLinks: _arrIndex = index.KLinks; break; } lbIndex.Items.Clear(); foreach (IndexItem curItem in _arrIndex) { bool bAdd = true; if (filter != null) { bAdd = false; if (curItem.InfoTypeStrings.Count <= 0) { bAdd = true; } else { for (int i = 0; i < curItem.InfoTypeStrings.Count; i++) { bAdd |= filter.Match(curItem.InfoTypeStrings[i].ToString()); } } } if (bAdd) { lbIndex.Items.Add(curItem.IndentKeyWord); } } }
/// <summary> /// Call this method to build the table of contents (TOC) tree. /// </summary> /// <param name="tocItems">TOC instance (tree) extracted from the chm file</param> /// <param name="filter">information type/category filter</param> public void BuildTOC(TableOfContents tocItems, InfoTypeCategoryFilter filter) { tocTreeView.Nodes.Clear(); BuildTOC(tocItems.TOC, tocTreeView.Nodes, filter); tocTreeView.Update(); }