|
|
@ -85,44 +85,55 @@ namespace SearchAndReplace |
|
|
|
|
|
|
|
|
|
|
|
void FindNextButtonClicked(object sender, EventArgs e) |
|
|
|
void FindNextButtonClicked(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
try { |
|
|
|
WritebackOptions(); |
|
|
|
WritebackOptions(); |
|
|
|
var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(true) : null); |
|
|
|
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 strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); |
|
|
|
lastMatch = SearchManager.FindNext(strategy, location); |
|
|
|
lastMatch = SearchManager.FindNext(strategy, location); |
|
|
|
SearchManager.SelectResult(lastMatch); |
|
|
|
SearchManager.SelectResult(lastMatch); |
|
|
|
Focus(); |
|
|
|
Focus(); |
|
|
|
|
|
|
|
} catch (SearchPatternException ex) { |
|
|
|
|
|
|
|
MessageService.ShowError(ex.Message); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void FindAllButtonClicked(object sender, EventArgs e) |
|
|
|
void FindAllButtonClicked(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WritebackOptions(); |
|
|
|
WritebackOptions(); |
|
|
|
var monitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor(); |
|
|
|
using (var monitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor()) { |
|
|
|
monitor.TaskName = StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}"); |
|
|
|
monitor.TaskName = StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}"); |
|
|
|
try { |
|
|
|
try { |
|
|
|
var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(false) : null); |
|
|
|
var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(false) : null); |
|
|
|
var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); |
|
|
|
var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); |
|
|
|
var results = SearchManager.FindAllParallel(strategy, location, monitor); |
|
|
|
var results = SearchManager.FindAllParallel(strategy, location, monitor); |
|
|
|
SearchManager.ShowSearchResults(SearchOptions.FindPattern, results); |
|
|
|
SearchManager.ShowSearchResults(SearchOptions.FindPattern, results); |
|
|
|
|
|
|
|
} catch (SearchPatternException ex) { |
|
|
|
|
|
|
|
MessageService.ShowError(ex.Message); |
|
|
|
} catch (OperationCanceledException) {} |
|
|
|
} catch (OperationCanceledException) {} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void BookmarkAllButtonClicked(object sender, EventArgs e) |
|
|
|
void BookmarkAllButtonClicked(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WritebackOptions(); |
|
|
|
WritebackOptions(); |
|
|
|
var monitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor(); |
|
|
|
using (var monitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor()) { |
|
|
|
monitor.TaskName = StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}"); |
|
|
|
monitor.TaskName = StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}"); |
|
|
|
try { |
|
|
|
try { |
|
|
|
var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(false) : null); |
|
|
|
var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(false) : null); |
|
|
|
var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); |
|
|
|
var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); |
|
|
|
var results = SearchManager.FindAllParallel(strategy, location, monitor); |
|
|
|
var results = SearchManager.FindAllParallel(strategy, location, monitor); |
|
|
|
SearchManager.MarkAll(results); |
|
|
|
SearchManager.MarkAll(results); |
|
|
|
|
|
|
|
} catch (SearchPatternException ex) { |
|
|
|
|
|
|
|
MessageService.ShowError(ex.Message); |
|
|
|
} catch (OperationCanceledException) {} |
|
|
|
} catch (OperationCanceledException) {} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ReplaceAllButtonClicked(object sender, EventArgs e) |
|
|
|
void ReplaceAllButtonClicked(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WritebackOptions(); |
|
|
|
WritebackOptions(); |
|
|
|
int count = -1; |
|
|
|
int count = -1; |
|
|
|
|
|
|
|
try { |
|
|
|
AsynchronousWaitDialog.RunInCancellableWaitDialog( |
|
|
|
AsynchronousWaitDialog.RunInCancellableWaitDialog( |
|
|
|
StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}"), null, |
|
|
|
StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}"), null, |
|
|
|
monitor => { |
|
|
|
monitor => { |
|
|
@ -133,10 +144,14 @@ namespace SearchAndReplace |
|
|
|
}); |
|
|
|
}); |
|
|
|
if (count != -1) |
|
|
|
if (count != -1) |
|
|
|
SearchManager.ShowReplaceDoneMessage(count); |
|
|
|
SearchManager.ShowReplaceDoneMessage(count); |
|
|
|
|
|
|
|
} catch (SearchPatternException ex) { |
|
|
|
|
|
|
|
MessageService.ShowError(ex.Message); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ReplaceButtonClicked(object sender, EventArgs e) |
|
|
|
void ReplaceButtonClicked(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
try { |
|
|
|
WritebackOptions(); |
|
|
|
WritebackOptions(); |
|
|
|
if (SearchManager.IsResultSelected(lastMatch)) |
|
|
|
if (SearchManager.IsResultSelected(lastMatch)) |
|
|
|
SearchManager.Replace(lastMatch, SearchOptions.ReplacePattern); |
|
|
|
SearchManager.Replace(lastMatch, SearchOptions.ReplacePattern); |
|
|
@ -145,6 +160,9 @@ namespace SearchAndReplace |
|
|
|
lastMatch = SearchManager.FindNext(strategy, location); |
|
|
|
lastMatch = SearchManager.FindNext(strategy, location); |
|
|
|
SearchManager.SelectResult(lastMatch); |
|
|
|
SearchManager.SelectResult(lastMatch); |
|
|
|
Focus(); |
|
|
|
Focus(); |
|
|
|
|
|
|
|
} catch (SearchPatternException ex) { |
|
|
|
|
|
|
|
MessageService.ShowError(ex.Message); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void WritebackOptions() |
|
|
|
void WritebackOptions() |
|
|
|