/// <summary> /// If Revit API elements are shown, hides them. Otherwise, /// shows them. Update search when done with either. /// </summary> public void ToggleIncludingRevitAPIElements() { if (!IncludeRevitAPIElements) { this.RemoveCategory(BuiltinNodeCategories.REVIT_API); foreach (var ele in RevitApiSearchElements) { SearchDictionary.Remove(ele, ele.Name); if (!(ele is CategorySearchElement)) { SearchDictionary.Remove(ele, BuiltinNodeCategories.REVIT_API + "." + ele.Name); } } } else { var revitCat = this.AddCategory(BuiltinNodeCategories.REVIT_API); bool addToCat = !revitCat.Items.Any(); // add elements to search foreach (var ele in RevitApiSearchElements) { if (addToCat) { revitCat.Items.Add(ele); } SearchDictionary.Add(ele, ele.Name); if (!(ele is CategorySearchElement)) { SearchDictionary.Add(ele, BuiltinNodeCategories.REVIT_API + "." + ele.Name); } } } }
internal void RemoveNode(Guid funcId) { // remove from search dictionary SearchDictionary.Remove((x) => x is CustomNodeSearchElement && ((CustomNodeSearchElement)x).Guid == funcId); // remove from browser leaves _searchElements.Where(x => x is CustomNodeSearchElement && ((CustomNodeSearchElement)x).Guid == funcId).ToList().ForEach(x => _searchElements.Remove(x)); }
internal void RemoveNode(string nodeName) { // remove from search dictionary SearchDictionary.Remove((ele) => (ele).Name == nodeName); SearchDictionary.Remove((ele) => (ele).Name.EndsWith("." + nodeName)); // remove from browser leaves _searchElements.Where(x => x.Name == nodeName).ToList().ForEach(x => _searchElements.Remove(x)); }
public void Remove(string nodeName) { // get the node, return if not found var nodes = _browserLeaves.Where(x => x.Name == nodeName); if (!nodes.Any()) { return; } // remove from search dictionary SearchDictionary.Remove((ele) => (ele).Name == nodeName); SearchDictionary.Remove((ele) => (ele).Name.EndsWith("." + nodeName)); // remove from browser leaves _browserLeaves.Where(x => x.Name == nodeName).ToList().ForEach(x => _browserLeaves.Remove(x)); // get the category if it doesn't exist, then remove it foreach (var node in nodes) { var categoryName = ((SearchElementBase)node).FullCategoryName; var parentCategoryName = ((BrowserInternalElement)node).Parent.Name; if (!NodeCategories.ContainsKey(categoryName)) { return; } // first level category var pcategory = NodeCategories[parentCategoryName]; pcategory.NumElements--; if (pcategory.NumElements == 0) { this.RemoveCategory(pcategory.Name); } // immediate category var category = NodeCategories[categoryName]; category.NumElements--; if (category.NumElements == 0) { this.RemoveCategory(category.Name); } } }