/// <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); } } } }
/// <summary> /// Adds a PackageHeader, recently downloaded from the Package Manager, to Search /// </summary> /// <param name="packageHeader">A PackageHeader object</param> public void Add(PackageHeader packageHeader) { var searchEle = new PackageManagerSearchElement(packageHeader); SearchDictionary.Add(searchEle, searchEle.Name); if (packageHeader.keywords != null && packageHeader.keywords.Count > 0) { SearchDictionary.Add(searchEle, packageHeader.keywords); } SearchDictionary.Add(searchEle, searchEle.Description); SearchAndUpdateResultsSync(SearchText); }
public bool Add(CustomNodeInfo nodeInfo) { var nodeEle = new CustomNodeSearchElement(nodeInfo); nodeEle.Executed += this.OnExecuted; if (SearchDictionary.Contains(nodeEle)) { return(this.Refactor(nodeInfo)); } SearchDictionary.Add(nodeEle, nodeEle.Name); SearchDictionary.Add(nodeEle, nodeInfo.Category + "." + nodeEle.Name); TryAddCategoryAndItem(nodeInfo.Category, nodeEle); return(true); }
/// <summary> /// Add a custom node to search. /// </summary> /// <param name="workspace">A dynWorkspace to add</param> /// <param name="name">The name to use</param> public void Add(string name, string category, string description, Guid functionId) { if (name == "Home") { return; } // create the node in search var nodeEle = new NodeSearchElement(name, description, functionId); if (SearchDictionary.Contains(nodeEle)) { return; } SearchDictionary.Add(nodeEle, nodeEle.Name); SearchDictionary.Add(nodeEle, category + "." + nodeEle.Name); TryAddCategoryAndItem(category, nodeEle); NodeCategories[category].NumElements++; }
/// <summary> /// Adds a local DynNode to search /// </summary> /// <param name="dynNode">A Dynamo node object</param> public void Add(Type t) { // get name, category, attributes (this is terribly ugly...) var attribs = t.GetCustomAttributes(typeof(NodeNameAttribute), false); var name = ""; if (attribs.Length > 0) { name = (attribs[0] as NodeNameAttribute).Name; } attribs = t.GetCustomAttributes(typeof(NodeCategoryAttribute), false); var cat = ""; if (attribs.Length > 0) { cat = (attribs[0] as NodeCategoryAttribute).ElementCategory; } attribs = t.GetCustomAttributes(typeof(NodeSearchTagsAttribute), false); var tags = new List <string>(); if (attribs.Length > 0) { tags = (attribs[0] as NodeSearchTagsAttribute).Tags; } attribs = t.GetCustomAttributes(typeof(NodeDescriptionAttribute), false); var description = ""; if (attribs.Length > 0) { description = (attribs[0] as NodeDescriptionAttribute).ElementDescription; } var searchEle = new NodeSearchElement(name, description, tags, t.FullName); searchEle.Executed += this.OnExecuted; attribs = t.GetCustomAttributes(typeof(NodeSearchableAttribute), false); bool searchable = true; if (attribs.Length > 0) { searchable = (attribs[0] as NodeSearchableAttribute).IsSearchable; } searchEle.SetSearchable(searchable); attribs = t.GetCustomAttributes(typeof(NotSearchableInHomeWorkspace), false); if (attribs.Length > 0) { this.NodesHiddenInHomeWorkspace.Add(searchEle); if (this.DynamoModel != null && this.DynamoModel.CurrentWorkspace != null && this.DynamoModel.CurrentWorkspace is HomeWorkspaceModel) { searchEle.SetSearchable(false); } } attribs = t.GetCustomAttributes(typeof(NotSearchableInCustomNodeWorkspace), false); if (attribs.Length > 0) { this.NodesHiddenInCustomNodeWorkspace.Add(searchEle); if (this.DynamoModel != null && this.DynamoModel.CurrentWorkspace != null && this.DynamoModel.CurrentWorkspace is CustomNodeWorkspaceModel) { searchEle.SetSearchable(false); } } if (!string.IsNullOrEmpty(cat)) { SearchDictionary.Add(searchEle, cat + "." + searchEle.Name); } TryAddCategoryAndItem(cat, searchEle); SearchDictionary.Add(searchEle, searchEle.Name); if (tags.Count > 0) { // reduce the weight in search by adding white space tags.ForEach(x => SearchDictionary.Add(searchEle, x + "++++++++")); } SearchDictionary.Add(searchEle, description); }
/// <summary> /// Adds DesignScript function groups /// </summary> /// <param name="func"></param> public void Add(IEnumerable <FunctionGroup> functionGroups) { if (null == functionGroups) { return; } foreach (var functionGroup in functionGroups) { var functions = functionGroup.Functions.ToList(); if (!functions.Any()) { continue; } bool isOverloaded = functions.Count > 1; foreach (var function in functions) { //Don't add the functions that are not visible in library. if (!function.IsVisibleInLibrary) { continue; } // For overloaded functions, only parameters are displayed // for this item. E.g, for Count(), on UI it is: // // -> Abs // +----------------+ // | dValue: double | // +----------------+ // | nValue: int | // +----------------+ var displayString = function.UserFriendlyName; var category = function.Category; // do not add GetType method names to search if (displayString.Contains("GetType")) { continue; } if (isOverloaded) { var args = string.Join(", ", function.Parameters.Select(p => p.ToString())); if (!string.IsNullOrEmpty(args)) { displayString = displayString + "(" + args + ")"; } } var searchElement = new DSFunctionNodeSearchElement(displayString, function); searchElement.SetSearchable(true); searchElement.FullCategoryName = category; searchElement.Executed += this.OnExecuted; // Add this search eleemnt to the search view TryAddCategoryAndItem(category, searchElement); // function.QualifiedName is the search string for this // element SearchDictionary.Add(searchElement, function.QualifiedName); // add all search tags function.GetSearchTags().ToList().ForEach(x => SearchDictionary.Add(searchElement, x)); } } }
/// <summary> /// Adds a local DynNode to search /// </summary> /// <param name="dynNode">A Dynamo node object</param> public void Add(Type t) { // get name, category, attributes (this is terribly ugly...) var attribs = t.GetCustomAttributes(typeof(NodeNameAttribute), false); var name = ""; if (attribs.Length > 0) { name = (attribs[0] as NodeNameAttribute).Name; } attribs = t.GetCustomAttributes(typeof(NodeCategoryAttribute), false); var cat = ""; if (attribs.Length > 0) { cat = (attribs[0] as NodeCategoryAttribute).ElementCategory; } attribs = t.GetCustomAttributes(typeof(NodeSearchTagsAttribute), false); var tags = new List <string>(); if (attribs.Length > 0) { tags = (attribs[0] as NodeSearchTagsAttribute).Tags; } attribs = t.GetCustomAttributes(typeof(NodeDescriptionAttribute), false); var description = ""; if (attribs.Length > 0) { description = (attribs[0] as NodeDescriptionAttribute).ElementDescription; } var searchEle = new NodeSearchElement(name, description, tags); attribs = t.GetCustomAttributes(typeof(NodeSearchableAttribute), false); bool searchable = true; if (attribs.Length > 0) { searchable = (attribs[0] as NodeSearchableAttribute).IsSearchable; } searchEle.SetSearchable(searchable); // if it's a revit search element, keep track of it if (cat.Equals(BuiltinNodeCategories.REVIT_API)) { this.RevitApiSearchElements.Add(searchEle); if (!IncludeRevitAPIElements) { return; } } if (!string.IsNullOrEmpty(cat)) { SearchDictionary.Add(searchEle, cat + "." + searchEle.Name); } TryAddCategoryAndItem(cat, searchEle); SearchDictionary.Add(searchEle, searchEle.Name); if (tags.Count > 0) { SearchDictionary.Add(searchEle, tags); } SearchDictionary.Add(searchEle, description); }
/// <summary> /// Adds the Home Workspace to search. /// </summary> private void AddHomeToSearch() { SearchDictionary.Add(new WorkspaceSearchElement("Home", "Navigate to Home Workspace"), "Home"); }