136 lines
5.0 KiB
C#
136 lines
5.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.IO;
|
|
using System.Media;
|
|
using System.Diagnostics;
|
|
|
|
namespace SoundBoard
|
|
{
|
|
public partial class formMain : Form
|
|
{
|
|
|
|
public SoundPlayer player = new SoundPlayer();
|
|
public Random randomNum = new Random();
|
|
|
|
public formMain()
|
|
{
|
|
InitializeComponent();
|
|
//create event handlers for onClick events in the ListBoxes
|
|
gamerPoopListBox.MouseClick += new MouseEventHandler(gamerPoopListBox_Click);
|
|
asdfMovieListBox.MouseClick += new MouseEventHandler(asdfMovieListBox_Click);
|
|
}
|
|
|
|
private void gamerPoopListBox_Click(object sender, MouseEventArgs e)
|
|
{
|
|
string fullPath = Path.GetFullPath("gamer_poop/") + gamerPoopListBox.SelectedItem + ".wav";
|
|
player.SoundLocation = fullPath;
|
|
player.Load();
|
|
player.Play();
|
|
}
|
|
|
|
private void asdfMovieListBox_Click(object sender, MouseEventArgs e)
|
|
{
|
|
string fullPath = Path.GetFullPath("asdfmovie/") + asdfMovieListBox.SelectedItem + ".wav";
|
|
player.SoundLocation = fullPath;
|
|
player.Load();
|
|
player.Play();
|
|
}
|
|
|
|
private void formMain_Load(object sender, EventArgs e)
|
|
{
|
|
string[] soundFiles;
|
|
soundFiles = Directory.GetFiles(Path.GetFullPath("gamer_poop/"));
|
|
foreach (string str in soundFiles)
|
|
{
|
|
this.gamerPoopListBox.Items.Add(Path.GetFileNameWithoutExtension(str));
|
|
}
|
|
soundFiles = Directory.GetFiles(Path.GetFullPath("asdfmovie/"));
|
|
foreach (string str in soundFiles)
|
|
{
|
|
asdfMovieListBox.Items.Add(Path.GetFileNameWithoutExtension(str));
|
|
}
|
|
}
|
|
|
|
private void btnRandom_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
int iterations = (int)randomIterationNumericUpDown.Value;
|
|
string fullPath;
|
|
//disable the Random Button and the NumericUpDown box
|
|
btnRandom.Enabled = false;
|
|
randomIterationNumericUpDown.Enabled = false;
|
|
|
|
for (int i = 0; i < iterations; i++)
|
|
{
|
|
int tempRandomNumber;
|
|
|
|
if (this.soundboardTabControl.SelectedIndex == 0)
|
|
{
|
|
tempRandomNumber = randomNum.Next(gamerPoopListBox.Items.Count - 1);
|
|
gamerPoopListBox.SelectedIndex = tempRandomNumber;
|
|
fullPath = Path.GetFullPath("gamer_poop/") + gamerPoopListBox.SelectedItem + ".wav";
|
|
player.SoundLocation = fullPath;
|
|
player.Load();
|
|
player.PlaySync();
|
|
}
|
|
else if (this.soundboardTabControl.SelectedIndex == 1)
|
|
{
|
|
tempRandomNumber = randomNum.Next(asdfMovieListBox.Items.Count - 1);
|
|
asdfMovieListBox.SelectedIndex = tempRandomNumber;
|
|
fullPath = Path.GetFullPath("asdfmovie/") + asdfMovieListBox.SelectedItem + ".wav";
|
|
player.SoundLocation = fullPath;
|
|
player.Load();
|
|
player.PlaySync();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("The " + soundboardTabControl.SelectedTab.Text + " tab has no sounds to play.", "No Sounds to Play");
|
|
}
|
|
}
|
|
//re-enable the controls
|
|
btnRandom.Enabled = true;
|
|
randomIterationNumericUpDown.Enabled = true;
|
|
}
|
|
|
|
private void mainMenuFileExit_Click(object sender, EventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private void mainMenuFileShowOnDisk_Click(object sender, EventArgs e)
|
|
{
|
|
string filePath;
|
|
string arg;
|
|
|
|
if (soundboardTabControl.SelectedIndex == 0)
|
|
{
|
|
filePath = Path.GetFullPath("gamer_poop/") + gamerPoopListBox.SelectedItem + ".wav";
|
|
arg = "/select, " + '"' + filePath + '"';
|
|
Process.Start("explorer.exe", arg);
|
|
}
|
|
else if (soundboardTabControl.SelectedIndex == 1)
|
|
{
|
|
filePath = Path.GetFullPath("asdfmovie/") + asdfMovieListBox.SelectedItem + ".wav";
|
|
arg = "/select, " + '"' + filePath + '"';
|
|
Process.Start("explorer.exe", arg);
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Unable to open files in this tab.", "Error");
|
|
}
|
|
}
|
|
|
|
private void mainMenuHelpAbout_Click(object sender, EventArgs e)
|
|
{
|
|
MessageBox.Show("YouTube Soundboard\nVersion: 0.2.5.0\nBuilt in .NET 4.5\nAnd way to lazy to create a pretty About Form.", "YouTube Soundboard");
|
|
}
|
|
}
|
|
}
|