public |
Subversion Repositories: |
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace BeatBox
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool Play(string strFile)
{
if (Environment.OSVersion.Platform.ToString().ToLower().Equals("wince"))
{
return (PlaySoundWinCE.PlaySound(strFile, IntPtr.Zero, SoundFlags.SND_ASYNC));
}
else
{
return (PlaySoundWin32.PlaySound(strFile, IntPtr.Zero, SoundFlags.SND_ASYNC));
}
}
bool Play(byte[] arrBytes)
{
if (Environment.OSVersion.Platform.ToString().ToLower().Equals("wince"))
{
return (PlaySoundWinCE.PlaySound(arrBytes, IntPtr.Zero, SoundFlags.SND_ASYNC | SoundFlags.SND_MEMORY));
}
else
{
return (PlaySoundWin32.PlaySound(arrBytes, IntPtr.Zero, SoundFlags.SND_ASYNC | SoundFlags.SND_MEMORY));
}
}
private void Form1_Resize(object sender, EventArgs e)
{
Control control = (Control)sender;
Single width = control.ClientSize.Width;
Single height = control.ClientSize.Height;
Single bw = (width - 4) / 3;
Single bh = (height - 4) / 3;
pictureBox1.Width = (int) bw;
pictureBox1.Height = (int) bh;
pictureBox1.Top = 1;
pictureBox1.Left = 2;
pictureBox2.Width = (int)bw;
pictureBox2.Height = (int)bh;
pictureBox2.Top = 1;
pictureBox2.Left = 3 + (int)bw;
pictureBox3.Width = (int)bw;
pictureBox3.Height = (int)bh;
pictureBox3.Top = 1;
pictureBox3.Left = 4 + (2 * (int)bw);
pictureBox4.Width = (int)bw;
pictureBox4.Height = (int)bh;
pictureBox4.Top = 2 + (int)bh;
pictureBox4.Left = 2;
pictureBox5.Width = (int)bw;
pictureBox5.Height = (int)bh;
pictureBox5.Top = 2 + (int)bh;
pictureBox5.Left = 3 + (int)bw;
pictureBox6.Width = (int)bw;
pictureBox6.Height = (int)bh;
pictureBox6.Top = 2 + (int)bh;
pictureBox6.Left = 4 + (2 * (int)bw);
pictureBox7.Width = (int)bw;
pictureBox7.Height = (int)bh;
pictureBox7.Top = 3 + (2 * (int)bh);
pictureBox7.Left = 2;
pictureBox8.Width = (int)bw;
pictureBox8.Height = (int)bh;
pictureBox8.Top = 3 + (2 * (int)bh);
pictureBox8.Left = 3 + (int)bw;
pictureBox9.Width = (int)bw;
pictureBox9.Height = (int)bh;
pictureBox9.Top = 3 + (2 * (int)bh);
pictureBox9.Left = 4 + (2 * (int)bw);
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
Play(BeatBox.Properties.Resources.drum1);
}
private void pictureBox2_MouseDown(object sender, MouseEventArgs e)
{
Play(BeatBox.Properties.Resources.drum2);
}
private void pictureBox3_MouseDown(object sender, MouseEventArgs e)
{
Play(BeatBox.Properties.Resources.drum3);
}
private void pictureBox4_MouseDown(object sender, MouseEventArgs e)
{
Play(BeatBox.Properties.Resources.drum4);
}
private void pictureBox5_Click(object sender, EventArgs e)
{
Play(BeatBox.Properties.Resources.drum5);
}
private void pictureBox6_Click(object sender, EventArgs e)
{
Play(BeatBox.Properties.Resources.drum6);
}
private void pictureBox7_Click(object sender, EventArgs e)
{
Play(BeatBox.Properties.Resources.drum7);
}
private void pictureBox8_Click(object sender, EventArgs e)
{
Play(BeatBox.Properties.Resources.drum8);
}
private void pictureBox9_Click(object sender, EventArgs e)
{
Play(BeatBox.Properties.Resources.drum9);
}
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
if ((e.KeyCode == System.Windows.Forms.Keys.D1))
{
Play(BeatBox.Properties.Resources.drum1);
}
if ((e.KeyCode == System.Windows.Forms.Keys.D2))
{
Play(BeatBox.Properties.Resources.drum2);
}
if ((e.KeyCode == System.Windows.Forms.Keys.D3))
{
Play(BeatBox.Properties.Resources.drum3);
}
if ((e.KeyCode == System.Windows.Forms.Keys.D4))
{
Play(BeatBox.Properties.Resources.drum4);
}
if ((e.KeyCode == System.Windows.Forms.Keys.D5))
{
Play(BeatBox.Properties.Resources.drum5);
}
if ((e.KeyCode == System.Windows.Forms.Keys.D6))
{
Play(BeatBox.Properties.Resources.drum6);
}
if ((e.KeyCode == System.Windows.Forms.Keys.D7))
{
Play(BeatBox.Properties.Resources.drum7);
}
if ((e.KeyCode == System.Windows.Forms.Keys.D8))
{
Play(BeatBox.Properties.Resources.drum8);
}
if ((e.KeyCode == System.Windows.Forms.Keys.D9))
{
Play(BeatBox.Properties.Resources.drum9);
}
}
}
}
Generated by GNU enscript 1.6.4.