private void button1_Click(object sender, EventArgs e) { MP3Player mp3 = new MP3Player(); mp3.Close(); this.Close(); }
private void checkBox1_CheckedChanged(object sender, EventArgs e) { MP3Player mp3 = new MP3Player(); if (checkBox1.Checked==true) { mp3.Open("work.mp3"); mp3.Play(true); } else mp3.Close(); }
//keyboard controls: rotate, ↓, →, ↑. private void Form1_KeyPress(object sender, KeyPressEventArgs e) { //tetris controls int iLose, iScore; iScore = Game.GetScore(); iLose = Game.GetLose(); //w -rotate if (e.KeyChar == 119) { Game.RotateBlock(); pBox1.Invalidate(); pBox2.Invalidate(); } //a -left if (e.KeyChar == 97) { Game.MoveBlockLeft(); pBox1.Invalidate(); pBox2.Invalidate(); } //s -down if (e.KeyChar == 115) { if (iScore > Game.GetHighScore()) { Game.SetHighScore(iScore); lblHighScore.Text = Game.GetHighScore().ToString(); } Game.MoveBlockDown(); lblScore.Text = iScore.ToString(); pBox1.Invalidate(); pBox2.Invalidate(); } //d - right else if (e.KeyChar == 100) { Game.MoveBlockRight(); pBox1.Invalidate(); pBox2.Invalidate(); } //music controls if (e.KeyChar == 49) { M.Close(); string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Music\Tetris Remix.mp3"); M.Open(path); M.Play(true); } if (e.KeyChar == 50) { M.Close(); string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Music\Mount and Blade.mp3"); M.Open(path); M.Play(true); } if (e.KeyChar == 51) { M.Close(); string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Music\Rules of Nature.mp3"); M.Open(path); M.Play(true); } if (e.KeyChar == 52) { M.Close(); string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Music\Smooth Criminal.mp3"); M.Open(path); M.Play(true); } if (e.KeyChar == 53) { M.Close(); string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Music\This is Our Time.mp3"); M.Open(path); M.Play(true); } if (e.KeyChar == 54) { M.Close(); string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Music\Ding Dong Song.mp3"); M.Open(path); M.Play(true); } if (e.KeyChar == 55) { M.Close(); string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Music\Gaben.mp3"); M.Open(path); M.Play(true); } if (e.KeyChar == 56) { M.Close(); string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Music\Final Countdown.mp3"); M.Open(path); M.Play(true); } if (e.KeyChar == 57) { M.Close(); string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Music\Yee.mp3"); M.Open(path); M.Play(true); } if (e.KeyChar == 48) { M.Close(); string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Music\Tetris.mp3"); M.Open(path); M.Play(true); } }
/// <summary> /// Stops every sound from the program /// </summary> /// <param name="sender"></param> private void BtnStopSounds(object sender) { mp3Player.Close(); }