Ejemplo n.º 1
0
        /// <summary>
        /// Shows a wait dialog.
        /// </summary>
        /// <param name="titleName">Title of the wait dialog</param>
        /// <param name="taskName">Name of the current task</param>
        /// <returns>WaitHandle object - you can use it to access the wait dialog's properties.
        /// To close the wait dialog, call Dispose() on the WaitHandle</returns>
        public static AsynchronousWaitDialog ShowWaitDialog(string titleName)
        {
            if (titleName == null)
            {
                throw new ArgumentNullException("titleName");
            }
            AsynchronousWaitDialog h = new AsynchronousWaitDialog(titleName);

            h.Start();
            return(h);
        }
Ejemplo n.º 2
0
 private void Button_ReplaceAll_Click(object sender, EventArgs e)
 {
     WritebackOptions();
     if (IsSelectionSearch)
     {
         if (IsTextSelected(selection))
         {
             RunAllInSelection(2);
         }
     }
     else
     {
         using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("Search", true))
         {
             SearchReplaceManager.ReplaceAll(monitor);
         }
     }
 }
Ejemplo n.º 3
0
 void BookmarkAllButtonClicked(object sender, EventArgs e)
 {
     WritebackOptions();
     if (IsSelectionSearch)
     {
         if (IsTextSelected(selection))
         {
             RunAllInSelection(1);
         }
     }
     else
     {
         using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("Search"))
         {
             SearchReplaceManager.MarkAll(monitor);
         }
     }
 }
Ejemplo n.º 4
0
 void FindAllButtonClicked(object sender, EventArgs e)
 {
     WritebackOptions();
     if (IsSelectionSearch)
     {
         if (IsTextSelected(selection))
         {
             RunAllInSelection(0);
         }
     }
     else
     {
         using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("Search"))
         {
             SearchInFilesManager.FindAll(monitor);
         }
     }
 }
Ejemplo n.º 5
0
 void ReplaceAllButtonClicked(object sender, EventArgs e)
 {
     WritebackOptions();
     if (IsSelectionSearch)
     {
         if (selection.IsTextSelected)
         {
             RunAllInSelection(2);
         }
     }
     else
     {
         using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("Search", true))
         {
             monitor.Progress = double.NaN;                     // progress not implemented, use indeterminate progress
             SearchReplaceManager.ReplaceAll(monitor);
         }
     }
 }
Ejemplo n.º 6
0
 void FindNextButtonClicked(object sender, EventArgs e)
 {
     WritebackOptions();
     if (IsSelectionSearch)
     {
         if (IsTextSelected(selection))
         {
             FindNextInSelection();
         }
     }
     else
     {
         using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("Search"))
         {
             SearchReplaceManager.FindNext(monitor);
         }
     }
     Focus();
 }
        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);
            }
        }