Ejemplo n.º 1
0
 private void btReplaceAll_Click(object sender, EventArgs e)
 {
     try
     {
         tb.Selection.BeginUpdate();
         tb.Selection.Start = new Place(0, 0);
         //search
         var ranges = FindAll();
         //replace
         if (ranges.Count > 0)
         {
             tb.manager.ExecuteCommand(new ReplaceTextCommand(tb, ranges, tbReplace.Text));
             tb.Selection.Start = new Place(0, 0);
         }
         //
         tb.Invalidate();
         CheetahMessage f = new CheetahMessage();
         f.Title = "Info";
         f.Message = ranges.Count + " occurrence(s) replaced";
         f.CancelVisible = false;
         f.ShowDialog();
     }
     catch (Exception ex)
     {
         CheetahMessage f = new CheetahMessage();
         f.Title = "Error!";
         f.Message = ex.Message;
         f.CancelVisible = false;
         f.ShowDialog();
     }
     tb.Selection.EndUpdate();
 }
Ejemplo n.º 2
0
 private void btFindNext_Click(object sender, EventArgs e)
 {
     try
     {
         if (!Find())
         {
             CheetahMessage f = new CheetahMessage();
             f.Title = "Warning!";
             f.Message = "Not found";
             f.CancelVisible = false;
             f.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         CheetahMessage f = new CheetahMessage();
         f.Title = "Error!";
         f.Message = ex.Message;
         f.CancelVisible = false;
         f.ShowDialog();
     }
 }
Ejemplo n.º 3
0
 private void btReplace_Click(object sender, EventArgs e)
 {
     try
     {
         if (tb.SelectionLength != 0)
             tb.InsertText(tbReplace.Text);
         btFindNext_Click(sender, null);
     }
     catch (Exception ex)
     {
         CheetahMessage f = new CheetahMessage();
         f.Title = "Error!";
         f.Message = ex.Message;
         f.CancelVisible = false;
         f.ShowDialog();
     }
 }
Ejemplo n.º 4
0
 private void FindNext()
 {
     try
     {
         string pattern = tbFind.Text;
         RegexOptions opt = cbMatchCase.Checked ? RegexOptions.None : RegexOptions.IgnoreCase;
         if (!cbRegex.Checked)
             pattern = Regex.Replace(pattern, RegexSpecSymbolsPattern, "\\$0");
         if (cbWholeWord.Checked)
             pattern = "\\b" + pattern + "\\b";
         //
         Range range = tb.Selection.Clone();
         range.Normalize();
         //
         if (firstSearch)
         {
             startPlace = range.Start;
             firstSearch = false;
         }
         //
         range.Start = range.End;
         if (range.Start >= startPlace)
             range.End = new Place(tb.GetLineLength(tb.LinesCount - 1), tb.LinesCount - 1);
         else
             range.End = startPlace;
         //
         foreach (var r in range.GetRanges(pattern, opt))
         {
             tb.Selection = r;
             tb.DoSelectionVisible();
             tb.Invalidate();
             return;
         }
         //
         if (range.Start >= startPlace && startPlace > Place.Empty)
         {
             tb.Selection.Start = new Place(0, 0);
             FindNext();
             return;
         }
         CheetahMessage f = new CheetahMessage();
         f.Title = "Warning!";
         f.Message = "Not found";
         f.CancelVisible = false;
         f.ShowDialog();
     }
     catch (Exception ex)
     {
         CheetahMessage f = new CheetahMessage();
         f.Title = "Error!";
         f.Message = ex.Message;
         f.CancelVisible = false;
         f.ShowDialog();
     }
 }