예제 #1
0
        /// <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);
            }
        }
예제 #2
0
        /// <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;
            }
        }