public static IDocumentIterator CreateDocumentIterator(DocumentIteratorType type, IProgressMonitor monitor) { switch (type) { case DocumentIteratorType.CurrentDocument: case DocumentIteratorType.CurrentSelection: return new CurrentDocumentIterator(); case DocumentIteratorType.Directory: try { if (!Directory.Exists(SearchOptions.LookIn)) { if (monitor != null) monitor.ShowingDialog = true; MessageService.ShowMessageFormatted("${res:Dialog.NewProject.SearchReplace.SearchStringNotFound.Title}", "${res:Dialog.NewProject.SearchReplace.LookIn.DirectoryNotFound}", FileUtility.NormalizePath(SearchOptions.LookIn)); if (monitor != null) monitor.ShowingDialog = false; return new DummyDocumentIterator(); } } catch (Exception ex) { if (monitor != null) monitor.ShowingDialog = true; MessageService.ShowMessage(ex.Message); if (monitor != null) monitor.ShowingDialog = false; return new DummyDocumentIterator(); } return new DirectoryDocumentIterator(SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories); case DocumentIteratorType.AllOpenFiles: return new AllOpenDocumentIterator(); case DocumentIteratorType.WholeProject: return new WholeProjectDocumentIterator(); case DocumentIteratorType.WholeSolution: return new WholeSolutionDocumentIterator(); default: throw new System.NotImplementedException("CreateDocumentIterator for type " + type); } }
public static IDocumentIterator CreateDocumentIterator(DocumentIteratorType type, IProgressMonitor monitor) { switch (type) { case DocumentIteratorType.CurrentDocument: case DocumentIteratorType.CurrentSelection: return(new CurrentDocumentIterator()); case DocumentIteratorType.Directory: try { if (!Directory.Exists(SearchOptions.LookIn)) { if (monitor != null) { monitor.ShowingDialog = true; } MessageService.ShowMessageFormatted("${res:Dialog.NewProject.SearchReplace.SearchStringNotFound.Title}", "${res:Dialog.NewProject.SearchReplace.LookIn.DirectoryNotFound}", FileUtility.NormalizePath(SearchOptions.LookIn)); if (monitor != null) { monitor.ShowingDialog = false; } return(new DummyDocumentIterator()); } } catch (Exception ex) { if (monitor != null) { monitor.ShowingDialog = true; } MessageService.ShowMessage(ex.Message); if (monitor != null) { monitor.ShowingDialog = false; } return(new DummyDocumentIterator()); } return(new DirectoryDocumentIterator(SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories)); case DocumentIteratorType.AllOpenFiles: return(new AllOpenDocumentIterator()); case DocumentIteratorType.WholeProject: return(new WholeProjectDocumentIterator()); case DocumentIteratorType.WholeSolution: return(new WholeSolutionDocumentIterator()); default: throw new System.NotImplementedException("CreateDocumentIterator for type " + type); } }
public static IDocumentIterator CreateDocumentIterator(DocumentIteratorType type) { switch (type) { case DocumentIteratorType.CurrentDocument: case DocumentIteratorType.CurrentSelection: return(new CurrentDocumentIterator()); case DocumentIteratorType.AllOpenFiles: return(new AllOpenDocumentIterator()); default: throw new System.NotImplementedException("CreateDocumentIterator for type " + type); } }
public static IDocumentIterator CreateDocumentIterator(DocumentIteratorType type) { switch (type) { case DocumentIteratorType.None: return null; case DocumentIteratorType.CurrentDocument: return new CurrentDocumentIterator(); case DocumentIteratorType.Directory: return new DirectoryDocumentIterator(SearchReplaceInFilesManager.SearchOptions.SearchDirectory, SearchReplaceInFilesManager.SearchOptions.FileMask, SearchReplaceInFilesManager.SearchOptions.SearchSubdirectories); case DocumentIteratorType.AllOpenFiles: return new AllOpenDocumentIterator(); case DocumentIteratorType.WholeCombine: return new WholeProjectDocumentIterator(); default: throw new System.NotImplementedException("CreateDocumentIterator for type " + type); } }
void SetOptions() { ComboBox_FindWhat.Text = SearchOptions.FindPattern; ComboBox_FindWhat.Items.Clear(); ComboBox_FindWhat.Text = SearchOptions.FindPattern; ComboBox_FindWhat.Items.Clear(); foreach (string findPattern in SearchOptions.FindPatterns) { ComboBox_FindWhat.Items.Add(findPattern); } if (searchAndReplaceMode == SearchAndReplaceMode.Replace) { ComboBox_ReplaceWith.Text = SearchOptions.ReplacePattern; ComboBox_ReplaceWith.Items.Clear(); foreach (string replacePattern in SearchOptions.ReplacePatterns) { ComboBox_ReplaceWith.Items.Add(replacePattern); } } ComboBox_LookIn.Text = SearchOptions.LookIn; //string[] lookInTexts = { // // must be in the same order as the DocumentIteratorType enum // "${res:Dialog.NewProject.SearchReplace.LookIn.CurrentDocument}", // "${res:Dialog.NewProject.SearchReplace.LookIn.CurrentSelection}", // //"${res:Dialog.NewProject.SearchReplace.LookIn.AllOpenDocuments}", // //"${res:Dialog.NewProject.SearchReplace.LookIn.WholeProject}", // //"${res:Dialog.NewProject.SearchReplace.LookIn.WholeSolution}" //}; //foreach (string lookInText in lookInTexts) { // ComboBox_LookIn.Items.Add(StringParser.Parse(lookInText)); //} //ComboBox_LookIn.Items.Add(SearchOptions.LookIn); //ComboBox_LookIn.SelectedIndexChanged += new EventHandler(LookInSelectedIndexChanged); if (IsMultipleLineSelection(GetCurrentTextSelection())) { DocumentIteratorType = DocumentIteratorType.CurrentSelection; } else { if (SearchOptions.DocumentIteratorType == DocumentIteratorType.CurrentSelection) { SearchOptions.DocumentIteratorType = DocumentIteratorType.CurrentDocument; } DocumentIteratorType = SearchOptions.DocumentIteratorType; } //Get<ComboBox>("fileTypes").Text = SearchOptions.LookInFiletypes; CheckBox_MatchCase.Checked = SearchOptions.MatchCase; CheckBox_MatchWholeWord.Checked = SearchOptions.MatchWholeWord; //Get<CheckBox>("includeSubFolder").Checked = SearchOptions.IncludeSubdirectories; //this.ComboBox_Use.Items.Clear(); //ComboBox_Use.Items.Add(StringParser.Parse("${res:Dialog.NewProject.SearchReplace.SearchStrategy.Standard}")); //ComboBox_Use.Items.Add(StringParser.Parse("${res:Dialog.NewProject.SearchReplace.SearchStrategy.RegexSearch}")); //ComboBox_Use.Items.Add(StringParser.Parse("${res:Dialog.NewProject.SearchReplace.SearchStrategy.WildcardSearch}")); switch (SearchOptions.SearchStrategyType) { case SearchStrategyType.RegEx: ComboBox_Use.SelectedIndex = 1; break; case SearchStrategyType.Wildcard: ComboBox_Use.SelectedIndex = 2; break; default: ComboBox_Use.SelectedIndex = 0; break; } }
void SetOptions() { Get <ComboBox>("find").Text = SearchOptions.FindPattern; Get <ComboBox>("find").Items.Clear(); Get <ComboBox>("find").Text = SearchOptions.FindPattern; Get <ComboBox>("find").Items.Clear(); foreach (string findPattern in SearchOptions.FindPatterns) { Get <ComboBox>("find").Items.Add(findPattern); } if (searchAndReplaceMode == SearchAndReplaceMode.Replace) { Get <ComboBox>("replace").Text = SearchOptions.ReplacePattern; Get <ComboBox>("replace").Items.Clear(); foreach (string replacePattern in SearchOptions.ReplacePatterns) { Get <ComboBox>("replace").Items.Add(replacePattern); } } Get <ComboBox>("lookIn").Text = SearchOptions.LookIn; string[] lookInTexts = { // must be in the same order as the DocumentIteratorType enum "${res:Dialog.NewProject.SearchReplace.LookIn.CurrentDocument}", "${res:Dialog.NewProject.SearchReplace.LookIn.CurrentSelection}", "${res:Dialog.NewProject.SearchReplace.LookIn.AllOpenDocuments}", "${res:Dialog.NewProject.SearchReplace.LookIn.WholeProject}", "${res:Dialog.NewProject.SearchReplace.LookIn.WholeSolution}" }; foreach (string lookInText in lookInTexts) { Get <ComboBox>("lookIn").Items.Add(StringParser.Parse(lookInText)); } Get <ComboBox>("lookIn").Items.Add(SearchOptions.LookIn); Get <ComboBox>("lookIn").SelectedIndexChanged += new EventHandler(LookInSelectedIndexChanged); if (IsMultipleLineSelection(SearchReplaceUtilities.GetActiveTextEditor())) { DocumentIteratorType = DocumentIteratorType.CurrentSelection; } else { if (SearchOptions.DocumentIteratorType == DocumentIteratorType.CurrentSelection) { SearchOptions.DocumentIteratorType = DocumentIteratorType.CurrentDocument; } DocumentIteratorType = SearchOptions.DocumentIteratorType; } Get <ComboBox>("fileTypes").Text = SearchOptions.LookInFiletypes; Get <CheckBox>("matchCase").Checked = SearchOptions.MatchCase; Get <CheckBox>("matchWholeWord").Checked = SearchOptions.MatchWholeWord; Get <CheckBox>("includeSubFolder").Checked = SearchOptions.IncludeSubdirectories; Get <ComboBox>("use").Items.Clear(); Get <ComboBox>("use").Items.Add(StringParser.Parse("${res:Dialog.NewProject.SearchReplace.SearchStrategy.Standard}")); Get <ComboBox>("use").Items.Add(StringParser.Parse("${res:Dialog.NewProject.SearchReplace.SearchStrategy.RegexSearch}")); Get <ComboBox>("use").Items.Add(StringParser.Parse("${res:Dialog.NewProject.SearchReplace.SearchStrategy.WildcardSearch}")); switch (SearchOptions.SearchStrategyType) { case SearchStrategyType.RegEx: Get <ComboBox>("use").SelectedIndex = 1; break; case SearchStrategyType.Wildcard: Get <ComboBox>("use").SelectedIndex = 2; break; default: Get <ComboBox>("use").SelectedIndex = 0; break; } }
void SetOptions() { Get<ComboBox>("find").Text = SearchOptions.FindPattern; Get<ComboBox>("find").Items.Clear(); Get<ComboBox>("find").Text = SearchOptions.FindPattern; Get<ComboBox>("find").Items.Clear(); foreach (string findPattern in SearchOptions.FindPatterns) { Get<ComboBox>("find").Items.Add(findPattern); } if (searchAndReplaceMode == SearchAndReplaceMode.Replace) { Get<ComboBox>("replace").Text = SearchOptions.ReplacePattern; Get<ComboBox>("replace").Items.Clear(); foreach (string replacePattern in SearchOptions.ReplacePatterns) { Get<ComboBox>("replace").Items.Add(replacePattern); } } Get<ComboBox>("lookIn").Text = SearchOptions.LookIn; string[] lookInTexts = { // must be in the same order as the DocumentIteratorType enum "${res:Dialog.NewProject.SearchReplace.LookIn.CurrentDocument}", "${res:Dialog.NewProject.SearchReplace.LookIn.CurrentSelection}", "${res:Dialog.NewProject.SearchReplace.LookIn.AllOpenDocuments}", "${res:Dialog.NewProject.SearchReplace.LookIn.WholeProject}", "${res:Dialog.NewProject.SearchReplace.LookIn.WholeSolution}" }; foreach (string lookInText in lookInTexts) { Get<ComboBox>("lookIn").Items.Add(StringParser.Parse(lookInText)); } Get<ComboBox>("lookIn").Items.Add(SearchOptions.LookIn); Get<ComboBox>("lookIn").SelectedIndexChanged += new EventHandler(LookInSelectedIndexChanged); if (IsMultipleLineSelection(GetCurrentTextSelection())) { DocumentIteratorType = DocumentIteratorType.CurrentSelection; } else { DocumentIteratorType = SearchOptions.DocumentIteratorType; } Get<ComboBox>("fileTypes").Text = SearchOptions.LookInFiletypes; Get<CheckBox>("matchCase").Checked = SearchOptions.MatchCase; Get<CheckBox>("matchWholeWord").Checked = SearchOptions.MatchWholeWord; Get<CheckBox>("includeSubFolder").Checked = SearchOptions.IncludeSubdirectories; Get<ComboBox>("use").Items.Clear(); Get<ComboBox>("use").Items.Add(StringParser.Parse("${res:Dialog.NewProject.SearchReplace.SearchStrategy.Standard}")); Get<ComboBox>("use").Items.Add(StringParser.Parse("${res:Dialog.NewProject.SearchReplace.SearchStrategy.RegexSearch}")); Get<ComboBox>("use").Items.Add(StringParser.Parse("${res:Dialog.NewProject.SearchReplace.SearchStrategy.WildcardSearch}")); switch (SearchOptions.SearchStrategyType) { case SearchStrategyType.RegEx: Get<ComboBox>("use").SelectedIndex = 1; break; case SearchStrategyType.Wildcard: Get<ComboBox>("use").SelectedIndex = 2; break; default: Get<ComboBox>("use").SelectedIndex = 0; break; } }