Advertisement
slashdemonofthesword

C# Beat Pad Code

Jul 28th, 2012
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.27 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Windows.Forms;
  4. using System.Media;
  5.  
  6. namespace A_Beat_Pad
  7. {
  8.     public partial class Form1 : Form
  9.     {
  10.         public Form1()
  11.         {
  12.             InitializeComponent();
  13.         }
  14.  
  15.         private void button1_Click(object sender, EventArgs e)
  16.         {
  17.             // Not Needed
  18.         }
  19.  
  20.         private void Form1_KeyDown(object sender, KeyEventArgs e)
  21.         {
  22.             // Not Needed
  23.         }
  24.  
  25.         private void button1_KeyDown(object sender, KeyEventArgs e)
  26.         {
  27.             if (e.KeyCode == (Keys.S))
  28.             {                                      // Edit File Location,
  29.                 SoundPlayer snare = new SoundPlayer(@"C:\Users\Anguel Esperanza\My Documents\Wave Files\snare.wav");// Wav File Location
  30.                 snare.Play();
  31.             }
  32.             // Adds Focus To The Other Buttons When Key Is Pressed
  33.             else if (e.KeyCode == Keys.D)
  34.                 button2.Focus();
  35.             else if (e.KeyCode == Keys.F)
  36.                 button3.Focus();
  37.             else if (e.KeyCode == Keys.G)
  38.                 button4.Focus();
  39.         }
  40.  
  41.         private void button2_KeyDown(object sender, KeyEventArgs e)
  42.         {
  43.             if (e.KeyCode == Keys.D)
  44.             {                                      // Edit File Location,
  45.                 SoundPlayer hi_hat = new SoundPlayer(@"C:\Users\Anguel Esperanza\My Documents\Wave Files\hi hat.wav");// Wav File Location
  46.                 hi_hat.Play();
  47.  
  48.             }
  49.             // Adds Focus To The Other Buttons When Key Is Pressed
  50.             else if (e.KeyCode == Keys.S)
  51.                 button1.Focus();
  52.             else if (e.KeyCode == Keys.F)
  53.                 button3.Focus();
  54.             else if (e.KeyCode == Keys.G)
  55.                 button4.Focus();
  56.            
  57.         }
  58.  
  59.         private void button3_Click(object sender, EventArgs e)
  60.         {
  61.             // Not Needed
  62.         }
  63.  
  64.         private void button3_KeyDown(object sender, KeyEventArgs e)
  65.         {
  66.             if (e.KeyCode == Keys.F)
  67.             {                                      // Edit File Location,
  68.                 SoundPlayer clap = new SoundPlayer(@"C:\Users\Anguel Esperanza\My Documents\Wave Files\clap.wav");// Wav File Location
  69.                 clap.Play();
  70.             }
  71.             // Adds Focus To The Other Buttons When Key Is Pressed
  72.             else if (e.KeyCode == Keys.S)
  73.                 button1.Focus();
  74.             else if (e.KeyCode == Keys.D)
  75.                 button2.Focus();
  76.             else if (e.KeyCode == Keys.G)
  77.                 button4.Focus();
  78.         }
  79.  
  80.         private void button4_KeyDown(object sender, KeyEventArgs e)
  81.         {
  82.             if (e.KeyCode == Keys.G)
  83.             {                                      // Edit File Location,
  84.                 SoundPlayer kick = new SoundPlayer(@"C:\Users\Anguel Esperanza\My Documents\Wave Files\kick.wav");// Wav File Lo
  85.                 kick.Play();
  86.             }
  87.             // Adds Focus To The Other Buttons When Key Is Pressed
  88.             else if (e.KeyCode == Keys.S)
  89.                 button1.Focus();
  90.             else if (e.KeyCode == Keys.D)
  91.                 button2.Focus();
  92.             else if (e.KeyCode == Keys.F)
  93.                 button3.Focus();
  94.         }
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement