Advertisement
Guest User

Untitled

a guest
Feb 27th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.62 KB | None | 0 0
  1.         private void SearchWindow_KeyDown(object sender, KeyEventArgs e)
  2.         {
  3.             if (e.KeyCode == Keys.Escape)
  4.             {
  5.                 this.Close();
  6.             }
  7.             else if (e.KeyCode == Keys.F3 && e.Shift)
  8.             {
  9.                 if (outputRichTextBox.LastWord == "")
  10.                     outputRichTextBox.ShowSearchWindow();
  11.                 else
  12.                 {
  13.                     var word = outputRichTextBox.LastWord;
  14.                     var mouthIndexPos = outputRichTextBox.SelectionStart;
  15.                     outputRichTextBox.Index  = mouthIndexPos;
  16.                     var index = outputRichTextBox.Index;
  17.                     this.outputRichTextBox.SearchAndSelectWord(word, 0, index, RichTextBoxFinds.Reverse);
  18.                 }
  19.             }
  20.             else if (e.KeyCode == Keys.F3)
  21.             {
  22.                 if (this.outputRichTextBox.LastWord == "")
  23.                     this.outputRichTextBox.ShowSearchWindow();
  24.                 else
  25.                 {
  26.                     var mouthIndexPos = outputRichTextBox.SelectionStart;
  27.                     var word = this.outputRichTextBox.LastWord;
  28.                     this.outputRichTextBox.Index = outputRichTextBox.SelectionStart;
  29.                     var endPos = this.outputRichTextBox.TextLength;
  30.                     var startPos = outputRichTextBox.Index + word.Length;
  31.  
  32.                     if (startPos > endPos)
  33.                         startPos = endPos - 1;
  34.  
  35.                     this.outputRichTextBox.SearchAndSelectWord(word, startPos, endPos, RichTextBoxFinds.None);
  36.                 }
  37.             }
  38.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement