Exemplo n.º 1
0
        /// <summary>
        ///     The class constructor.
        /// </summary>
        /// <param name="bench"> Reference to dynBench object for logging </param>
        public SearchViewModel()
        {
            SelectedIndex          = 0;
            RevitApiSearchElements = new List <SearchElementBase>();
            NodeCategories         = new Dictionary <string, CategorySearchElement>();
            SearchDictionary       = new SearchDictionary <SearchElementBase>();
            SearchResults          = new ObservableCollection <SearchElementBase>();
            MaxNumSearchResults    = 20;
            Visible                 = false;
            _SearchText             = "";
            IncludeRevitAPIElements = false; // revit api

            //Regions = new ObservableDictionary<string, RegionBase<object>>();
            ////Regions.Add("Include Nodes from Package Manager", DynamoCommands.PackageManagerRegionCommand );
            //var region = new RevitAPIRegion<object>(RevitAPIRegionExecute, RevitAPIRegionCanExecute);
            //region.RaiseCanExecuteChanged();
            //Regions.Add("Include Experimental Revit API Nodes", new RevitAPIRegion<object>(RevitAPIRegionExecute, RevitAPIRegionCanExecute));

            _topResult = this.AddRootCategory("Top Result");
            this.AddRootCategory(BuiltinNodeCategories.CORE);
            this.AddRootCategory(BuiltinNodeCategories.LOGIC);
            this.AddRootCategory(BuiltinNodeCategories.CREATEGEOMETRY);
            this.AddRootCategory(BuiltinNodeCategories.MODIFYGEOMETRY);
            this.AddRootCategory(BuiltinNodeCategories.REVIT);
            this.AddRootCategory(BuiltinNodeCategories.IO);
            this.AddRootCategory(BuiltinNodeCategories.SCRIPTING);
            this.AddRootCategory(BuiltinNodeCategories.ANALYZE);
        }
Exemplo n.º 2
0
        public void Adding10000RandomKeysAndRemovingHalfWorks()
        {
            var randomKeys = Keygenerator.GenerateKeys(49, 20, '0', 'z', 100000);

            var searchDictionary = new SearchDictionary <int>();

            foreach (var randomKey in randomKeys)
            {
                searchDictionary.Add(randomKey, 0);
            }

            var i = 0;

            foreach (var randomKey in randomKeys)
            {
                if (i % 2 == 0)
                {
                    Assert.IsTrue(searchDictionary.Remove(randomKey), $"RemoveKey(\"{randomKey}\"");
                }

                i++;
            }

            i = 0;
            foreach (var randomKey in randomKeys)
            {
                Assert.AreEqual(i % 2 != 0, searchDictionary.ContainsKey(randomKey), $"ContainsKey(\"{randomKey}\"");
                i++;
            }

            Assert.AreEqual(randomKeys.Count / 2, searchDictionary.Count);
        }
Exemplo n.º 3
0
        /// <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);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public 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));
        }
Exemplo n.º 5
0
        public 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));
        }
Exemplo n.º 6
0
        /// <summary>
        ///     Performs a search using the given string as query, but does not update
        ///     the SearchResults object.
        /// </summary>
        /// <returns> Returns a list with a maximum MaxNumSearchResults elements.</returns>
        /// <param name="search"> The search query </param>
        internal List <SearchElementBase> Search(string search)
        {
            if (string.IsNullOrEmpty(search) || search == "Search...")
            {
                return(_browserLeaves);
            }

            return(SearchDictionary.Search(search, MaxNumSearchResults));
        }
Exemplo n.º 7
0
        public void Add()
        {
            var dictionary = new SearchDictionary <string>
            {
                { "Test", "Data" }
            };

            // Test that ArgumentException is thrown.
            dictionary.Add("Test", "Data");
        }
Exemplo n.º 8
0
        /// <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);
        }
 /// <summary>
 ///     The class constructor.
 /// </summary>
 /// <param name="bench"> Reference to dynBench object for logging </param>
 public PackageManagerSearchViewModel(PackageManagerClient client)
 {
     PackageManagerClient  = client;
     SearchResults         = new ObservableCollection <PackageManagerSearchElement>();
     MaxNumSearchResults   = 12;
     SearchDictionary      = new SearchDictionary <PackageManagerSearchElement>();
     ClearCompletedCommand = new DelegateCommand(ClearCompleted, CanClearCompleted);
     PackageManagerClient.Downloads.CollectionChanged += DownloadsOnCollectionChanged;
     this.SearchResults.CollectionChanged             += SearchResultsOnCollectionChanged;
     SearchText = "";
 }
 /// <summary>
 ///     The class constructor.
 /// </summary>
 /// <param name="bench"> Reference to dynBench object for logging </param>
 public PackageManagerSearchViewModel(PackageManagerClient client)
 {
     PackageManagerClient = client;
     SearchResults = new ObservableCollection<PackageManagerSearchElement>();
     MaxNumSearchResults = 12;
     SearchDictionary = new SearchDictionary<PackageManagerSearchElement>();
     ClearCompletedCommand = new DelegateCommand(ClearCompleted, CanClearCompleted);
     PackageManagerClient.Downloads.CollectionChanged += DownloadsOnCollectionChanged;
     this.SearchResults.CollectionChanged += SearchResultsOnCollectionChanged;
     SearchText = "";
 }
Exemplo n.º 11
0
        public void StartsWith()
        {
            var dictionary = new SearchDictionary <string>
            {
                { "testa", "testa" },
                { "testb", "testb" },
                { "test", "test" },
                { "tesk", "tesk" }
            };

            CollectionAssert.AreEqual(new[] { "testa", "testb", "test" }.OrderBy(v => v).ToArray(), dictionary.StartsWith("test").OrderBy(v => v).ToArray());
        }
Exemplo n.º 12
0
        public void ValuesPropertyReturnsAllValues()
        {
            var dictionary = new SearchDictionary <string>
            {
                { "a", "a" },
                { "aa", "aa" },
                { "c", "c" },
                { "b", "b" }
            };

            CollectionAssert.AreEqual(new[] { "a", "aa", "b", "c" }, dictionary.Values.OrderBy(value => value).ToArray());
        }
Exemplo n.º 13
0
        public void KeysPropertyReturnsAllKeys()
        {
            var dictionary = new SearchDictionary <string>
            {
                { "a", "a" },
                { "aa", "aa" },
                { "c", "c" },
                { "b", "b" }
            };

            CollectionAssert.AreEqual(new[] { "a", "aa", "b", "c" }, dictionary.Keys.OrderBy(key => key).ToArray());
        }
Exemplo n.º 14
0
        public void Clear()
        {
            SearchDictionary <string> dictionary = new SearchDictionary <string>();
            const string Key = "Test";

            dictionary.Add(Key, "data");
            dictionary.Clear();
            dictionary.Add(Key, "data");
            dictionary.Clear();

            // Test that the dictionary count is 0.
            Assert.AreEqual(0, dictionary.Count);
        }
 internal PackageManagerSearchViewModel()
 {
     SearchResults                    = new ObservableCollection <PackageManagerSearchElementViewModel>();
     MaxNumSearchResults              = 35;
     SearchDictionary                 = new SearchDictionary <PackageManagerSearchElement>();
     ClearCompletedCommand            = new DelegateCommand(ClearCompleted, CanClearCompleted);
     SortCommand                      = new DelegateCommand(Sort, CanSort);
     SetSortingKeyCommand             = new DelegateCommand <object>(SetSortingKey, CanSetSortingKey);
     SetSortingDirectionCommand       = new DelegateCommand <object>(SetSortingDirection, CanSetSortingDirection);
     SearchResults.CollectionChanged += SearchResultsOnCollectionChanged;
     SearchText       = "";
     SortingKey       = PackageSortingKey.LastUpdate;
     SortingDirection = PackageSortingDirection.Ascending;
 }
Exemplo n.º 16
0
        public void ContainsKey()
        {
            SearchDictionary <string> dictionary = new SearchDictionary <string>();
            const string Key = "Test";

            // Test that the key does exist.
            Assert.IsFalse(dictionary.ContainsKey(Key));

            dictionary.Add(Key, "Data");

            // Test that the key exist.
            Assert.IsTrue(dictionary.ContainsKey(Key));
            Assert.IsFalse(dictionary.ContainsKey(Key.Substring(0, 3)));
            Assert.IsFalse(dictionary.ContainsKey(Key + "t"));
        }
Exemplo n.º 17
0
        public bool Add(CustomNodeInfo nodeInfo)
        {
            var nodeEle = new CustomNodeSearchElement(nodeInfo);

            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);
        }
Exemplo n.º 18
0
        public void OptimizeDoesNotDestroyTheTree()
        {
            var randomKeys = Keygenerator.GenerateKeys(57, 20, '0', 'z', 10000);

            var searchDictionary = new SearchDictionary <int>();

            foreach (var ranomKey in randomKeys)
            {
                searchDictionary.Add(ranomKey, 0);
            }

            foreach (var randomKey in randomKeys)
            {
                Assert.IsTrue(searchDictionary.ContainsKey(randomKey), $"ContainsKey(\"{randomKey}\"");
            }
        }
Exemplo n.º 19
0
 /// <summary>
 ///     The class constructor.
 /// </summary>
 /// <param name="bench"> Reference to dynBench object for logging </param>
 public PackageManagerSearchViewModel(PackageManagerClient client)
 {
     PackageManagerClient       = client;
     SearchResults              = new ObservableCollection <PackageManagerSearchElement>();
     MaxNumSearchResults        = 12;
     SearchDictionary           = new SearchDictionary <PackageManagerSearchElement>();
     ClearCompletedCommand      = new DelegateCommand(ClearCompleted, CanClearCompleted);
     SortCommand                = new DelegateCommand(Sort, CanSort);
     SetSortingKeyCommand       = new DelegateCommand <object>(SetSortingKey, CanSetSortingKey);
     SetSortingDirectionCommand = new DelegateCommand <object>(SetSortingDirection, CanSetSortingDirection);
     PackageManagerClient.Downloads.CollectionChanged += DownloadsOnCollectionChanged;
     SearchResults.CollectionChanged += SearchResultsOnCollectionChanged;
     SearchText       = "";
     SortingKey       = PackageSortingKey.LAST_UPDATE;
     SortingDirection = PackageSortingDirection.ASCENDING;
 }
Exemplo n.º 20
0
        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);
                }
            }
        }
Exemplo n.º 21
0
        public void GetThis()
        {
            SearchDictionary <object> dictionary = new SearchDictionary <object>();
            const string Key     = "Test";
            object       object1 = new object();
            object       object2 = new object();

            dictionary.Add(Key + 1, object1);
            dictionary.Add(Key + 2, object2);

            // Test that key1 maps to object1 and key2 maps to object2.
            Assert.AreEqual(object1, dictionary[Key + 1]);
            Assert.AreEqual(object2, dictionary[Key + 2]);

            // Test that KeyNotFoundException is thrown.
            var obj = dictionary[Key + 3];
        }
Exemplo n.º 22
0
        public void Adding10000RandomKeysWork()
        {
            var randomKeys = Keygenerator.GenerateKeys(42, 20, '0', 'z', 10000);

            var searchDictionary = new SearchDictionary <int>();

            foreach (var randomKey in randomKeys)
            {
                searchDictionary.Add(randomKey, 0);
            }

            Assert.AreEqual(randomKeys.Count, searchDictionary.Count);
            foreach (var randomKey in randomKeys)
            {
                Assert.IsTrue(searchDictionary.ContainsKey(randomKey));
            }
        }
