Beispiel #1
0
 // https://stackoverflow.com/questions/604410/global-keyboard-capture-in-c-sharp-application
 private void onKeyPressed(object sender, GlobalKeyboardHookEventArgs e)
 {
     if (e.KeyboardData.VirtualCode == Keys.Up.GetHashCode() && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
     {
         playlist.ElementAt(playlistIndex).y++;
         alignPlayer();
         showPlaylist();
     }
     else if (e.KeyboardData.VirtualCode == Keys.Down.GetHashCode() && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
     {
         playlist.ElementAt(playlistIndex).y--;
         alignPlayer();
         showPlaylist();
     }
     else if (e.KeyboardData.VirtualCode == Keys.Left.GetHashCode() && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
     {
         playlist.ElementAt(playlistIndex).x--;
         alignPlayer();
         showPlaylist();
     }
     else if (e.KeyboardData.VirtualCode == Keys.Right.GetHashCode() && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
     {
         playlist.ElementAt(playlistIndex).x++;
         alignPlayer();
         showPlaylist();
     }
     else if (e.KeyboardData.VirtualCode == Keys.Q.GetHashCode() && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
     {
         playlist.ElementAt(playlistIndex).w++;
         alignPlayer();
         showPlaylist();
     }
     else if (e.KeyboardData.VirtualCode == Keys.A.GetHashCode() && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
     {
         playlist.ElementAt(playlistIndex).w--;
         alignPlayer();
         showPlaylist();
     }
     else if (e.KeyboardData.VirtualCode == Keys.W.GetHashCode() && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
     {
         playlist.ElementAt(playlistIndex).h++;
         alignPlayer();
         showPlaylist();
     }
     else if (e.KeyboardData.VirtualCode == Keys.S.GetHashCode() && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
     {
         playlist.ElementAt(playlistIndex).h--;
         alignPlayer();
         showPlaylist();
     }
     else if (e.KeyboardData.VirtualCode == Keys.Escape.GetHashCode() && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
     {
         storePlaylist();
         Close();
     }
     else if (e.KeyboardData.VirtualCode == Keys.X.GetHashCode() && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
     {
         playNext();
     }
     else if (e.KeyboardData.VirtualCode == Keys.Y.GetHashCode() && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
     {
         playPrevious();
     }
     else if (e.KeyboardData.VirtualCode == Keys.Space.GetHashCode() && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
     {
         player.togglePlayPause();
     }
     else if (e.KeyboardData.VirtualCode == Keys.N.GetHashCode() && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
     {
         player.backwards30s();
     }
     else if (e.KeyboardData.VirtualCode == Keys.M.GetHashCode() && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
     {
         player.forwards30s();
     }
 }