private void listBox1_KeyDown(object sender, KeyEventArgs e)
{
controlKeyPressed = false;
if (ModifierKeys == Keys.Control)
{
// Set control key to true to allow listBox1_keyPressed to know that
// control key is been pressed. This is to prevent control + <key>
// to be sent back to Microsoft Word.
// Eg. Pressing CTRL + N while on the listBox will not pass CTRL + N to
// Microsoft Word.
controlKeyPressed = true;
Keys[] keys = {Keys.D1, Keys.D2, Keys.D3, Keys.D4, Keys.D5,
Keys.D6, Keys.D7, Keys.D8, Keys.D9};
for (int i = 0; i < this.getDisplaySuggestionCount(); i++)
{
if (e.KeyCode == keys[i])
{
quickPaste(i);
e.Handled = true;
}
}
}
else if (e.KeyCode == Keys.Left)
{
e.Handled = true;
previousSuggestionPage();
}
else if (e.KeyCode == Keys.Right)
{
e.Handled = true;
nextSuggestionPage();
}
else if (e.KeyCode == Keys.Enter)
{
Globals.ThisAddIn.insertSuggestion(displaySuggestion[listBox1.SelectedIndex]);
}
else if (e.KeyCode == Keys.Escape)
{
this.Hide();
}
else
{
String result = "";
char key = (char)e.KeyCode;
if (e.KeyCode == Keys.Tab)
{
result = "{tab}";
}
if (!result.Equals(""))
{
Globals.ThisAddIn.Application.Activate();
SendKeys.Send(result);
this.Hide();
e.Handled = true;
}
}
}