Exemplo n.º 23
0
        public void GetCount()
        {
            SearchDictionary <string> dictionary = new SearchDictionary <string>();
            const string Key   = "Test";
            const int    Count = 34;

            // Test that the dictionary count is 0.
            Assert.AreEqual(dictionary.Count, 0);

            for (int i = 1; i <= Count; i++)
            {
                dictionary.Add(Key + i, null);

                // Test that the count is i.
                Assert.AreEqual(i, dictionary.Count);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Attempts to obtain the list of search results.  If it fails, it does nothing
        /// </summary>
        public void Refresh()
        {
            var pkgs = PackageManagerClientViewModel.ListAll();

            pkgs.Sort((e1, e2) => e1.Name.ToLower().CompareTo(e2.Name.ToLower()));
            LastSync = pkgs;

            SearchDictionary = new SearchDictionary <PackageManagerSearchElement>();

            foreach (var pkg in pkgs)
            {
                SearchDictionary.Add(pkg, pkg.Name);
                SearchDictionary.Add(pkg, pkg.Description);
                SearchDictionary.Add(pkg, pkg.Maintainers);
                SearchDictionary.Add(pkg, pkg.Keywords);
            }
        }
 internal PackageManagerSearchViewModel()
 {
     SearchResults                         = new ObservableCollection <PackageManagerSearchElementViewModel>();
     MaxNumSearchResults                   = 35;
     SearchDictionary                      = new SearchDictionary <PackageManagerSearchElement>();
     ClearCompletedCommand                 = new DelegateCommand(ClearCompleted, CanClearCompleted);
     SortCommand                           = new DelegateCommand(Sort, CanSort);
     SetSortingKeyCommand                  = new DelegateCommand <object>(SetSortingKey, CanSetSortingKey);
     SetSortingDirectionCommand            = new DelegateCommand <object>(SetSortingDirection, CanSetSortingDirection);
     ViewPackageDetailsCommand             = new DelegateCommand <object>(ViewPackageDetails);
     ClearSearchTextBoxCommand             = new DelegateCommand <object>(ClearSearchTextBox);
     ClearDownloadToastNotificationCommand = new DelegateCommand <object>(ClearDownloadToastNotification);
     SearchText       = string.Empty;
     SortingKey       = PackageSortingKey.LastUpdate;
     SortingDirection = PackageSortingDirection.Descending;
     HostFilter       = new List <FilterEntry>();
     SelectedHosts    = new List <string>();
 }
Exemplo n.º 26
0
        public void TestRemoveItems()
        {
            // Arrange
            var searchDictionary = new SearchDictionary <string>();
            var tag1             = Guid.NewGuid().ToString();

            //It will generate the numbers from 1 to 10, starting from 1
            IEnumerable <string> ranges1 = from value in Enumerable.Range(1, 10)
                                           select value.ToString();

            //It will generate the numbers from 1 to 10, starting from 1
            IEnumerable <string> tags = from value in Enumerable.Range(1, 2)
                                        select tag1;

            //Delegate that uses a lamda expression to delete the tag "9" inside the searchDictionary
            Func <string, bool> selector = str => str.Equals("9");

            //Delegate that uses a lamda expression to delete the tag "8" inside the searchDictionary
            Func <string, bool> selectorValue = str => str.Equals("8");

            //Delegate that uses a lamda expression to delete the tag "8" inside the searchDictionary
            Func <string, bool> selectorTag = str => str.Equals(tag1);

            //Act
            searchDictionary.Add(ranges1, tag1);//Add 10 strings

            //This will execute the method  internal bool Remove(V value, string tag)
            searchDictionary.Remove("10", tag1);//Remove the value "10"

            //This will execute the method int Remove(Func<V, bool> removeCondition)
            searchDictionary.Remove(selector);//Remove the value "9"

            //This will execute the method  internal int Remove(Func<V, bool> valueCondition, Func<string, bool> removeTagCondition)
            searchDictionary.Remove(selectorValue, selectorTag);//Remove the value 8

            //This will execute the method internal int Remove(V value, IEnumerable<string> tags)
            searchDictionary.Remove("7", tags);                      //Remove the value 7
            int valuesRemoved = searchDictionary.Remove("16", tags); //Value won't be found so it will retung 0

            //Assert
            //Check that we have only 7 strings in the dictionary, at the beginning we had 10 but 3 were removed
            Assert.AreEqual(searchDictionary.NumTags, 6);
            Assert.AreEqual(valuesRemoved, 0);//Means that value was't found, the Remove(V value, IEnumerable<string> tags) method returned 0
        }
Exemplo n.º 27
0
        public void AllKeyValuePairsCanBeEnumerated()
        {
            var allItems = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("a", "a"),
                new KeyValuePair <string, string>("aa", "aa"),
                new KeyValuePair <string, string>("c", "c"),
                new KeyValuePair <string, string>("b", "b"),
            };

            var dictionary = new SearchDictionary <string>();

            foreach (var item in allItems)
            {
                dictionary.Add(item);
            }

            CollectionAssert.AreEqual(allItems.OrderBy(item => item.Key).ToArray(), dictionary.OrderBy(item => item.Key).ToArray());
        }
Exemplo n.º 28
0
        public void TestSearchDictionaryPerformance()
        {
            //Arrange
            var searchDictionary = new SearchDictionary <string>();

            var tagsPath = System.IO.Path.Combine(TestDirectory, "performance", "search_tags", "searchtags.log");
            var tags     = System.IO.File.ReadAllLines(tagsPath);
            int value    = 0;

            foreach (var tag in tags)
            {
                searchDictionary.Add($"Value:{value++}", tag);
            }

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            var query1 = "all";

            searchDictionary.Search(query1);
            var query2 = "all elements";

            searchDictionary.Search(query2);
            var query3 = "all elements of";

            searchDictionary.Search(query3);
            var query4 = "all elements of category";

            searchDictionary.Search(query4);
            var query   = "az";
            var results = searchDictionary.Search(query);

            stopwatch.Stop();

            Assert.AreEqual(results.Count(), 20);

            double timeLimit = 300;//ms
            double range     = 70;

            Assert.IsTrue(Math.Abs(stopwatch.ElapsedMilliseconds - timeLimit) < range / 100 * timeLimit, $"Search time should be within a range of +/- {range}% of {timeLimit}ms but we got {stopwatch.ElapsedMilliseconds}ms");
        }
Exemplo n.º 29
0
        public void RemoveRemovesKeysProperly()
        {
            var dictionary = new SearchDictionary <string>
            {
                { "a", "a" },
                { "aa", "aa" },
                { "c", "c" },
                { "b", "b" }
            };

            dictionary.Remove("a");
            dictionary.Remove("b");
            dictionary.Remove("c");

            Assert.AreEqual(1, dictionary.Count);
            Assert.IsFalse(dictionary.ContainsKey("a"));
            Assert.IsFalse(dictionary.ContainsKey("b"));
            Assert.IsFalse(dictionary.ContainsKey("c"));
            Assert.IsTrue(dictionary.ContainsKey("aa"));
        }
Exemplo n.º 30
0
        /// <summary>
        ///     The class constructor.
        /// </summary>
        /// <param name="bench"> Reference to dynBench object for logging </param>
        public SearchViewModel()
        {
            SelectedIndex          = 0;
            RevitApiSearchElements = new List <SearchElementBase>();
            NodeCategories         = new Dictionary <string, CategorySearchElement>();
            SearchDictionary       = new SearchDictionary <SearchElementBase>();
            SearchResults          = new ObservableCollection <SearchElementBase>();
            MaxNumSearchResults    = 35;
            Visible    = false;
            searchText = "";
            IncludeRevitAPIElements = true; // revit api

            _topResult = this.AddRootCategory("Top Result");
            this.AddRootCategory(BuiltinNodeCategories.CORE);
            this.AddRootCategory(BuiltinNodeCategories.LOGIC);
            this.AddRootCategory(BuiltinNodeCategories.GEOMETRY);
            this.AddRootCategory(BuiltinNodeCategories.REVIT);
            this.AddRootCategory(BuiltinNodeCategories.ANALYZE);
            this.AddRootCategory(BuiltinNodeCategories.IO);
        }
Exemplo n.º 31
0
    static void Main(string[] args)
    {
        SearchDictionary dictionary = new SearchDictionary();

        // populate

        dictionary.AddWord("add");
        dictionary.AddWord("adb");
        dictionary.AddWord("adcc");


        // test search
        Console.WriteLine($"{dictionary.SearchWord("ad.")}");  // expecting true
        Console.WriteLine($"{dictionary.SearchWord("ad.c")}"); // expecting true
        Console.WriteLine($"{dictionary.SearchWord("ad.d")}"); // expecting false
        Console.WriteLine($"{dictionary.SearchWord("adb")}");  // expecting true
        Console.WriteLine($"{dictionary.SearchWord("adg")}");  // expecting false
        Console.WriteLine($"{dictionary.SearchWord("ac.")}");  //expecting false
        Console.WriteLine($"{dictionary.SearchWord("ad..")}"); // expecting true
        Console.WriteLine($"{dictionary.SearchWord(".dc.")}"); // expecting true
    }
Exemplo n.º 32
0
        private void InitializeCore()
        {
            SelectedIndex = 0;
            NodeCategories = new Dictionary<string, CategorySearchElement>();
            SearchDictionary = new SearchDictionary<SearchElementBase>();
            SearchResults = new ObservableCollection<SearchElementBase>();
            MaxNumSearchResults = 35;
            Visible = false;
            searchText = "";

            _topResult = this.AddRootCategory("Top Result");
            this.AddRootCategory(BuiltinNodeCategories.CORE);
            this.AddRootCategory(BuiltinNodeCategories.LOGIC);
            this.AddRootCategory(BuiltinNodeCategories.GEOMETRY);
            this.AddRootCategory(BuiltinNodeCategories.REVIT);
            this.AddRootCategory(BuiltinNodeCategories.ANALYZE);
            this.AddRootCategory(BuiltinNodeCategories.IO);
        }
Exemplo n.º 33
0
        /// <summary>
        ///     The class constructor.
        /// </summary>
        /// <param name="bench"> Reference to dynBench object for logging </param>
        public SearchViewModel()
        {
            SelectedIndex = 0;
            RevitApiSearchElements = new List<SearchElementBase>();
            NodeCategories = new Dictionary<string, CategorySearchElement>();
            SearchDictionary = new SearchDictionary<SearchElementBase>();
            SearchResults = new ObservableCollection<SearchElementBase>();
            MaxNumSearchResults = 35;
            Visible = false;
            searchText = "";
            IncludeRevitAPIElements = true; // revit api

            _topResult = this.AddRootCategory("Top Result");
            this.AddRootCategory(BuiltinNodeCategories.CORE);
            this.AddRootCategory(BuiltinNodeCategories.LOGIC);
            this.AddRootCategory(BuiltinNodeCategories.GEOMETRY);
            this.AddRootCategory(BuiltinNodeCategories.REVIT);
            this.AddRootCategory(BuiltinNodeCategories.ANALYZE);
            this.AddRootCategory(BuiltinNodeCategories.IO);
        }
Exemplo n.º 34
0
        /// <summary>
        /// Attempts to obtain the list of search results.  If it fails, it does nothing
        /// </summary>
        public void Refresh()
        {
            var pkgs = PackageManagerClientViewModel.ListAll();

            pkgs.Sort((e1, e2) => e1.Name.ToLower().CompareTo(e2.Name.ToLower()));
            LastSync = pkgs;

            SearchDictionary = new SearchDictionary<PackageManagerSearchElement>();

            foreach (var pkg in pkgs)
            {
                SearchDictionary.Add(pkg, pkg.Name);
                SearchDictionary.Add(pkg, pkg.Description);
                SearchDictionary.Add(pkg, pkg.Maintainers);
                SearchDictionary.Add(pkg, pkg.Keywords);
            }
        }
Exemplo n.º 35
0
        /// <summary>
        ///     The class constructor.
        /// </summary>
        /// <param name="bench"> Reference to dynBench object for logging </param>
        public SearchViewModel()
        {
            SelectedIndex = 0;
            RevitApiSearchElements = new List<SearchElementBase>();
            NodeCategories = new Dictionary<string, CategorySearchElement>();
            SearchDictionary = new SearchDictionary<SearchElementBase>();
            SearchResults = new ObservableCollection<SearchElementBase>();
            MaxNumSearchResults = 20;
            Visible = Visibility.Collapsed;
            _SearchText = "";
            IncludeRevitAPIElements = false; // revit api
            Regions = new ObservableDictionary<string, RegionBase>();
            //Regions.Add("Include Nodes from Package Manager", DynamoCommands.PackageManagerRegionCommand );
            Regions.Add("Include Experimental Revit API Nodes", new RevitAPIRegion());

            _topResult = this.AddRootCategory("Top Result");
            this.AddRootCategory(BuiltinNodeCategories.CORE);
            this.AddRootCategory(BuiltinNodeCategories.LOGIC);
            this.AddRootCategory(BuiltinNodeCategories.CREATEGEOMETRY);
            this.AddRootCategory(BuiltinNodeCategories.MODIFYGEOMETRY);
            this.AddRootCategory(BuiltinNodeCategories.REVIT);
            this.AddRootCategory(BuiltinNodeCategories.IO);
            this.AddRootCategory(BuiltinNodeCategories.SCRIPTING);
            this.AddRootCategory(BuiltinNodeCategories.ANALYZE);
        }
Exemplo n.º 36
0
 /// <summary>
 ///     The class constructor.
 /// </summary>
 /// <param name="bench"> Reference to dynBench object for logging </param>
 public SearchViewModel()
 {
     SelectedIndex = 0;
     RevitApiSearchElements = new List<SearchElementBase>();
     NodeCategories = new Dictionary<string, CategorySearchElement>();
     SearchDictionary = new SearchDictionary<SearchElementBase>();
     SearchResults = new ObservableCollection<SearchElementBase>();
     MaxNumSearchResults = 100;
     Visible = Visibility.Collapsed;
     _SearchText = "";
     IncludeOptionalElements = false; // revit api
     Regions = new ObservableDictionary<string, RegionBase>();
     //Regions.Add("Include Nodes from Package Manager", DynamoCommands.PackageManagerRegionCommand );
     Regions.Add("Include Experimental Revit API Nodes", new RevitAPIRegion());
     AddHomeToSearch();
     AddCommandElements();
 }
Exemplo n.º 37
0
        private void InitializeCore()
        {
            NodeCategories = new Dictionary<string, CategorySearchElement>();
            SearchDictionary = new SearchDictionary<SearchElementBase>();
            MaxNumSearchResults = 15;

            // pre-populate the search categories
            this.AddRootCategory(BuiltinNodeCategories.CORE);
            this.AddRootCategory(LibraryServices.Categories.BuiltIns);
            this.AddRootCategory(LibraryServices.Categories.Operators);
            this.AddRootCategory(BuiltinNodeCategories.GEOMETRY);
            this.AddRootCategory(BuiltinNodeCategories.REVIT);
            this.AddRootCategory(BuiltinNodeCategories.ANALYZE);
            this.AddRootCategory("Units");
            this.AddRootCategory("Office");
            this.AddRootCategory("Migration");
        }
 internal PackageManagerSearchViewModel()
 {
     SearchResults = new ObservableCollection<PackageManagerSearchElementViewModel>();
     MaxNumSearchResults = 35;
     SearchDictionary = new SearchDictionary<PackageManagerSearchElement>();
     ClearCompletedCommand = new DelegateCommand(ClearCompleted, CanClearCompleted);
     SortCommand = new DelegateCommand(Sort, CanSort);
     SetSortingKeyCommand = new DelegateCommand<object>(SetSortingKey, CanSetSortingKey);
     SetSortingDirectionCommand = new DelegateCommand<object>(SetSortingDirection, CanSetSortingDirection);
     SearchResults.CollectionChanged += SearchResultsOnCollectionChanged;
     SearchText = "";
     SortingKey = PackageSortingKey.LastUpdate;
     SortingDirection = PackageSortingDirection.Ascending;
 }
Exemplo n.º 39
0
        /// <summary>
        ///     The class constructor.
        /// </summary>
        public PackageManagerSearchViewModel(PackageManagerClientViewModel client)
        {
            this.PackageManagerClientViewModel = client;

            SearchResults = new ObservableCollection<PackageManagerSearchElement>();
            MaxNumSearchResults = 35;
            SearchDictionary = new SearchDictionary<PackageManagerSearchElement>();
            ClearCompletedCommand = new DelegateCommand(ClearCompleted, CanClearCompleted);
            SortCommand = new DelegateCommand(Sort, CanSort);
            SetSortingKeyCommand = new DelegateCommand<object>(SetSortingKey, CanSetSortingKey);
            SetSortingDirectionCommand = new DelegateCommand<object>(SetSortingDirection, CanSetSortingDirection);
            PackageManagerClientViewModel.Downloads.CollectionChanged += DownloadsOnCollectionChanged;
            SearchResults.CollectionChanged += SearchResultsOnCollectionChanged;
            SearchText = "";
            SortingKey = PackageSortingKey.LAST_UPDATE;
            SortingDirection = PackageSortingDirection.ASCENDING;
        }