Advertisement
Guest User

Untitled

a guest
Feb 27th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. public void SearchAndSelectWord(string word, int startPos, int endPos, RichTextBoxFinds type)
  2.         {
  3.             this.Suspend();
  4.  
  5.             if (endOfSearchingFlag)
  6.             {
  7.                 index = this.Find(word, startPos, endPos, type);
  8.  
  9.                 ReturnCarriage(ref startPos, ref endPos);
  10.  
  11.                 endOfSearchingFlag = false;
  12.             }
  13.  
  14.             var preveousIndex = index;
  15.             index = this.Find(word, startPos, endPos, type);
  16.  
  17.             if (index == -1)
  18.             {
  19.                 if (isFirstTimeFlag)
  20.                 {
  21.                     ReturnCarriage(ref startPos, ref endPos);
  22.  
  23.                     index = this.Find(word, startPos, endPos, type);
  24.  
  25.                     if (index == -1)
  26.                     {
  27.                         var message = "Cannot find '" + LastWord + "'";
  28.                         MessageBox.Show(message, "Terrain Constructor", MessageBoxButtons.OK, MessageBoxIcon.Information);
  29.                     }
  30.                 }
  31.                 else
  32.                 {
  33.                     var message = "Finish searching document.";
  34.                     MessageBox.Show(message, "Terrain Constructor", MessageBoxButtons.OK, MessageBoxIcon.Information);
  35.                     index = preveousIndex;
  36.                     endOfSearchingFlag = true;
  37.                 }
  38.             }
  39.             else
  40.             {
  41.                 this.Select(index, word.Length);
  42.                 this.ScrollToCaret();
  43.                 this.isFirstTimeFlag = false;
  44.             }
  45.  
  46.             this.Resume();
  47.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement