private async void EditIndex_Click(object sender, RoutedEventArgs e) { if (ApplicationView.CurrentIndexFile == null) { return; } IndexDialog dialog = new IndexDialog { DataContext = ApplicationView.CurrentIndexFile, Owner = this, IsNew = false, ResizeMode = System.Windows.ResizeMode.NoResize }; if (dialog.ShowDialog() == true) { ApplicationView.CurrentIndexFile.SaveIndexFile(); await ApplicationViewService.UpdateIndex(); } else { await ApplicationViewService.LoadIndex(ApplicationView.CurrentIndexFile.IndexFile); } }
private async void OpenIndex_Click(object sender, RoutedEventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog { Filter = string.Format("Index file (*{0})|*{0}", Constants.IndexFileExtension) }; if (fileDialog.ShowDialog() == true) { await ApplicationViewService.LoadIndex(fileDialog.FileName); } }
private async void LoadRecentIndex_Click(object sender, RoutedEventArgs e) { var menuItem = sender as MenuItem; if (menuItem == null) { return; } var recentIndex = menuItem.DataContext as RecentIndexSetting; if (recentIndex == null) { return; } await ApplicationViewService.LoadIndex(recentIndex); }
private async void CreateIndex(ApplicationViewModel contextViewModel, IndexViewModel indexModel) { Guid opId = Guid.Empty; CancellationToken cancelToken; if (!contextViewModel.BeginOperation(StatusKind.Indexing, out opId, out cancelToken)) { return; } try { string newIndexDirectory = indexModel.IndexDirectory; await Task.Run(() => { LuceneIndexer.Instance.CreateIndexDirectory(indexModel.SourceDirectories, indexModel.FileFilters, newIndexDirectory, cancelToken); if (cancelToken.IsCancellationRequested) { return; } indexModel.LastFullRefresh = DateTime.Now; indexModel.SaveIndexFile(); }, cancelToken); if (cancelToken.IsCancellationRequested) { if (Directory.Exists(newIndexDirectory)) { Directory.Delete(newIndexDirectory, true); } return; } contextViewModel.EndOperation(opId); await ApplicationViewService.LoadIndex(indexModel.IndexFile); } finally { contextViewModel.EndOperation(opId); } }