Esempio n. 1
0
        void keyboardHook_GlobalKeyDown(KeyboardHook sender, KeyboardHook.KeyEventArgsExt e)
        {
            if (this.Visible && !settingsShown)
            {
                int inputNum = -1;
                if (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9)
                {
                    inputNum = e.KeyCode - Keys.D0;
                }

                /*if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9)
                 * {
                 *  inputNum = e.KeyCode - Keys.NumPad0;
                 * }*/
                if (inputNum >= 0)
                {
                    e.Handled = true;
                    timer1.Stop();
                    TextInputHelper.InputString(resultButtons[(inputNum + 9) % 10].Text);
                    this.handwritingDisplayPanel1.ClearStrokes();
                    this.ink.DeleteStrokes();
                    this.Invalidate();
                }
                else if (e.KeyCode == Keys.OemMinus)
                {
                    e.Handled = true;
                    timer1.Stop();
                    this.handwritingDisplayPanel1.ClearStrokes();
                    this.ink.DeleteStrokes();
                    this.Invalidate();
                }
            }
        }
 void keyboardHook_GlobalKeyDown(KeyboardHook sender, KeyboardHook.KeyEventArgsExt e)
 {
     //System.Diagnostics.Debug.WriteLine("Down Key = {0}, ScanCode = {1}", e.KeyCode, e.ScanCode);
     if (useScancode ? e.Scancode == scancode : e.KeyCode == key)
     {
         if (!isKeyDown)
         {
             isKeyDown = true;
             if (hasPressedOnce)
             {
                 if (pressIntervalStopwatch.ElapsedMilliseconds > interval)
                 {
                     hasPressedOnce = false;
                     pressIntervalStopwatch.Reset();
                     pressIntervalStopwatch.Start();
                 }
             }
             else
             {
                 pressIntervalStopwatch.Reset();
                 pressIntervalStopwatch.Start();
             }
         }
     }
     else
     {
         isKeyDown      = false;
         hasPressedOnce = false;
     }
 }
 void keyboardHook_GlobalKeyUp(KeyboardHook sender, KeyboardHook.KeyEventArgsExt e)
 {
     //System.Diagnostics.Debug.WriteLine("Up   Key = {0}, ScanCode = {1}", e.KeyCode, e.ScanCode);
     if (useScancode ? e.Scancode == scancode : e.KeyCode == key)
     {
         if (isKeyDown)
         {
             isKeyDown = false;
             if (hasPressedOnce)
             {
                 pressIntervalStopwatch.Stop();
                 hasPressedOnce = false;
                 if (pressIntervalStopwatch.ElapsedMilliseconds <= interval)
                 {
                     //System.Diagnostics.Debug.WriteLine("Yeah!");
                     KeyboardDoublePressEventHandler handler = this.KeyDoublePressed;
                     if (handler != null)
                     {
                         handler(this, this.useScancode ? new KeyboardDoublePressEventArgs(this.scancode) : new KeyboardDoublePressEventArgs(this.key));
                     }
                 }
             }
             else
             {
                 hasPressedOnce = true;
             }
         }
     }
     else
     {
         isKeyDown      = false;
         hasPressedOnce = false;
     }
 }
 void keyboardHook_GlobalKeyDown(KeyboardHook sender, KeyboardHook.KeyEventArgsExt e)
 {
     e.Handled = true;
     if (this.InvokeRequired)
     {
         this.BeginInvoke((KeyboardHook.KeyEventHandlerExt)keyboardHook_GlobalKeyDown, sender, e);
     }
     else
     {
         this.key                         = e.KeyCode;
         this.scancode                    = e.Scancode;
         this.keyboardHook.Enabled        = true;
         this.keyboardHook.GlobalKeyDown -= new KeyboardHook.KeyEventHandlerExt(keyboardHook_GlobalKeyDown);
         this.DialogResult                = System.Windows.Forms.DialogResult.OK;
         this.Close();
     }
 }