コード例 #1
0
ファイル: SearchViewModel.cs プロジェクト: RobertiF/Dynamo
 private void ExecuteElement(CategorySearchElement searchElement)
 {
     this.SearchText = searchElement.Name + ".";
 }
コード例 #2
0
ファイル: SearchViewModel.cs プロジェクト: hippo811028/Dynamo
        /// <summary>
        ///     Adds a local DynNode to search
        /// </summary>
        /// <param name="dynNode">A Dynamo node object</param>
        public void Add(dynNode dynNode)
        {
            var searchEle = new LocalSearchElement(dynNode);

            // add category to search
            var cat = dynNode.Category;
            if (!string.IsNullOrEmpty(cat))
            {
                if (!cat.StartsWith("Revit API"))
                {
                    SearchDictionary.Add(searchEle, cat + "." + searchEle.Name);

                    if (!NodeCategories.ContainsKey(cat))
                    {
                        var nameEle = new CategorySearchElement(cat);
                        NodeCategories.Add(cat, nameEle);
                        SearchDictionary.Add(nameEle, cat);
                    }
                }
                else
                {
                    if (!NodeCategories.ContainsKey(cat))
                    {
                        var nameEle = new CategorySearchElement(cat);
                        NodeCategories.Add(cat, nameEle);
                        RevitApiSearchElements.Add(nameEle);
                    }
                }

            }

            NodeCategories[cat].NumElements++;

            // add node to search
            if ( (searchEle.Name.StartsWith("API_")) )
            {
                RevitApiSearchElements.Add( searchEle );
            }
            else
            {
                SearchDictionary.Add(searchEle, searchEle.Name);
                if (dynNode.NodeUI.Tags.Count > 0)
                {
                    SearchDictionary.Add(searchEle, dynNode.NodeUI.Tags);
                }
                SearchDictionary.Add(searchEle, dynNode.NodeUI.Description);
            }
        }
コード例 #3
0
ファイル: SearchModel.cs プロジェクト: whztt07/Dynamo
        /// <summary>
        ///     Add a category, given a delimited name
        /// </summary>
        /// <param name="categoryName">The comma delimited name </param>
        /// <returns>The newly created item</returns>
        internal BrowserItem AddCategory(string categoryName)
        {
            if (string.IsNullOrEmpty(categoryName))
            {
                return this.TryAddRootCategory("Uncategorized");
            }

            if (ContainsCategory(categoryName))
            {
                return GetCategoryByName(categoryName);
            }

            if (!NodeCategories.ContainsKey(categoryName))
            {
                var cat = new CategorySearchElement(categoryName);
                cat.Executed += this.OnExecuted;

                NodeCategories.Add(categoryName, cat);
            }

            // otherwise split the category name
            var splitCat = SplitCategoryName(categoryName);

            // attempt to add root element
            if (splitCat.Count == 1)
            {
                return this.TryAddRootCategory(categoryName);
            }

            if (splitCat.Count == 0)
            {
                return null;
            }

            // attempt to add root category
            var currentCat = TryAddRootCategory(splitCat[0]);

            for (var i = 1; i < splitCat.Count; i++)
            {
                currentCat = TryAddChildCategory(currentCat, splitCat[i]);
            }

            return currentCat;

        }
コード例 #4
0
ファイル: SearchViewModel.cs プロジェクト: hippo811028/Dynamo
        /// <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
            object[] 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 LocalSearchElement(name, description, tags);

            if (!string.IsNullOrEmpty(cat))
            {
                if (!cat.StartsWith("Revit API"))
                {
                    SearchDictionary.Add(searchEle, cat + "." + searchEle.Name);

                    if (!NodeCategories.ContainsKey(cat))
                    {
                        var nameEle = new CategorySearchElement(cat);
                        NodeCategories.Add(cat, nameEle);
                        SearchDictionary.Add(nameEle, cat);
                    }
                }
                else
                {
                    if (!NodeCategories.ContainsKey(cat))
                    {
                        var nameEle = new CategorySearchElement(cat);
                        NodeCategories.Add(cat, nameEle);
                        RevitApiSearchElements.Add(nameEle);
                    }
                }
            }

            NodeCategories[cat].NumElements++;

            // add node to search
            if ((searchEle.Name.StartsWith("API_")))
            {
                RevitApiSearchElements.Add(searchEle);
            }
            else
            {
                SearchDictionary.Add(searchEle, searchEle.Name);
                if (tags.Count > 0)
                {
                    SearchDictionary.Add(searchEle, tags);
                }
                SearchDictionary.Add(searchEle, description);
            }
        }