/// <summary> /// Finds the previous match based on the current position /// </summary> private void FindPrev(String text, Boolean refreshHighlights) { if (text == "") { return; } ScintillaControl sci = Globals.SciControl; this.findTextBox.BackColor = SystemColors.Window; List <SearchMatch> matches = this.GetResults(sci, text); if (matches != null && matches.Count != 0) { SearchMatch match = FRDialogGenerics.GetNextDocumentMatch(sci, matches, false, false); if (match != null) { FRDialogGenerics.SelectMatch(sci, match); } if (refreshHighlights) { this.RefreshHighlights(sci, matches); } String message = TextHelper.GetString("Info.ShowingResult"); Int32 index = FRDialogGenerics.GetMatchIndex(match, matches); String formatted = String.Format(message, index, matches.Count); this.infoLabel.Text = formatted; } else { this.findTextBox.BackColor = Color.Salmon; sci.SetSel(sci.SelectionStart, sci.SelectionStart); String message = TextHelper.GetString("Info.NoMatchesFound"); this.infoLabel.Text = message; } }
/// <summary> /// Finds the correct match based on the current position /// </summary> private void FindCorrect(String text, Boolean refreshHighlights) { if (string.IsNullOrEmpty(text)) { return; } ScintillaControl sci = Globals.SciControl; this.findTextBox.BackColor = this.backColor; List <SearchMatch> matches = this.GetResults(sci, text); if (matches != null && matches.Count != 0) { SearchMatch match = FRDialogGenerics.GetNextDocumentMatch(sci, matches, true, true); if (match != null) { FRDialogGenerics.SelectMatch(sci, match); } if (refreshHighlights) { this.RefreshHighlights(sci, matches); } String message = TextHelper.GetString("Info.ShowingResult"); Int32 index = FRDialogGenerics.GetMatchIndex(match, matches); String formatted = String.Format(message, index, matches.Count); this.infoLabel.Text = formatted; } else { this.findTextBox.BackColor = Globals.MainForm.GetThemeColor("QuickFind.ErrorBack", Color.Salmon); sci.SetSel(sci.SelectionStart, sci.SelectionStart); String message = TextHelper.GetString("Info.NoMatchesFound"); this.infoLabel.Text = message; } }
/// <summary> /// Runs the find based on the user specified arguments /// </summary> private void FindButtonClick(Object sender, EventArgs e) { String path = this.folderComboBox.Text; String mask = this.extensionComboBox.Text; Boolean recursive = this.subDirectoriesCheckBox.Checked; if (!String.IsNullOrEmpty(this.findComboBox.Text) && this.IsValidFileMask(mask)) { FRConfiguration config = this.GetFRConfig(path, mask, recursive); if (config == null) { return; } config.CacheDocuments = true; this.UpdateUIState(true); this.runner = new FRRunner(); this.runner.ProgressReport += new FRProgressReportHandler(this.RunnerProgress); this.runner.Finished += new FRFinishedHandler(this.FindFinished); this.runner.SearchAsync(config); // FRDialogGenerics.UpdateComboBoxItems(this.folderComboBox); FRDialogGenerics.UpdateComboBoxItems(this.extensionComboBox); FRDialogGenerics.UpdateComboBoxItems(this.findComboBox); } }
/// <summary> /// Shows the info message in dialog /// </summary> private void ShowMessage(String msg, Int32 img) { Image image = FRDialogGenerics.GetImage(img); this.infoPictureBox.Image = image; this.infoLabel.Text = msg; }
/// <summary> /// Bookmarks all results /// </summary> private void BookmarkAllButtonClick(Object sender, System.EventArgs e) { if (Globals.SciControl == null) { return; } ScintillaControl sci = Globals.SciControl; List <SearchMatch> matches = this.GetResults(sci); if (matches != null && this.lookComboBox.SelectedIndex == 1 && sci.SelText.Length > 0) { Int32 end = sci.MBSafeCharPosition(sci.SelectionEnd); Int32 start = sci.MBSafeCharPosition(sci.SelectionStart); matches = FRDialogGenerics.FilterMatches(matches, start, end); } if (matches != null && matches.Count != 0) { FRDialogGenerics.BookmarkMatches(sci, matches); String message = TextHelper.GetString("Info.MatchesBookmarked"); this.ShowMessage(message, 0); } else { String message = TextHelper.GetString("Info.NothingToBookmark"); this.ShowMessage(message, 0); } }
/// <summary> /// Runs the replace based on the user specified arguments /// </summary> private void ReplaceButtonClick(Object sender, EventArgs e) { String path = this.folderComboBox.Text; String mask = this.extensionComboBox.Text; Boolean recursive = this.subDirectoriesCheckBox.Checked; if (this.findComboBox.Text.Trim() != "") { if (!Globals.Settings.DisableReplaceFilesConfirm) { String caption = TextHelper.GetString("Title.ConfirmDialog"); String message = TextHelper.GetString("Info.AreYouSureToReplaceInFiles"); DialogResult result = MessageBox.Show(message, caption, MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.Cancel) { return; } } this.UpdateUIState(true); FRConfiguration config = new FRConfiguration(path, mask, recursive, this.GetFRSearch()); config.Replacement = this.replaceComboBox.Text; this.runner = new FRRunner(); this.runner.ProgressReport += new FRProgressReportHandler(this.RunnerProgress); this.runner.Finished += new FRFinishedHandler(this.ReplaceFinished); this.runner.ReplaceAsync(config); // FRDialogGenerics.UpdateComboBoxItems(this.folderComboBox); FRDialogGenerics.UpdateComboBoxItems(this.extensionComboBox); FRDialogGenerics.UpdateComboBoxItems(this.replaceComboBox); FRDialogGenerics.UpdateComboBoxItems(this.findComboBox); } }
/// <summary> /// Applies the settings to the UI /// </summary> public void UpdateSettings() { FRDialogGenerics.UpdateComboBoxItems(this.folderComboBox); Boolean useGroups = Globals.MainForm.Settings.UseListViewGrouping; this.resultsView.ShowGroups = useGroups; this.resultsView.GridLines = !useGroups; }
/// <summary> /// Replaces all results specified by user input /// </summary> private void ReplaceAllButtonClick(Object sender, System.EventArgs e) { if (Globals.SciControl == null) { return; } ScintillaControl sci = Globals.SciControl; List <SearchMatch> matches = this.GetResults(sci); Boolean selectionOnly = this.lookComboBox.SelectedIndex == 1 && sci.SelText.Length > 0; if (matches != null && selectionOnly) { Int32 end = sci.MBSafeCharPosition(sci.SelectionEnd); Int32 start = sci.MBSafeCharPosition(sci.SelectionStart); matches = FRDialogGenerics.FilterMatches(matches, start, end); } if (matches != null) { sci.BeginUndoAction(); try { for (Int32 i = 0, count = matches.Count; i < count; i++) { if (!selectionOnly) { FRDialogGenerics.SelectMatch(sci, matches[i]); } else { FRDialogGenerics.SelectMatchInTarget(sci, matches[i]); } String replaceWith = this.GetReplaceText(matches[i]); FRSearch.PadIndexes(matches, i, matches[i].Value, replaceWith); sci.EnsureVisible(sci.CurrentLine); if (!selectionOnly) { sci.ReplaceSel(replaceWith); } else { sci.ReplaceTarget(sci.MBSafeTextLength(replaceWith), replaceWith); } } } finally { sci.EndUndoAction(); } FRDialogGenerics.UpdateComboBoxItems(this.findComboBox); FRDialogGenerics.UpdateComboBoxItems(this.replaceComboBox); String message = TextHelper.GetString("Info.ReplacedMatches"); String formatted = String.Format(message, matches.Count); this.ShowMessage(formatted, 0); this.lookupIsDirty = false; } }
/// <summary> /// Finds the next result based on direction /// </summary> public void FindNext(Boolean forward, Boolean update, Boolean simple) { this.currentMatch = null; if (update) { this.UpdateFindText(); } if (Globals.SciControl == null) { return; } ScintillaControl sci = Globals.SciControl; List <SearchMatch> matches = this.GetResults(sci, simple); if (matches != null && matches.Count != 0) { FRDialogGenerics.UpdateComboBoxItems(this.findComboBox); SearchMatch match = FRDialogGenerics.GetNextDocumentMatch(sci, matches, forward, false); if (match != null) { this.currentMatch = match; FRDialogGenerics.SelectMatch(sci, match); this.lookupIsDirty = false; } if (this.Visible) { Int32 index = FRDialogGenerics.GetMatchIndex(match, matches); String message = TextHelper.GetString("Info.ShowingResult"); String formatted = String.Format(message, index, matches.Count); this.ShowMessage(formatted, 0); } } else { if (this.Visible) { String message = TextHelper.GetString("Info.NoMatchesFound"); this.ShowMessage(message, 0); } } this.SelectText(); }
/// <summary> /// Runs the replace based on the user specified arguments /// </summary> private void ReplaceButtonClick(Object sender, EventArgs e) { String mask = this.extensionComboBox.Text; Boolean recursive = this.subDirectoriesCheckBox.Checked; if (!String.IsNullOrEmpty(this.findComboBox.Text) && this.IsValidFileMask(mask)) { if (!Globals.Settings.DisableReplaceFilesConfirm) { String caption = TextHelper.GetString("Title.ConfirmDialog"); String message = TextHelper.GetString("Info.AreYouSureToReplaceInFiles"); DialogResult result = MessageBox.Show(message, caption, MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.Cancel) { return; } } string[] paths = this.folderComboBox.Text.Split(';'); foreach (string path in paths) { FRConfiguration config = this.GetFRConfig(path, mask, recursive); if (config == null) { return; } config.CacheDocuments = true; config.UpdateSourceFileOnly = false; config.Replacement = this.replaceComboBox.Text; this.UpdateUIState(true); this.runner = new FRRunner(); this.runner.ProgressReport += new FRProgressReportHandler(this.RunnerProgress); this.runner.Finished += new FRFinishedHandler(this.ReplaceFinished); this.runner.ReplaceAsync(config); // FRDialogGenerics.UpdateComboBoxItems(this.folderComboBox); FRDialogGenerics.UpdateComboBoxItems(this.extensionComboBox); FRDialogGenerics.UpdateComboBoxItems(this.replaceComboBox); FRDialogGenerics.UpdateComboBoxItems(this.findComboBox); } } }
/// <summary> /// Runs the find based on the user specified arguments /// </summary> private void FindButtonClick(Object sender, EventArgs e) { String path = this.folderComboBox.Text; String mask = this.extensionComboBox.Text; Boolean recursive = this.subDirectoriesCheckBox.Checked; if (this.findComboBox.Text.Trim() != "") { this.UpdateUIState(true); FRConfiguration config = new FRConfiguration(path, mask, recursive, this.GetFRSearch()); this.runner = new FRRunner(); this.runner.ProgressReport += new FRProgressReportHandler(this.RunnerProgress); this.runner.Finished += new FRFinishedHandler(this.FindFinished); this.runner.SearchAsync(config); // FRDialogGenerics.UpdateComboBoxItems(this.folderComboBox); FRDialogGenerics.UpdateComboBoxItems(this.extensionComboBox); FRDialogGenerics.UpdateComboBoxItems(this.findComboBox); } }
/// <summary> /// Replaces the next result specified by user input /// </summary> private void ReplaceButtonClick(Object sender, System.EventArgs e) { if (Globals.SciControl == null) { return; } ScintillaControl sci = Globals.SciControl; if (sci.SelText.Length == 0) { this.FindNext(true); } else { String replaceWith = this.GetReplaceText(currentMatch); sci.ReplaceSel(replaceWith); FRDialogGenerics.UpdateComboBoxItems(this.findComboBox); FRDialogGenerics.UpdateComboBoxItems(this.replaceComboBox); String message = TextHelper.GetString("Info.SelectedReplaced"); this.ShowMessage(message, 0); this.lookupIsDirty = false; this.FindNext(true); } }