Hello fellow users of CodeProject!
So basically I have completed one of my first projects & I would like to add some features, the thing is that I dont really know how to add this one "KeyFeature" to my app, I think I know what needs to be done but not sure, would just like to know if my way of thinking makes any sence when it comes to this.
So here it is..
I recently created a SoundBoard that uses resources I added to Visual Studio (Audio Files) & they are connected to buttons so when I press a button it plays a Sound,(Providing the code down below) it is not WMP(Windows Media Player) driven & by that I mean that I did not use the built in Windows Media Player Feature because that made things very complicated.
so this is what I would like to do, but I wouldnt want to do it if there is a easier way of doing it.
I would like to add a trackBar that allows me to adjust the volume of the whole app & what I think I would need to do is implement a code that changes the windows system volume for that specific application when the user is making changes to the trackBar.
Thats pretty much how I was thinking of going by with creating this feature, does it sound cray? Am I trying to be too advanced here? What way would you go by of making something like this?
(If this is a inappropriate question I will delete it!)
Regards!
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;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.KeyPreview = true;
this.KeyDown += new KeyEventHandler(button1_KeyDown);
this.KeyDown += new KeyEventHandler(button2_KeyDown);
this.KeyDown += new KeyEventHandler(button3_KeyDown);
this.KeyDown += new KeyEventHandler(button4_KeyDown);
}
private void button1_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.cow;
player.Play();
}
private void button2_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.owl;
player.Play();
}
private void button3_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.ram;
player.Play();
}
private void button4_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.water;
player.Play();
}
private void button5_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.wind;
player.Play();
}
private void button6_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.fire;
player.Play();
}
private void button7_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.car;
player.Play();
}
private void button8_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.horn;
player.Play();
}
private void button9_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.happy;
player.Play();
}
private void button10_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.farm;
player.Play();
}
private void button11_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.pig;
player.Play();
}
private void button12_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.horse;
player.Play();
}
private void button1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode.ToString() == "F1")
{
button1_Click(null, null);
}
}
private void button2_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode.ToString() == "F2")
{
button2_Click(null, null);
}
}
private void button14_Click(object sender, EventArgs e)
{
panel1.Visible = true;
}
private void beep_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.beep;
player.Play();
}
private void plate_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.office;
player.Play();
}
private void Fatality_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.bird;
player.Play();
}
private void FHRITP_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.shark;
player.Play();
}
private void Finish_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.race;
player.Play();
}
private void F***_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.themesong;
player.Play();
}
private void Headshot_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.bitgame;
player.Play();
}
private void Nathan_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.harry;
player.Play();
}
private void Nuke_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.nick;
player.Play();
}
private void Sadhorn_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.cash;
player.Play();
}
private void Shots_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.eagle;
player.Play();
}
private void Sonata_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.elephant;
player.Play();
}
private void Surprise_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.tiger;
player.Play();
}
private void Weed_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.duck;
player.Play();
}
private void button3_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode.ToString() == "F3")
{
button3_Click(null, null);
}
}
private void button4_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode.ToString() == "F4")
{
button3_Click(null, null);
}
}
private void Previous_Click(object sender, EventArgs e)
{
panel1.Visible = false;
}
}
}