Пример #1
0
 private void Search_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         ApplicationViewService.RunSearch(ApplicationView.CurrentSearch);
     }
 }
Пример #2
0
        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);
            }
        }
Пример #3
0
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            ApplicationViewService.LoadLastIndex();
            HandleStartupStart();
            FocusSearchText();

            SingleInstanceService.InitWndProc(this);
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
        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);
            }
        }
Пример #7
0
 private void Window_PreviewMouseUp(object sender, MouseButtonEventArgs e)
 {
     //Mouse back button
     if (e.ChangedButton == MouseButton.XButton1)
     {
         string searchTerm = ApplicationViewService.RunPreviousSearch(ApplicationView.CurrentSearch);
         if (!string.IsNullOrEmpty(searchTerm))
         {
             ApplicationView.CurrentSearch.SearchText = searchTerm;
         }
     }
     //Mouse forward button
     else if (e.ChangedButton == MouseButton.XButton2)
     {
         string searchTerm = ApplicationViewService.RunNextSearch(ApplicationView.CurrentSearch);
         if (!string.IsNullOrEmpty(searchTerm))
         {
             ApplicationView.CurrentSearch.SearchText = searchTerm;
         }
     }
 }
Пример #8
0
        private void Result_KeyDown(object sender, KeyEventArgs e)
        {
            var listView = (ListView)sender;

            if (e.Key == Key.End)
            {
                //disable END
                //If end is pressed and many lazy results are still to be loaded, all of them will be loaded at once
                //because the last item is always selected right away.
                e.Handled = true;
            }
            else if (e.Key == Key.Delete)
            {
                //remove selected files
                var selectedResultFiles = listView.SelectedItems.OfType <SearchResultViewModel>()
                                          .Select(cur => cur.GetFilePath())
                                          .Distinct();

                foreach (var delFile in selectedResultFiles.ToList())
                {
                    ApplicationView.CurrentSearch.FilterResults(delFile, FilterKind.RemoveFile);
                }
            }
            else if (e.Key == Key.Enter)
            {
                var searchResult = listView.SelectedItem as SearchResultViewModel;
                if (searchResult == null)
                {
                    return;
                }

                if (CodeIDXSettings.Results.FilterFileOnEnter)
                {
                    //Filter selected file
                    string fileToFilter = searchResult.GetFilePath();
                    ApplicationView.CurrentSearch.FilterResults(fileToFilter, FilterKind.LeaveFile);
                }
                else
                {
                    try
                    {
                        string file = searchResult.GetFilePath();
                        if (!CodeIDXSettings.Results.UseVisualStudioAsDefault || !Win32Helper.OpenInVisualStudio(file, searchResult.LineNumber))
                        {
                            //use default application
                            Process.Start(file);
                        }
                    }
                    catch { }
                }
            }
            else if (Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.C)
            {
                //copy selected filename to clipboard
                var searchResult = listView.SelectedItem as SearchResultViewModel;
                if (searchResult != null)
                {
                    Clipboard.SetText(searchResult.GetFilePath());
                }
            }
            else if (e.Key == Key.F5)
            {
                ApplicationViewService.RunLastSearch(ApplicationView.CurrentSearch);
            }
        }
Пример #9
0
 private async void UpdateIndex_Click(object sender, RoutedEventArgs e)
 {
     await ApplicationViewService.UpdateIndex();
 }
 protected override void Execute(SearchViewModel contextViewModel)
 {
     ApplicationViewService.RunSearch(contextViewModel);
 }