Version Beta 1.5.0.0 as marked by the aboutForm dialog.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoundBoard
|
||||
{
|
||||
class GenerateRandomPlayList
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.9.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.9.0.0")]
|
||||
[assembly: AssemblyVersion("1.5.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.5.0.0")]
|
||||
|
||||
@@ -96,6 +96,7 @@
|
||||
<Compile Include="aboutForm.Designer.cs">
|
||||
<DependentUpon>aboutForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GenerateRandomPlayList.cs" />
|
||||
<Compile Include="mainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
||||
Generated
+1
-1
@@ -58,7 +58,7 @@
|
||||
this.applicationVersionLabel.Name = "applicationVersionLabel";
|
||||
this.applicationVersionLabel.Size = new System.Drawing.Size(246, 80);
|
||||
this.applicationVersionLabel.TabIndex = 1;
|
||||
this.applicationVersionLabel.Text = "Dynamic Soundboard \r\n\r\nVersion Beta 0.9.0.0\r\nMP3 sound format supported!";
|
||||
this.applicationVersionLabel.Text = "Dynamic Soundboard \r\n\r\nVersion Beta 1.5.0.0\r\nMP3 sound format supported!";
|
||||
//
|
||||
// lordBalgruufPortrait
|
||||
//
|
||||
|
||||
Generated
+19
-3
@@ -42,6 +42,7 @@
|
||||
this.soundboardTabControl = new System.Windows.Forms.TabControl();
|
||||
this.loopSelectedSoundCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.fileSystemWatcherMain = new System.IO.FileSystemWatcher();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.mainMenu.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.randomIterationNumericUpDown)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.fileSystemWatcherMain)).BeginInit();
|
||||
@@ -52,7 +53,8 @@
|
||||
this.btnRandom.Location = new System.Drawing.Point(7, 545);
|
||||
this.btnRandom.Name = "btnRandom";
|
||||
this.btnRandom.Size = new System.Drawing.Size(81, 23);
|
||||
this.btnRandom.TabIndex = 1;
|
||||
this.btnRandom.TabIndex = 0;
|
||||
this.btnRandom.TabStop = false;
|
||||
this.btnRandom.Text = "Random";
|
||||
this.btnRandom.UseVisualStyleBackColor = true;
|
||||
this.btnRandom.Click += new System.EventHandler(this.btnRandom_Click);
|
||||
@@ -132,7 +134,7 @@
|
||||
0});
|
||||
this.randomIterationNumericUpDown.Name = "randomIterationNumericUpDown";
|
||||
this.randomIterationNumericUpDown.Size = new System.Drawing.Size(58, 20);
|
||||
this.randomIterationNumericUpDown.TabIndex = 4;
|
||||
this.randomIterationNumericUpDown.TabIndex = 1;
|
||||
this.randomIterationNumericUpDown.TabStop = false;
|
||||
this.randomIterationNumericUpDown.Value = new decimal(new int[] {
|
||||
1,
|
||||
@@ -148,6 +150,7 @@
|
||||
this.soundboardTabControl.SelectedIndex = 0;
|
||||
this.soundboardTabControl.Size = new System.Drawing.Size(425, 506);
|
||||
this.soundboardTabControl.TabIndex = 0;
|
||||
this.soundboardTabControl.TabStop = false;
|
||||
//
|
||||
// loopSelectedSoundCheckBox
|
||||
//
|
||||
@@ -155,7 +158,8 @@
|
||||
this.loopSelectedSoundCheckBox.Location = new System.Drawing.Point(158, 549);
|
||||
this.loopSelectedSoundCheckBox.Name = "loopSelectedSoundCheckBox";
|
||||
this.loopSelectedSoundCheckBox.Size = new System.Drawing.Size(129, 17);
|
||||
this.loopSelectedSoundCheckBox.TabIndex = 3;
|
||||
this.loopSelectedSoundCheckBox.TabIndex = 2;
|
||||
this.loopSelectedSoundCheckBox.TabStop = false;
|
||||
this.loopSelectedSoundCheckBox.Text = "Loop Selected Sound";
|
||||
this.loopSelectedSoundCheckBox.UseVisualStyleBackColor = true;
|
||||
this.loopSelectedSoundCheckBox.CheckedChanged += new System.EventHandler(this.loopSelectedSoundCheckBox_CheckedChanged);
|
||||
@@ -165,17 +169,28 @@
|
||||
this.fileSystemWatcherMain.EnableRaisingEvents = true;
|
||||
this.fileSystemWatcherMain.SynchronizingObject = this;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(294, 548);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(35, 13);
|
||||
this.label1.TabIndex = 4;
|
||||
this.label1.Text = "label1";
|
||||
//
|
||||
// formMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(425, 578);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.loopSelectedSoundCheckBox);
|
||||
this.Controls.Add(this.randomIterationNumericUpDown);
|
||||
this.Controls.Add(this.soundboardTabControl);
|
||||
this.Controls.Add(this.btnRandom);
|
||||
this.Controls.Add(this.mainMenu);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.KeyPreview = true;
|
||||
this.MainMenuStrip = this.mainMenu;
|
||||
this.Name = "formMain";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
@@ -205,6 +220,7 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem mainMenuHelpAbout;
|
||||
private System.Windows.Forms.CheckBox loopSelectedSoundCheckBox;
|
||||
private System.IO.FileSystemWatcher fileSystemWatcherMain;
|
||||
public System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+205
-156
@@ -1,26 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
namespace SoundBoard
|
||||
{
|
||||
public partial class formMain : Form
|
||||
public partial class formMain : Form, IMessageFilter
|
||||
{
|
||||
private const int WM_KEYDOWN = 0x100;
|
||||
public WMPLib.WindowsMediaPlayer Player = new WMPLib.WindowsMediaPlayer();
|
||||
public Random randomNum = new Random();
|
||||
public ListBox listBoxEntity = new ListBox();
|
||||
ProcessStartInfo process = new ProcessStartInfo();
|
||||
BackgroundWorker worker = new BackgroundWorker();
|
||||
public string _workingDirectory;
|
||||
public ListView listViewEntity = new ListView();
|
||||
public string _workingDirectory = Path.GetDirectoryName(Application.ExecutablePath);
|
||||
public string[] _soundFiles;
|
||||
public string[] _soundDirectories;
|
||||
|
||||
@@ -31,29 +30,27 @@ namespace SoundBoard
|
||||
|
||||
private void formMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
_workingDirectory = Path.GetDirectoryName(Application.ExecutablePath);
|
||||
_soundFiles = Directory.GetFiles(_workingDirectory);
|
||||
//Build the UI, foreach directory create one TabPage and one ListView object
|
||||
foreach (string sound in _soundFiles)
|
||||
{
|
||||
CreateUITabs("Working Directory", _workingDirectory);
|
||||
}
|
||||
|
||||
_soundDirectories = Directory.GetDirectories(_workingDirectory);
|
||||
_soundDirectories = Directory.GetDirectories(_workingDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
foreach (string sounds in _soundDirectories)
|
||||
{
|
||||
CreateUITabs(Path.GetFileName(sounds), sounds);
|
||||
}
|
||||
|
||||
worker.WorkerSupportsCancellation = true;
|
||||
worker.WorkerReportsProgress = true;
|
||||
fileSystemWatcherMain.Path = _workingDirectory;
|
||||
fileSystemWatcherMain.IncludeSubdirectories = true;
|
||||
Application.AddMessageFilter(this);
|
||||
fileSystemWatcherMain.Path = _workingDirectory; //watch in the application's working directory
|
||||
fileSystemWatcherMain.IncludeSubdirectories = true; //and watch in the subfolders for changes, but only one layer down from the app's directory
|
||||
fileSystemWatcherMain.Created += new FileSystemEventHandler(fileSystemUpdateDetected); //file or folder created
|
||||
fileSystemWatcherMain.Deleted += new FileSystemEventHandler(fileSystemUpdateDetected); //file or folder moved or deleted
|
||||
fileSystemWatcherMain.Renamed += new RenamedEventHandler(fileSystemUpdateDetected); //for any file changes like file extension changes
|
||||
soundboardTabControl.SelectedIndexChanged += new EventHandler(CheckForDisabledListBox); //disables ore enables the Show on Disk file menu object
|
||||
Player.PlayStateChange += new WMPLib._WMPOCXEvents_PlayStateChangeEventHandler(WMP_PlayStateChange);
|
||||
//check to see if the listBox is empty on form load
|
||||
soundboardTabControl.SelectedIndexChanged += new EventHandler(CheckForDisabledListBox); //disables or enables the Show on Disk file menu object
|
||||
Player.PlayStateChange += new WMPLib._WMPOCXEvents_PlayStateChangeEventHandler(WMP_PlayStateChange); //eventhandler for the playstate of the Player object
|
||||
//check to see if the listView is empty on form load
|
||||
if (soundboardTabControl.SelectedTab.Controls[0].Enabled == true)
|
||||
{
|
||||
mainMenuFileShowOnDisk.Enabled = true;
|
||||
@@ -64,10 +61,41 @@ namespace SoundBoard
|
||||
mainMenuFileShowOnDisk.Enabled = false;
|
||||
btnRandom.Enabled = false;
|
||||
}
|
||||
soundboardTabControl.Select();
|
||||
}
|
||||
|
||||
private void WMP_PlayStateChange(int newState)
|
||||
{
|
||||
//check to see if the random play functions are running
|
||||
if (btnRandom.Enabled == false)
|
||||
{
|
||||
if (Player.playState == WMPLib.WMPPlayState.wmppsTransitioning)
|
||||
{
|
||||
//Player is transitioning, so keep the controls disabled
|
||||
btnRandom.Enabled = false;
|
||||
loopSelectedSoundCheckBox.Enabled = false;
|
||||
}
|
||||
else if (Player.playState == WMPLib.WMPPlayState.wmppsPlaying)
|
||||
{
|
||||
//player is still playing the random playlist, keep the controls disbaled
|
||||
btnRandom.Enabled = false;
|
||||
loopSelectedSoundCheckBox.Enabled = false;
|
||||
}
|
||||
else if (Player.playState == WMPLib.WMPPlayState.wmppsReady)
|
||||
{
|
||||
//renable the controls, the Random functions are done
|
||||
//first check to see if the loop checkBox is checked, if so set the player to "loop"
|
||||
if (soundboardTabControl.SelectedTab.Controls[0].Enabled == true)
|
||||
{
|
||||
btnRandom.Enabled = true;
|
||||
}
|
||||
if (loopSelectedSoundCheckBox.Checked == true)
|
||||
{
|
||||
Player.settings.setMode("loop", true);
|
||||
}
|
||||
loopSelectedSoundCheckBox.Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fileSystemUpdateDetected(object sender, FileSystemEventArgs e)
|
||||
@@ -78,17 +106,16 @@ namespace SoundBoard
|
||||
|
||||
private void CheckForDisabledListBox(object sender, EventArgs e)
|
||||
{
|
||||
ListBox listBoxEntity = new ListBox();
|
||||
try
|
||||
{
|
||||
listBoxEntity = (ListBox)soundboardTabControl.SelectedTab.Controls[0];
|
||||
listViewEntity = (ListView)soundboardTabControl.SelectedTab.Controls[0];
|
||||
}
|
||||
catch (Exception spam)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (listBoxEntity.Enabled == false)
|
||||
if (listViewEntity.Enabled == false)
|
||||
{
|
||||
mainMenuFileShowOnDisk.Enabled = false;
|
||||
btnRandom.Enabled = false;
|
||||
@@ -107,9 +134,9 @@ namespace SoundBoard
|
||||
|
||||
foreach (TabPage tabPage in soundboardTabControl.TabPages)
|
||||
{
|
||||
foreach (ListBox listBox in tabPage.Controls)
|
||||
foreach (ListView listView in tabPage.Controls)
|
||||
{
|
||||
listBox.Dispose();
|
||||
listView.Dispose();
|
||||
}
|
||||
tabPage.Dispose();
|
||||
}
|
||||
@@ -122,7 +149,7 @@ namespace SoundBoard
|
||||
{
|
||||
CreateUITabs(Path.GetFileName(files), files);
|
||||
}
|
||||
//check to see if the listBox is empty
|
||||
//check to see if the listView is empty
|
||||
if (soundboardTabControl.SelectedTab.Controls[0].Enabled == true)
|
||||
{
|
||||
mainMenuFileShowOnDisk.Enabled = true;
|
||||
@@ -137,12 +164,14 @@ namespace SoundBoard
|
||||
|
||||
private void CreateUITabs(string tabName, string directoryPath)
|
||||
{
|
||||
//add tabs dynamically
|
||||
//Add tabs dynamically
|
||||
int soundControlHeight = soundboardTabControl.Height;
|
||||
int soundControlWidth = soundboardTabControl.Width;
|
||||
string[] directoryFiles; //files in the target directory
|
||||
string[] directoryFiles; //Files in the target directory
|
||||
TabPage tab = new TabPage();
|
||||
ListBox localListBox = new ListBox();
|
||||
ListView localListView = new ListView();
|
||||
string[] columnNames = new string[2]; //Perhaps include a compatibility column to flag files that cause errors?
|
||||
ListViewItem listItemObject;
|
||||
|
||||
if (soundboardTabControl.Controls.ContainsKey(tabName.Replace(" ", "") + "Tab"))
|
||||
{
|
||||
@@ -150,38 +179,60 @@ namespace SoundBoard
|
||||
}
|
||||
else
|
||||
{
|
||||
tab.Text = tabName; //display the folder's full name to the user
|
||||
//Construct the TabPage and its properties
|
||||
tab.Text = tabName; //Display the folder's full name to the user
|
||||
tab.Name = tabName.Replace(" ", "") + "Tab"; //create a legal name for the tab's (name) property
|
||||
tab.Height = soundControlHeight;
|
||||
tab.Height = soundControlWidth;
|
||||
soundboardTabControl.Controls.Add(tab);
|
||||
|
||||
localListBox.Height = soundControlHeight - 25;
|
||||
localListBox.Width = soundControlWidth - 5;
|
||||
localListBox.Name = tabName.Replace(" ", "") + "ListBox";
|
||||
tab.Controls.Add(localListBox);
|
||||
localListBox.Click += new EventHandler((sender, e) => ListBoxOnLeftClick(sender, e, localListBox)); //create event handler for the lsit box and pass the object in
|
||||
//Construct the ListView and its properties
|
||||
localListView.Height = soundControlHeight - 25;
|
||||
localListView.Width = soundControlWidth - 5;
|
||||
localListView.Name = tabName.Replace(" ", "") + "ListView";
|
||||
localListView.FullRowSelect = true;
|
||||
localListView.MultiSelect = false;
|
||||
localListView.GridLines = true;
|
||||
localListView.View = View.Details;
|
||||
localListView.Activation = ItemActivation.OneClick;
|
||||
localListView.TabStop = false;
|
||||
tab.Controls.Add(localListView);
|
||||
localListView.Columns.Add("File Name", 340, HorizontalAlignment.Left);
|
||||
localListView.Columns.Add("File Ext", 50, HorizontalAlignment.Left);
|
||||
localListView.ItemActivate += new EventHandler((sender, e) => ListViewOnLeftClick(sender, e, localListView));
|
||||
}
|
||||
|
||||
directoryFiles = Directory.GetFiles(Path.GetFullPath(directoryPath));
|
||||
|
||||
foreach (string files in directoryFiles)
|
||||
foreach (string file in directoryFiles)
|
||||
{
|
||||
switch (Path.GetExtension(files))//check to make sure the file is a sound file
|
||||
switch (Path.GetExtension(file).ToLower())
|
||||
{
|
||||
case ".wav":
|
||||
//Only include sound files in the ListView
|
||||
case ".mp3":
|
||||
localListBox.Items.Add(Path.GetFileNameWithoutExtension(files));
|
||||
case ".wav":
|
||||
columnNames[0] = Path.GetFileNameWithoutExtension(file);
|
||||
columnNames[1] = Path.GetExtension(file);
|
||||
listItemObject = new ListViewItem(columnNames);
|
||||
localListView.Items.Add(listItemObject);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (localListBox.Items.Count == 0)
|
||||
if (localListView.Items.Count == 0)
|
||||
{
|
||||
localListBox.Items.Add("No sound files found in the " + tabName + " directory.");
|
||||
localListBox.Enabled = false;
|
||||
if (tab.Name == "WorkingDirectoryTab")
|
||||
{
|
||||
localListView.Items.Add("No sound files detected in the application's working directory.");
|
||||
}
|
||||
else
|
||||
{
|
||||
localListView.Items.Add("No sound files detected in the " + tabName + " directory");
|
||||
}
|
||||
|
||||
localListView.Enabled = false;
|
||||
if (soundboardTabControl.SelectedIndex == 0)
|
||||
{
|
||||
mainMenuFileShowOnDisk.Enabled = false;
|
||||
@@ -190,59 +241,59 @@ namespace SoundBoard
|
||||
}
|
||||
}
|
||||
|
||||
private void ListBoxOnLeftClick(object sender, EventArgs e, ListBox list)
|
||||
private void ListViewOnLeftClick(object sender, EventArgs e, ListView listView)
|
||||
{
|
||||
//check to make sure something is actually selected
|
||||
if (list.SelectedItem == null)
|
||||
if (btnRandom.Enabled == false)
|
||||
{
|
||||
//If the btnRandom button is disabled that means a randomise function is running, so don't interupt it
|
||||
return;
|
||||
}
|
||||
//get the file's location on disk, double back if it's not a .wav file
|
||||
string fileName;
|
||||
string fileExt;
|
||||
string fileLocation;
|
||||
WMPLib.IWMPPlaylist _playList = Player.playlistCollection.newPlaylist("myPlayList"); //build the playlist object
|
||||
|
||||
fileName = listView.SelectedItems[0].SubItems[0].Text;
|
||||
fileExt = listView.SelectedItems[0].SubItems[1].Text;
|
||||
|
||||
if (soundboardTabControl.SelectedIndex == 0)
|
||||
{
|
||||
fileLocation = _workingDirectory + "\\" + list.SelectedItem.ToString() + ".wav";
|
||||
if (!File.Exists(fileLocation))
|
||||
if (File.Exists(_workingDirectory + "\\" + fileName + fileExt))
|
||||
{
|
||||
fileLocation = _workingDirectory + "\\" + list.SelectedItem.ToString() + ".mp3";
|
||||
fileLocation = _workingDirectory + "\\" + fileName + fileExt;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fileLocation = _workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + list.SelectedItem.ToString() + ".wav";
|
||||
if (!File.Exists(fileLocation))
|
||||
if (File.Exists(_workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + fileName + fileExt))
|
||||
{
|
||||
fileLocation = _workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + list.SelectedItem.ToString() + ".mp3";
|
||||
fileLocation = _workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + fileName + fileExt;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (File.Exists(fileLocation))//check for the file's existance
|
||||
{
|
||||
PlaySoundFile(fileLocation, list.SelectedItem.ToString()); //if the file exists then play it
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("The file '" + list.SelectedItem.ToString() + "' couldn't be found.", "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayRandomSounds()
|
||||
{
|
||||
PlaySoundFile(fileLocation);
|
||||
}
|
||||
|
||||
private void btnRandom_Click(object sender, EventArgs e)
|
||||
{
|
||||
int iterations = (int)randomIterationNumericUpDown.Value;
|
||||
listBoxEntity = (ListBox)soundboardTabControl.SelectedTab.Controls[0];
|
||||
listViewEntity = (ListView)soundboardTabControl.SelectedTab.Controls[0];
|
||||
Player.currentPlaylist.clear();
|
||||
|
||||
if (listBoxEntity.Enabled == false)
|
||||
//DOuble check to see if the ListView has any items that can be played
|
||||
if (listViewEntity.Enabled == false)
|
||||
{
|
||||
//the ListBox is disabled and therefore contains no sounds, so return
|
||||
//the ListView disabled and therefore contains no sounds, so return
|
||||
return;
|
||||
}
|
||||
//disable the Random Button and the NumericUpDown box
|
||||
//disable the Random Button and the loop checkbox
|
||||
btnRandom.Enabled = false;
|
||||
randomIterationNumericUpDown.Enabled = false;
|
||||
loopSelectedSoundCheckBox.Enabled = false;
|
||||
|
||||
if (mainMenuPlayAll.Checked == true)
|
||||
@@ -252,101 +303,82 @@ namespace SoundBoard
|
||||
{
|
||||
btnRandom.Enabled = true;
|
||||
}
|
||||
randomIterationNumericUpDown.Enabled = true;
|
||||
loopSelectedSoundCheckBox.Enabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
string fileLocation;
|
||||
string fileLocation = "";
|
||||
string fileExt;
|
||||
string fileName;
|
||||
//Check to see if the selected tab is the working directory's tab
|
||||
if (soundboardTabControl.SelectedIndex == 0)
|
||||
{
|
||||
listBoxEntity.SelectedIndex = randomNum.Next(listBoxEntity.Items.Count);
|
||||
if (File.Exists(_workingDirectory + "\\" + listBoxEntity.SelectedItem.ToString() + ".wav"))
|
||||
listViewEntity.Items[randomNum.Next(listViewEntity.Items.Count)].Selected = true;
|
||||
fileName = listViewEntity.SelectedItems[0].SubItems[0].Text;
|
||||
fileExt = listViewEntity.SelectedItems[0].SubItems[1].Text;
|
||||
|
||||
if (File.Exists(_workingDirectory + "\\" + fileName + fileExt))
|
||||
{
|
||||
fileLocation = _workingDirectory + "\\" + listBoxEntity.SelectedItem.ToString() + ".wav";
|
||||
}
|
||||
else if (File.Exists(_workingDirectory + "\\" + listBoxEntity.SelectedItem.ToString() + ".mp3"))
|
||||
{
|
||||
fileLocation = _workingDirectory + "\\" + listBoxEntity.SelectedItem.ToString() + ".mp3";
|
||||
fileLocation = _workingDirectory + "\\" + fileName + fileExt;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("The file '" + listBoxEntity.SelectedItem.ToString() + "' couldn't be found.", "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("The file couldn't be found.", "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
if (soundboardTabControl.SelectedTab.Controls[0].Enabled == true)
|
||||
{
|
||||
btnRandom.Enabled = true;
|
||||
}
|
||||
|
||||
randomIterationNumericUpDown.Enabled = true;
|
||||
loopSelectedSoundCheckBox.Enabled = true;
|
||||
Player.currentPlaylist.clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
listBoxEntity.SelectedIndex = randomNum.Next(listBoxEntity.Items.Count);
|
||||
if (File.Exists(_workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + listBoxEntity.SelectedItem.ToString() + ".wav"))
|
||||
listViewEntity.Items[randomNum.Next(listViewEntity.Items.Count)].Selected = true;
|
||||
fileName = listViewEntity.SelectedItems[0].SubItems[0].Text;
|
||||
fileExt = listViewEntity.SelectedItems[0].SubItems[1].Text;
|
||||
|
||||
if (File.Exists(_workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + fileName + fileExt))
|
||||
{
|
||||
fileLocation = _workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + listBoxEntity.SelectedItem.ToString() + ".wav";
|
||||
}
|
||||
else if (File.Exists(_workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + listBoxEntity.SelectedItem.ToString() + ".mp3"))
|
||||
{
|
||||
fileLocation = _workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + listBoxEntity.SelectedItem.ToString() + ".mp3";
|
||||
fileLocation = _workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + fileName + fileExt;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("The file '" + listBoxEntity.SelectedItem.ToString() + "' couldn't be found.", "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show(_workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + fileName + fileExt, "Not Found");
|
||||
if (soundboardTabControl.SelectedTab.Controls[0].Enabled == true)
|
||||
{
|
||||
btnRandom.Enabled = true;
|
||||
}
|
||||
|
||||
randomIterationNumericUpDown.Enabled = true;
|
||||
loopSelectedSoundCheckBox.Enabled = true;
|
||||
return;
|
||||
Player.currentPlaylist.clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
//play the sound file
|
||||
PlaySoundFile(fileLocation, listBoxEntity.SelectedItem.ToString(), false);
|
||||
//load the player with the randomly chosen sounds
|
||||
enumeratePlayerPlayList(fileLocation);
|
||||
}
|
||||
//renable the controls
|
||||
if (soundboardTabControl.SelectedTab.Controls[0].Enabled == true)
|
||||
{
|
||||
btnRandom.Enabled = true;
|
||||
}
|
||||
randomIterationNumericUpDown.Enabled = true;
|
||||
loopSelectedSoundCheckBox.Enabled = true;
|
||||
//prepare the Player object and play the playlist
|
||||
btnRandom.Enabled = false;
|
||||
Player.settings.setMode("loop", false);
|
||||
PlayPlayList();
|
||||
}
|
||||
|
||||
private void PlaySoundFile(string fileLocation, string fileName, bool willLoop = true)
|
||||
private void PlaySoundFile(string fileLocation)
|
||||
{
|
||||
//Set the file to be played's location
|
||||
Player.URL = fileLocation;
|
||||
|
||||
|
||||
//Attempt to play the file
|
||||
try
|
||||
{
|
||||
if (Player.settings.getMode("loop"))
|
||||
{
|
||||
if (!willLoop)
|
||||
{
|
||||
Player.settings.setMode("loop", false);
|
||||
Player.controls.play();
|
||||
}
|
||||
else
|
||||
{
|
||||
Player.controls.play();
|
||||
}
|
||||
Player.settings.setMode("loop", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Player.controls.play();
|
||||
}
|
||||
Player.controls.play();
|
||||
}
|
||||
catch (InvalidOperationException Ex)
|
||||
{
|
||||
MessageBox.Show("The file '" + fileName + "' couldn't be played.", "Invalid Sound File", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("The file couldn't be played.", "Invalid Sound File", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -360,15 +392,16 @@ namespace SoundBoard
|
||||
else
|
||||
{
|
||||
Player.settings.setMode("loop", false);
|
||||
Player.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void playRandomSoundBothColumns(int iterations)
|
||||
{
|
||||
int tempRandomNumber;
|
||||
string fileLocation;
|
||||
listBoxEntity = (ListBox)soundboardTabControl.SelectedTab.Controls[0];
|
||||
string fileLocation = "";
|
||||
string fileName;
|
||||
string fileExt;
|
||||
listViewEntity = (ListView)soundboardTabControl.SelectedTab.Controls[0];
|
||||
|
||||
for (int i = 0; i <= iterations; i++)
|
||||
{
|
||||
@@ -379,13 +412,13 @@ namespace SoundBoard
|
||||
soundboardTabControl.SelectedIndex = tempRandomNumber;
|
||||
if (soundboardTabControl.SelectedIndex == 0)
|
||||
{
|
||||
if (File.Exists(_workingDirectory + "\\" + "\\" + listBoxEntity.SelectedItem.ToString() + ".wav"))
|
||||
listViewEntity.Items[randomNum.Next(listViewEntity.Items.Count)].Selected = true;
|
||||
fileName = listViewEntity.SelectedItems[0].SubItems[0].Text;
|
||||
fileExt = listViewEntity.SelectedItems[0].SubItems[1].Text;
|
||||
|
||||
if (File.Exists(_workingDirectory + "\\" + fileName + fileExt))
|
||||
{
|
||||
fileLocation = _workingDirectory + "\\" + "\\" + listBoxEntity.SelectedItem.ToString() + ".wav";
|
||||
}
|
||||
else if (File.Exists(_workingDirectory + "\\" + listBoxEntity.SelectedItem.ToString() + ".mp3"))
|
||||
{
|
||||
fileLocation = _workingDirectory + "\\" + "\\" + listBoxEntity.SelectedItem.ToString() + ".mp3";
|
||||
fileLocation = _workingDirectory + "\\" + fileName + fileExt;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -394,58 +427,50 @@ namespace SoundBoard
|
||||
}
|
||||
else
|
||||
{
|
||||
soundboardTabControl.SelectedIndex = tempRandomNumber;
|
||||
listBoxEntity.SelectedIndex = randomNum.Next(listBoxEntity.Items.Count);
|
||||
if (File.Exists(_workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + listBoxEntity.SelectedItem.ToString() + ".wav"))
|
||||
listViewEntity.Items[randomNum.Next(listViewEntity.Items.Count)].Selected = true;
|
||||
fileName = listViewEntity.SelectedItems[0].SubItems[0].Text;
|
||||
fileExt = listViewEntity.SelectedItems[0].SubItems[1].Text;
|
||||
|
||||
if (File.Exists(_workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + fileName + fileExt))
|
||||
{
|
||||
fileLocation = _workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + listBoxEntity.SelectedItem.ToString() + ".wav";
|
||||
}
|
||||
else if (File.Exists(_workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + listBoxEntity.SelectedItem.ToString() + ".mp3"))
|
||||
{
|
||||
fileLocation = _workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + listBoxEntity.SelectedItem.ToString() + ".mp3";
|
||||
fileLocation = _workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + fileName + fileExt;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
PlaySoundFile(fileLocation, soundboardTabControl.SelectedTab.Text, false);
|
||||
enumeratePlayerPlayList(fileLocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
playRandomSoundBothColumns(iterations);
|
||||
playRandomSoundBothColumns(iterations - i);
|
||||
}
|
||||
}
|
||||
PlayPlayList();
|
||||
}
|
||||
|
||||
private void mainMenuFileShowOnDisk_Click(object sender, EventArgs e)
|
||||
{
|
||||
listBoxEntity = (ListBox)soundboardTabControl.SelectedTab.Controls[0];
|
||||
if ((String)listBoxEntity.SelectedItem == null)
|
||||
{
|
||||
MessageBox.Show("No sound file selected...", soundboardTabControl.SelectedTab.Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
listViewEntity = (ListView)soundboardTabControl.SelectedTab.Controls[0];
|
||||
string fileName;
|
||||
string fileExt;
|
||||
|
||||
fileName = listViewEntity.SelectedItems[0].SubItems[0].Text;
|
||||
fileExt = listViewEntity.SelectedItems[0].SubItems[1].Text;
|
||||
|
||||
if (soundboardTabControl.SelectedIndex == 0)
|
||||
{
|
||||
if (File.Exists(_workingDirectory + "\\" + listBoxEntity.SelectedItem.ToString() + ".wav"))
|
||||
if (File.Exists(_workingDirectory + "\\" + fileName + fileExt))
|
||||
{
|
||||
Process.Start("explorer.exe", "/select, " + '"' + _workingDirectory + "\\" + listBoxEntity.SelectedItem.ToString() + ".wav" + '"');
|
||||
}
|
||||
else
|
||||
{
|
||||
Process.Start("explorer.exe", "/select, " + '"' + _workingDirectory + "\\" + listBoxEntity.SelectedItem.ToString() + ".mp3" + '"');
|
||||
Process.Start("explorer.exe", "/select, \"" + _workingDirectory + "\\" + fileName + fileExt + "\"");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (File.Exists(_workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + listBoxEntity.SelectedItem.ToString() + ".wav"))
|
||||
if (File.Exists(_workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + fileName + fileExt))
|
||||
{
|
||||
Process.Start("explorer.exe", "/select, " + '"' + _workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + listBoxEntity.SelectedItem.ToString() + ".wav" + '"');
|
||||
}
|
||||
else
|
||||
{
|
||||
Process.Start("explorer.exe", "/select, " + '"' + _workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + listBoxEntity.SelectedItem.ToString() + ".mp3" + '"');
|
||||
Process.Start("explorer.exe", "/select, \"" + _workingDirectory + "\\" + soundboardTabControl.SelectedTab.Text + "\\" + fileName + fileExt + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -461,5 +486,29 @@ namespace SoundBoard
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void enumeratePlayerPlayList(string fileLocation)
|
||||
{
|
||||
WMPLib.IWMPMedia playList = Player.newMedia(fileLocation);
|
||||
Player.currentPlaylist.appendItem(playList);
|
||||
}
|
||||
|
||||
private void PlayPlayList()
|
||||
{
|
||||
Player.controls.play();
|
||||
}
|
||||
//Handles all messages being sent to controls
|
||||
public bool PreFilterMessage(ref Message m)
|
||||
{
|
||||
Keys keyCode = (Keys)(int)m.WParam & Keys.KeyCode;
|
||||
bool retVal = false;
|
||||
|
||||
if (m.Msg == WM_KEYDOWN)
|
||||
{
|
||||
// Handle the keypress
|
||||
label1.Text = keyCode.ToString();
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user