Beispiel #1
0
 void ReplaceButtonClicked(object sender, EventArgs e)
 {
     try {
         WritebackOptions();
         if (SearchManager.IsResultSelected(lastMatch))
         {
             SearchManager.Replace(lastMatch, SearchOptions.ReplacePattern);
         }
         var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(true) : null);
         var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode);
         lastMatch = SearchManager.FindNext(strategy, location);
         SearchManager.SelectResult(lastMatch);
         Focus();
     } catch (SearchPatternException ex) {
         MessageService.ShowError(ex.Message);
     }
 }
Beispiel #2
0
        void BookmarkAllButtonClicked(object sender, EventArgs e)
        {
            WritebackOptions();
            var             location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(false) : null);
            ISearchStrategy strategy;

            try {
                strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode);
            } catch (SearchPatternException ex) {
                MessageService.ShowError(ex.Message);
                return;
            }
            // No using block for the monitor; it is disposed when the asynchronous search finishes
            var monitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor();

            monitor.TaskName = StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}");
            var results = SearchManager.FindAllParallel(strategy, location, monitor);

            SearchManager.MarkAll(results);
        }
Beispiel #3
0
        void ReplaceAllButtonClicked(object sender, EventArgs e)
        {
            WritebackOptions();
            int count = -1;

            try {
                AsynchronousWaitDialog.RunInCancellableWaitDialog(
                    StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}"), null,
                    monitor => {
                    var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(true) : null);
                    var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode);
                    var results  = SearchManager.FindAll(strategy, location, monitor);
                    count        = SearchManager.ReplaceAll(results, SearchOptions.ReplacePattern, monitor.CancellationToken);
                });
                if (count != -1)
                {
                    SearchManager.ShowReplaceDoneMessage(count);
                }
            } catch (SearchPatternException ex) {
                MessageService.ShowError(ex.Message);
            }
        }