예제 #1
0
 public SearchBoxViewModel()
 {
     Searcher = new Searcher();
     DisplaySearchPurpose = new ObservableCollection<string>(new List<string>
         {
             LocalizedStrings.SearchName,
             LocalizedStrings.SearchColor
         });
     DisplaySearchScope = new ObservableCollection<string>(new List<string>
         {
             LocalizedStrings.AllDisck,
             LocalizedStrings.CurrentDirectory
         });
     SelectedSearchPurpose = SearchPurpose.Name;
     SelectedSearchScope = SearchScope.CurrentDirectory;
 }
예제 #2
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            var searcher = new Searcher(@"E:\GitHub Project\Everything\PhotoApplication\bin\Debug\SearchIndex");
            var hits = searcher.Search(SearchInupt.Text);
            var fileSystemItems = new List<FileSystemItem>();
            for (int i = 0; i < hits.Count(); i++)
            {
                var hit = hits[i];
                Document doc = searcher.GetDocument(hit.Doc);
                Field fileNameField = doc.GetField("Name");
                Field pathField = doc.GetField("Path");
                Field typeField = doc.GetField("Type");
                var fileItemType = FileItemType.File;
                switch (typeField.StringValue)
                {
                    case "File":
                        fileItemType = FileItemType.File;
                        break;
                    case "Directory":
                        fileItemType = FileItemType.Directory;
                        break;
                    case "Driver":
                        fileItemType = FileItemType.Drive;
                        break;

                }
                fileSystemItems.Add(new FileSystemItem(pathField.StringValue, fileNameField.StringValue, fileItemType));
            }

            FileBrowserHistory.PushBackHistory(FileBrowserHistory.SearchPage);
            SetDataContext(new FileItemsViewModel(fileSystemItems));
        }