示例#1
0
        /// <summary>
        /// Performs the search
        /// </summary>
        /// <returns>A Task to the search function</returns>
        private async Task Search()
        {
            // reset the results
            SearchResults = null;

            // verify there is a folder
            if (string.IsNullOrEmpty(Folder))
            {
                return;
            }

            // find the folder project item
            FolderConnectionProjectItem folder = Project.Current.GetItems <FolderConnectionProjectItem>().FirstOrDefault(f => f.Path == Folder);

            if (folder == null)
            {
                return;
            }

            // do the search
            IEnumerable <Item> results = await folder.SearchAsync(SearchString);

            // assign to the results variable
            SearchResults = results.ToList();
        }
示例#2
0
        private async void AddFolderToProject(string addFolderPath)
        {
            try
            {
                // Add a folder to the Project
                var folderToAdd = ItemFactory.Create(addFolderPath);
                await Project.Current.AddAsync(folderToAdd);

                // find the folder project item
                FolderConnectionProjectItem folder = Project.Current.GetItems <FolderConnectionProjectItem>().FirstOrDefault(f => f.Path.Equals(addFolderPath, StringComparison.CurrentCultureIgnoreCase));
                if (folder == null)
                {
                    return;
                }

                // do the search
                IEnumerable <Item> folderFiles = await folder.SearchAsync(Filter);

                // search MXDs
                lock (_lockMxdItemCollection)
                {
                    _mxdItems.Clear();
                    foreach (var newItem in folderFiles)
                    {
                        _mxdItems.Add(newItem);
                    }
                }
                NotifyPropertyChanged(() => MxdItems);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error adding folder to project: " + ex.ToString());
            }
        }