Exemplo n.º 1
0
        private void OnKeyPressed(object sender, InputEventArg e)
        {
//             lbHandle.Text = e.KeyPressEvent.DeviceHandle.ToString();
//             lbType.Text = e.KeyPressEvent.DeviceType;
//             lbName.Text = e.KeyPressEvent.DeviceName;
//             lbDescription.Text = e.KeyPressEvent.Name;
//             lbKey.Text = e.KeyPressEvent.VKey.ToString(CultureInfo.InvariantCulture);
//             lbNumKeyboards.Text = _rawinput.NumberOfKeyboards.ToString(CultureInfo.InvariantCulture);
//             lbVKey.Text = e.KeyPressEvent.VKeyName;
//             lbSource.Text = e.KeyPressEvent.Source;
//             lbKeyPressState.Text = e.KeyPressEvent.KeyPressState;
//             lbMessage.Text = string.Format("0x{0:X4} ({0})", e.KeyPressEvent.Message);

            switch (e.KeyPressEvent.Message)
            {
                case Win32.WM_KEYDOWN:
                    /*Debug.WriteLine(e.KeyPressEvent.KeyPressState);*/
                    break;
                case Win32.WM_KEYUP:
                    textBox.Text += e.KeyPressEvent.VKeyName.ToString() + "\n";
                    textBox.ScrollToEnd();
                    break;
            }
        }
Exemplo n.º 2
0
 private void OnKeyPressed(object sender, InputEventArg e)
 {
     switch (e.KeyPressEvent.Message)
     {
         case Win32.WM_KEYDOWN:
             /*Debug.WriteLine(e.KeyPressEvent.KeyPressState);*/
             break;
         case Win32.WM_KEYUP:
             textBox.Text += e.KeyPressEvent.VKeyName.ToString() + "\n";
             textBox.ScrollToEnd();
             break;
     }
 }
Exemplo n.º 3
0
        private void OnKeyPressed(object sender, InputEventArg e)
        {
            string vkStatus = e.KeyPressEvent.KeyPressState; // Retrieves information from the user input
            int vkNumber = e.KeyPressEvent.VKey;
            string vkName = e.KeyPressEvent.VKeyName;

            currentKey = vkStatus;
            if (previousKey == "BREAK")
            {
                previousKey = currentKey;
                return;
            }

            if (currentKey == previousKey) // Determiens if a key is being held down.
            {
                switch (vkNumber)
                {
                    case (int)MusicKeys.Previous: // Determines whether or not the rewind or fast-forward a track.
                        if (!isRewinding)
                        {
                            RewindSong();
                        }
                        break;
                    case (int)MusicKeys.Next:
                        if (!isFastForwarding)
                        {
                            FastForwardSong();
                        }
                        break;
                }
                canCheck = false;
            }
            else
            {
                if (!t.Enabled) // Enables the timer to determine whether or not the application should check for a key press.
                {
                    SetTimer(); // Enables the timer. Prevents repeated calls (e.g. calling "Next Track" multiple times, which would skip a few tracks)
                }
                if (canCheck)
                {
                    switch (vkNumber) // Depending on the key pressed, executes an action.
                    {
                        case (int)MusicKeys.Previous:
                            PreviousSong();
                            break;
                        case (int)MusicKeys.Next:
                            NextSong();
                            break;
                        case (int)MusicKeys.Stop:
                            StopSong();
                            break;
                        case (int)MusicKeys.PlayPause:
                            PlayPauseSong();
                            break;
                    }
                    isRewinding = false;
                    isFastForwarding = false;
                    previousKey = "BREAK";
                }
            }
        }