예제 #1
0
파일: Form1.cs 프로젝트: PaDiOc18/CETYS
 public void ReproducirMusica()
 {   ///Cambiar Ruta de diferente computadora
     player1.SoundLocation = "C:/Users/Pablo Diaz/Desktop/PROGRAMAS C# METODOS DE PROGRAMACION/RandomFacil/RandomFacil/Resources/Ninja.wav";
     player1.Play();
     if (timer1.Enabled == false)
     {
         player1.Stop();
     }
 }
예제 #2
0
        private void lbPvsP_Click(object sender, EventArgs e)
        {
            Form1 fr = new Form1();

            Properties.Settings.Default.PvsP = true;
            this.Hide();
            sound.Stop();
            fr.ShowDialog();
            this.Show();
            sound.Play();
        }
예제 #3
0
 /// <summary>
 /// Toggles background music on and off
 /// </summary>
 public void toggleMusic()
 {
     //Loops music in background, in separate thread,  if music setting is on
     if ((bool)Settings.Default["Music"])
     {
         Task.Factory.StartNew(() => { sp.PlayLooping(); });
     }
     else
     {
         sp.Stop();
     }
 }
예제 #4
0
 private void radioClose_CheckedChanged(object sender, EventArgs e)
 {
     if (this.radioClose.Checked)
     {
         this.radioGroupBox.Text = "开/关";
         this.timerUtil.Enabled  = false;
         this.timerUtil.Stop();
         this.timerDing.Stop();
         sp.Stop();
         spDing.Stop();
     }
 }
예제 #5
0
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            if (m.Msg == WM_HOTKEY && (int)m.WParam == 1)
            {
                player.SoundLocation = @"whyworry.wav";
                player.Play();
            }


            if (m.Msg == WM_HOTKEY && (int)m.WParam == 2)
            {
                player.SoundLocation = @"suck.wav";
                player.Play();
            }
            if (m.Msg == WM_HOTKEY && (int)m.WParam == 5)
            {
                player.SoundLocation = @"mii.wav";
                player.Play();
            }

            if (m.Msg == WM_HOTKEY && (int)m.WParam == 6)
            {
                player.SoundLocation = @"remember.wav";
                player.Play();
            }
            if (m.Msg == WM_HOTKEY && (int)m.WParam == 3)
            {
                player.Stop();
            }
            if (m.Msg == WM_HOTKEY && (int)m.WParam == 4)
            {
            }
        }
예제 #6
0
파일: Form1.cs 프로젝트: benhunt12/CompE361
        private void Stop()
        {
            string soundfile = @"C:\Users\benja\Desktop\Alien_AlarmDrum-KevanGC-893953959.wav";
            var    sound     = new System.Media.SoundPlayer(soundfile);

            sound.Stop();
        }
예제 #7
0
        }//Одноразовая проверка состояния блокировки

        public void alarm()
        {
cx:
            string Check = new System.Net.WebClient().DownloadString(textBox1.Text);

            System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:\bsound.wav");

            bool x = true;

            while (x)

            {
                if (Check.Contains("System blocked"))
                {
                    Thread.Sleep(100);
                    label1.ForeColor = Color.Red;
                    label1.Text      = "ТРЕВОГА!!!";
                    player.Play();
                    System.Threading.Thread.Sleep(20000);
                    player.Stop();

                    goto cx;
                }
                else
                {
                    label1.ForeColor = Color.LightGreen;
                    label1.Text      = "ВСЁ В ПОРЯДКЕ";
                    System.Threading.Thread.Sleep(1000);
                    goto cx;
                }
            }
        }//метод постоянного контроля состояния
예제 #8
0
        private void PlayWaverFile(string filePath, bool playLooping)
        {
            if (_soundPlay != null)
            {
                _soundPlay.Stop();
                _soundPlay.Dispose();
                _soundPlay = null;
            }

            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }

            _soundPlay = new SM.SoundPlayer(filePath);

            if (playLooping)
            {
                _soundPlay.PlayLooping();
            }
            else
            {
                _soundPlay.Play();
            }
        }
 private void muteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // acts as a mute button and stops the music.
     backSound.Stop();
     resumeToolStripMenuItem.Enabled = true;
     muteToolStripMenuItem.Enabled   = false;
 }
예제 #10
0
        private void timer_count_Tick(object sender, EventArgs e)
        {
            System.Media.SoundPlayer player_1
                = new System.Media.SoundPlayer(@"C:\Users\M0015\Desktop\pic\sound\1792.wav");
            System.Media.SoundPlayer player_2
                = new System.Media.SoundPlayer(@"C:\Users\M0015\Desktop\pic\sound\786.wav");
            String str = ts_count_tmp.Hours + ":" + ts_count_tmp.Minutes + ":" + ts_count_tmp.Seconds;

            label1.Text = str;                                           //label1用来显示剩余的时间

            ts_count_tmp = ts_count_tmp.Subtract(new TimeSpan(0, 0, 1)); //每隔一秒减去一秒

            if (ts_count_tmp.TotalSeconds < 3.0)                         //当倒计时剩余3s时
            {
                player_1.Play();
            }

            if (ts_count_tmp.TotalSeconds < 0.0)//当倒计时完毕
            {
                timer1.Enabled = false;
                player_1.Stop();
                player_2.Play();
                MessageBox.Show("时间到!");//提示时间到
            }
        }
예제 #11
0
 // Yoverion Kun's YouTube
 private void button1_Click(object sender, EventArgs e)
 {
     SoundPlayer backgroundSound = new SoundPlayer(Program.ResourcesFolder + "background.mp3");
     backgroundSound.Stop();
     Yov yov = new Yov();
     yov.Show();
 }
예제 #12
0
파일: Game.cs 프로젝트: zaba37/Skokoban_KCK
        public Game(string mapPath)
        {
            totalPoints = 0;

            totalRounds = 9; //TU ILE MAP MA GRA TRZEBA WPISAC

            typewriter = Constants.getSoundPlayerInstance();
            typewriter.Stop();
            typewriter.SoundLocation = "step.wav";

            isNewLevel = true;

            currentPositionInPauseMenu = 0;

            timerPauseMenu = new Timer(500);
            timerPauseMenu.AutoReset = true;
            timerPauseMenu.Elapsed += (s, e) => pasueMenuTick(e);
            timerPauseMenu.Start();

            heroObject = new Hero();
            boxObject = new Box();
            pointObject = new Point();
            floorObject = new Floor();
            wallObject = new Wall();

            mapNumber = 1;
            writelock = new object();
            initMap(mapPath, true);
        }
예제 #13
0
파일: Form1.cs 프로젝트: dushesss/Tetris2
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            sp2.Stop();
            this.Hide();
            Form2 form = new Form2();

            form.Show();
        }
예제 #14
0
        private void btnExit_Click(object sender, EventArgs e)
        {
            SoundPlayer player = new System.Media.SoundPlayer();

            player.Stop();
            timer.Stop();
            this.Close();
        }
예제 #15
0
 private void Exits_Click(object sender, EventArgs e)
 {
     sPlay.Stop();
     notifyIcon1.Visible = false;
     Close();
     Dispose();
     System.Environment.Exit(0);
 }
예제 #16
0
        private void button2_Click(object sender, EventArgs e)
        {
            System.Media.SoundPlayer player1 = new System.Media.SoundPlayer(@"C:\Users\FOladiji\Engineering45\WEEK3\Day5\Same Old Story.wav");
            player1.Stop();
            Medium me = new Medium();

            me.Show();
            Hide();
        }
예제 #17
0
        private void button3_Click(object sender, EventArgs e)
        {
            System.Media.SoundPlayer player1 = new System.Media.SoundPlayer(@"C:\Users\FOladiji\Engineering45\WEEK3\Day5\Same Old Story.wav");
            player1.Stop();
            HardLevel hd = new HardLevel();

            hd.Show();
            Hide();
        }
        } // resumes the match is it was paused

        public static void endMatch() // ends the match's timer and will handle other end match events
        {
            if (matchState != 0)             // this will run as long as the match state isnt already 0
            {
                gameTimer.Stop();            // stop the game timer
                Console.WriteLine("Game timer stopped since match is ending.");
                music.Stop();                // stop the audio from playing
                buzzer.Play();               // play that sicc buzzer sound
                matchState  = 0;             // set the match state to 0
                currentTime = 0.0f;          // set match time to 0
                lastTeam1   = Display.team1; // move the name of Team 1 to a internal variable within this class so that it is sent with the score data, since the user may change it before that happens
                lastTeam2   = Display.team2; // move the name of Team 2 to a internal variable within this class so that it is sent with the score data, since the user may change it before that happens
                if (doSend)
                {
                    Networking.sendData(Display.team1Score + ":" + Display.team2Score + ":" + lastTeam1 + ":" + lastTeam2);
                }
            }
        }
예제 #19
0
        private void play_basic(String note_octave)
        {
            pl.Stop();



            pl.SoundLocation = getAudioPath(note_octave);

            pl.Play();
        }
예제 #20
0
파일: Form1.cs 프로젝트: diceryas/csharp
 private void button2_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("是否退出?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)==DialogResult.Yes)
     {
         this.panel1.Enabled=false;
         SoundPlayer sp = new SoundPlayer("music.wav");  //播放音乐
         sp.Stop();
         MessageBox.Show("双击恢复音乐播放器!!!");
     }
 }
예제 #21
0
        // removes a life and checks to see when the user has lost all his lives
        private int UpdateLives(ref int livesRemaining)
        {
            livesRemaining = livesRemaining - 1;

            if (livesRemaining == 0)
            {
                //  stop the timer
                gameTimer.Stop();
                // stops the background music
                backSound.Stop();
                // shows the game over screen
                LoseScreen theForm = new LoseScreen();
                this.Hide();
                theForm.ShowDialog();
                this.Close();
            }

            return(livesRemaining);
        }
예제 #22
0
        private void BtnStop_Click(object sender, EventArgs e)
        {
            player.Stop();

            BtnPlay.Visible = true;
            BtnStop.Enabled = false;

            BtnPlay.Enabled = true;
            BtnStop.Visible = false;
        }
예제 #23
0
파일: Form1.cs 프로젝트: Persz/SecureApe
 private void cmdSTOPsnd_Click(object sender, EventArgs e)
 {
     SCP.Stop();
     Imperial1.Stop();
     Imperial2.Stop();
     Imperial3.Stop();
     Inter1.Stop();
     Inter2.Stop();
     Inter3.Stop();
 }
예제 #24
0
 public void XuLyNhac()
 {
     if (Nhacplay == true)
     {
         nhac.PlayLooping();
     }
     else
     {
         nhac.Stop();
     }
 }
예제 #25
0
 public static void GameSound(bool isOn)
 {
     SoundPlayer player = new SoundPlayer(@"../../Sounds/Background Music - DJ Sona Ethereal.wav");
     if (!isOn)
     {
         player.Stop();
     }
     else
     {
         player.PlayLooping();
     }
 }
예제 #26
0
 private static void InternalStop(SoundPlayer sound)
 {
     new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert();
     try
     {
         sound.Stop();
     }
     finally
     {
         CodeAccessPermission.RevertAssert();
     }
 }
예제 #27
0
파일: Sounds.cs 프로젝트: hrturlakov/Froggy
 public static void MainMenuSound(bool isOn)
 {
     SoundPlayer player = new SoundPlayer(@"..\..\music\02-overworld.wav");
     if (isOn)
     {
         player.Stop();
     }
     else
     {
         player.PlayLooping();
     }
 }
        protected void Button2_Click(object sender, EventArgs e)
        {
            //strängen style tilldelas länk till vald layout
            string style = "<LINK href=\"/1dv406/th222fa/Content/Style.css\" type=\"text/css\" rel=\"stylesheet\">";

            //stylesheetlänken i min masterpage sätts till vald layout
            Literal1.Text = style;
            Page.SetTempData("Layout", Literal1.Text);
            //SoundPlayer sound = new SoundPlayer(@"Content\Crazy.wav");
            string audioFile;
            audioFile = System.IO.Path.Combine(AppDomain.CurrentDomain.GetData("APPBASE").ToString(), @"Content\Crazy.wav");
            SoundPlayer sound = new SoundPlayer(audioFile);
            sound.Stop();
        }
예제 #29
0
        private void button2_Click(object sender, EventArgs e)
        {
            string play_file = power_APP.Properties.Settings.Default.clock_user;

            if (play_file.Contains(".mp3"))
            {
                Form1.wplayer.controls.stop();               
            }
            else
            {
                SoundPlayer myMusic = new SoundPlayer(play_file);
                myMusic.Stop();
            }
            this.Close();
        }
예제 #30
0
파일: Sounds.cs 프로젝트: UgotAlan/SET
        /// <summary>
        /// PlayMusicIntro method that takes boolean if mute option is enabled,
        /// and plays music file if it is not.
        /// </summary>
        /// <param name="playing">boolean true/false</param>
        /// <returns>boolean true/false just for unit testing</returns>        
        public bool PlayMusicIntro(bool playing)
        {
            SoundPlayer sound = new SoundPlayer(Resources.music_intro);

            if (playing == true)
            {
                sound.PlayLooping();
                return true;
            }
            else
            {
                sound.Stop();
                return false;
            }
        }
예제 #31
0
 //sp.SoundLocation = Properties.Resources.启动音乐;
 private void label3_Click(object sender, EventArgs e)
 {
     if (!sound_stop)
     {
         sp.Stop();
         sound_stop   = true;
         label3.Image = Properties.Resources.喇叭X;
     }
     else
     {
         sp.PlayLooping();
         sound_stop   = false;
         label3.Image = Properties.Resources.喇叭;
     }
 }
예제 #32
0
        private void button6_Click(object sender, EventArgs e)
        {
            aasfasfdasfg++;
            button6.Text = "Müziği Kapat";
            System.Media.SoundPlayer so = new System.Media.SoundPlayer();

            so.SoundLocation = "bb.wav";
            if (aasfasfdasfg % 2 != 0)
            {
                so.Play();
            }
            else
            {
                so.Stop();
            }
        }
예제 #33
0
 private void ClickOnCar(object sender, EventArgs e)
 {
     pbxVoiture.Location = new Point(iX+=10,300);
     Stream str = Properties.Resources._2jzCarSound;
     SoundPlayer snd = new SoundPlayer(str);
     if(iX >=570)
     {
         snd.Stop();
         MessageBox.Show("eucalyptus");
         pbxVoiture.Enabled = false;
     }
     if(iX==11)
     {
         snd.Play();
     }
 }
예제 #34
0
 private void cb_music_CheckedChanged(object sender, EventArgs e)
 {
     SoundPlayer backgroundmusic = new SoundPlayer(Properties.Resources.frametraxx_Manga_Action);
     Boolean music_playing = false;
     Properties.Settings.Default.music_on = cb_music.Checked;
     if(Properties.Settings.Default.music_on)
     {
         music_playing = true;
         backgroundmusic.Play();
     }
     else
     {
         music_playing = false;
         backgroundmusic.Stop();
     }
 }
예제 #35
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (player == null)
     {
         button2.Text = "Stop";
         player       = new SoundPlayer("bgm2.wav");
         player.PlayLooping();
     }
     else
     {
         button2.Text = "Start";
         player.Stop();
         player.Dispose();
         player = null;
     }
 }
예제 #36
0
 public void checkReminder()
 {
     String date = DateTime.Now.Date.ToShortDateString();
     String time = DateTime.Now.ToShortTimeString();
     for (int i = 0; i < reminderlistarray.Length; i++)
     {
         if (reminderlistarray[i][1].ToString() == date && reminderlistarray[i][2].ToString()==time)
         {
             SoundPlayer simpleSound = new SoundPlayer("laughcute.wav");
             simpleSound.Play();
             if (Convert.ToBoolean(MessageBox.Show("Check out your reminders :D", "Reminder", MessageBoxButton.YesNo)))
             {
                 simpleSound.Stop();
             }
         }
     }
 }
예제 #37
0
        private void btnCheckAnswer_Click(object sender, EventArgs e) //this is what checks the user's answer to see if it is correct.
        {
            if (userInput == songPicked)
            {
                lblRightWrong.Text = "Correct!";
                score = score + 25;
                player.Stop();
                songPick++;
                playSong();
            }
            else
            {
                score = score - 5;
                lblRightWrong.Text = "Wrong!!!";
            }

            lblScore.Text = score.ToString();
        }
예제 #38
0
        private void Form1_Load(object sender, EventArgs e)
        {
            SoundPlayer warframethemesong = new System.Media.SoundPlayer(Properties.Resources.Octavia_Song_Second_Dream);

            warframethemesong.Play();
            Alexis.Speak("Connecting to Warframe!");
            Alexis.Speak("looking for Players!");
            Alexis.Speak("Checking Server Status");
            Alexis.Speak("Looking for ChisdealHD Mappa");
            Alexis.Speak("Found Server Data");
            Alexis.Speak("internalizing Server Data");
            Alexis.Speak("Server Data is Done");
            Alexis.Speak("Logging in to Mainframe");
            Alexis.Speak("Looking for Developers.");
            Alexis.Speak("I'm here ready go!");
            warframethemesong.Stop();
            wake           = false;
            comboBox2.Text = Properties.Settings.Default.fortniteplat;

            textBox4.Text = Properties.Settings.Default.fortnite;

            comboBox1.Text = Properties.Settings.Default.bf1plat;

            textBox5.Text = Properties.Settings.Default.bf1;

            textBox6.Text = Properties.Settings.Default.bf3;

            comboBox3.Text = Properties.Settings.Default.bf3plat;

            comboBox5.Text = Properties.Settings.Default.bfhplat;

            textBox11.Text = Properties.Settings.Default.bfh;

            textBox8.Text = Properties.Settings.Default.hypixel;

            textBox10.Text = Properties.Settings.Default.mixer;

            textBox9.Text = Properties.Settings.Default.twitch;

            textBox7.Text = Properties.Settings.Default.bf4;

            comboBox4.Text = Properties.Settings.Default.bf4plat;
        }
예제 #39
0
        public void check()
        {
            string Check = new System.Net.WebClient().DownloadString(textBox1.Text);

            System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:\bsound.wav");

            if (Check.Contains("System blocked"))
            {
                player.Play();
            }
            else
            {
                System.Threading.Thread.Sleep(1000);
                player.Stop();


                //timer1.Start();
            }
        }//Одноразовая проверка состояния блокировки
예제 #40
0
 private void Q1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (e.CloseReason == CloseReason.UserClosing)
     {
         DialogResult result = MessageBox.Show("Do you really want to exit?", "Dialog Title", MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"C:\LEA by DELAN\LEA by DELAN\Resources\AUD1.wav");
             player.Stop();
         }
         else
         {
             e.Cancel = true;
         }
     }
     else
     {
         e.Cancel = true;
     }
 }
예제 #41
0
        private void Ball_Movement_Timer_Tick(object sender, EventArgs e)
        {
            rtn_Barra.Location = pcb_Paddle.Location;
            if (P1.MovimentoEGestione(ref rtn_Barra, ref Brick, ref Rect, ref VittoriaCont, ref punteggio) == true)
            {
                Ball_Movement_Timer.Stop();
                Ball_Movement_Timer.Enabled = false;
                MessageBox.Show("Hai perso una vita Idiota");
                vite--;
                lbl_Vite.Text = vite.ToString();
                CheckVite();

                pcb_Ball.Location = new Point(160, 360);

                punteggio /= 2;
                MessageBox.Show("Clicca sulla palla per continuare (Non premere 'e'") ;
            }
            else
            { lbl_Point.Text = punteggio.ToString(); }
            if (VittoriaCont == 35)
            {
                Ball_Movement_Timer.Stop();
                if (EE1_1 == true)
                    //EE1.Stop();

                if (!Serial)
                {
                    MessageBox.Show("Vuoi vincere? Compra il DLC presso steam");
                }
                else
                {
                    Stream S1 = Properties.Resources.WinTheme;
                    SoundPlayer SP1 = new SoundPlayer(S1);
                    SP1.Play();
                    MessageBox.Show("Complimenti, hai vinto la partita");
                    SP1.Stop();
                    Ogg.AttivaNewGame(ref Brick, ref pcb_Ball, ref VittoriaCont, ref pnl_Home, ref pcb_Start, ref punteggio, ref lbl_Point, ref pcb_Paddle);
                    pcb_Start.Enabled = true;
                }
            }
        }
예제 #42
0
파일: Player.cs 프로젝트: KH8/AmpIdent
        public static void Play(Button sender, string path)
        {
            var button = sender;

            if (!_playing)
            {
                _sp = new SoundPlayer();
                _sp.Stop();
                _sp.SoundLocation = path;
                _sp.LoadAsync();
                _sp.Play();
                _playing = true;
                button.Content = "Stop";
            }
            else
            {
                _sp.Stop();
                _playing = false;
                button.Content = "Play";
            }
        }
예제 #43
0
        /// <summary>
        /// Method for handleing the music in the game.
        /// </summary>
        /// <param name="ct">Token to cancel the process.</param>
        public void GameMusicHandler()
        {
            Action<Func<bool, bool, bool>, Stream> StartMusic = (func, stream) =>
            {
                sound = new SoundPlayer(stream);
                sound.PlayLooping();

                while (func.Invoke(gamePanelLeft.IsGameOver, gamePanelRight.IsGameOver))
                {
                    Thread.Sleep(100);
                }

                sound.Stop();
            };

            while (!Dispatcher.HasShutdownStarted)
            {
                StartMusic((x, y) => x && y, Properties.Resources.robotic);
                StartMusic((x, y) => !x || !y, Properties.Resources.searching);
            }
        }
예제 #44
0
파일: Program.cs 프로젝트: Amarg0/C-
        public static void GetCurrentTime(object a)
        {
            WakeUPP[] massiv = (WakeUPP[])a;
                SoundPlayer sp = new SoundPlayer("C:\\Users\\Amargo\\Desktop\\Alarm01.wav");
                SecondDelegate sc = new SecondDelegate(GetSecond);
                MinuteDelegate mn = new MinuteDelegate(GetMinute);

                Console.WriteLine(DateTime.Now);
                while (true)
                {
                    DateTime NowTime = DateTime.Now;

                    for (int i = 0; i < 100; i++)
                        if (massiv[i]!= null)
                            if (massiv[i].Hour == NowTime.Hour && massiv[i].Minute == NowTime.Minute)
                            {

                                sp.Play();
                                Console.WriteLine(massiv[i].Messager);
                                string file_adress = "c:\\Users\\Amargo\\Desktop\\101\\" + "Будильник_"
                                +i+".txt";
                                FileStream nowtimefile = new FileStream(file_adress,
                                       FileMode.Create);
                                StreamWriter writer1 = new StreamWriter(nowtimefile);
                                writer1.WriteLine("Будильник сработал в " + NowTime.Hour + " часов " + mn(NowTime) +
                                    " минут " + sc(NowTime) + " секунд") ;
                                writer1.WriteLine("Текст будильника: " + massiv[i].Messager);
                                writer1.Close();
                                Thread.Sleep(50000);
                                sp.Stop();
                            }
                    FileStream nowtimefile1 = new FileStream("c:\\Users\\Amargo\\Desktop\\101\\nowtime.txt",
                               FileMode.Create);
                    NowTime = DateTime.Now;
                    StreamWriter writer = new StreamWriter(nowtimefile1);
                    writer.Write("{0}", NowTime);
                    writer.Close();
                    Thread.Sleep(1000);
                }
        }
예제 #45
0
파일: Form1.cs 프로젝트: GalaxyZE/Clock
 private void button2_Click(object sender, EventArgs e)
 {
     if (radioButton3.Checked)
     {
         #region mode 3
         timer1.Enabled   = false;
         timer2.Enabled   = false;
         button1.Text     = "Start";
         Enable_Switch    = false;
         textBox1.Text    = ihours.ToString();
         textBox2.Text    = iminutes.ToString();
         textBox3.Text    = iseconds.ToString();
         textBox1.Enabled = true;
         textBox2.Enabled = true;
         textBox3.Enabled = true;
         button1.Enabled  = true;
         player1.controls.stop();
         if (AudioPath == null)
         {
             player.Stop();
         }
         #endregion
     }
     else if (radioButton2.Checked)
     {
         button1.Text           = "Start";
         StopwatchTimer.Enabled = false;
         stopwatchlabel.Text    = "00:00:00.00";
         for (byte i = 0; i < 4; i++)
         {
             Time[i] = "00";
         }
         Stopwatch        = 0;
         Stopwatch_Second = 0;
     }
     else if (radioButton1.Checked)
     {
     }
 }
 private void kphandler(object sender, GTA.KeyEventArgs e)
 {
     if (Keys.I == e.Key)
     {
         if (stalled == true)
         {
             if (starts == true)
             {
                 crank = false;
                 audioplayed2 = false;
                 audioplayed = false;
             }
             else
             {
                 System.Media.SoundPlayer player = new System.Media.SoundPlayer(Real_car_sounds.Properties.Resources.starter);
                 player.Play();
                 player.Stop();
                 audioplayed2 = false;
                 audioplayed = false;
                 crank = false;
             }
         }
     } 
 }
예제 #47
0
        /// <summary> 
        /// バイト配列として読みだした音を再生します。
        /// ブロッキングで実行され、音声再生が終了するかStop関数が呼び出されるかすると
        /// 関数が終了します。
        /// </summary>
        public async Task PlayByPronounce(string text, bool useLipSynch)
        {
            Stop();

            UpdateBySetting();

            string pronounce = _textToPronounceConverter.Convert(text);

            _cts = new CancellationTokenSource();
            var token = _cts.Token;
            var data = _currentSynthesizer.CreateWav(pronounce);
            //ガードが必要: 合成音声に失敗した場合を想定する
            if (data == null || data.Length == 0) return;

            using (var ms = new MemoryStream(data))
            using (var sp = new SoundPlayer(ms))
            {
                try
                {
                    //再生時間を読み取る
                    int durationMillisec = (int)WaveInfoWithNAudio.GetDurationMillisec(data);

                    if (useLipSynch)
                    {
                        RequestLipSynchByWavData(data);                        
                    }
                    sp.Play();

                    await Task.Delay(durationMillisec, token);
                }
                catch (TaskCanceledException)
                {
                    sp.Stop();
                }
            }
        }
예제 #48
0
        static void Main()
        {
            SoundPlayer sound = new SoundPlayer();
            try
            {
                sound = new SoundPlayer("../../intro.wav");
                sound.PlayLooping();
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("File intro.wav not found");
            }

            Console.BufferHeight = Console.WindowHeight = 35;
            Console.BufferWidth = Console.WindowWidth = 125;

            Console.BackgroundColor = ConsoleColor.Black;
            Console.Clear();
            Console.CursorVisible = false;
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Title = "KILLING NINJAS";
            Animation.FirstStage();

            int numberOfPlayers = Intro.Menu();
            sound.Stop();

            if (numberOfPlayers == 1)
            {

                MultyPlayer.MultyPlay();
            }
            else
            {
                MultyPlayer.MultyPlay(true);
            }
        }
예제 #49
0
        /* The 1st welcome page in the game */
        static void WelcomeScreen()
        {
            MemoryStream background = new MemoryStream(File.ReadAllBytes("../../sound/intro.wav"));
            SoundPlayer music = new SoundPlayer(background);
            music.Play();
            Console.BackgroundColor = ConsoleColor.Black;                   // background color
            Console.ForegroundColor = ConsoleColor.Green;                   // foreground color
            Console.Clear();

            Console.SetCursorPosition(21, 6);
            Console.WriteLine(@"             _________              __                    ");
            Console.SetCursorPosition(21, 7);
            Console.WriteLine(@"            /   _____/ ____ _____  |  | __ ____           ");
            Console.SetCursorPosition(21, 8);
            Console.WriteLine(@"            \_____  \ /    \\__  \ |  |/ // __ \          ");
            Console.SetCursorPosition(21, 9);
            Console.WriteLine(@"            /        \   |  \/ __ \|    <\  ___/          ");
            Console.SetCursorPosition(21, 10);
            Console.WriteLine(@"           /_______  /___|  (____  /__|_ \\___ \          ");
            Console.SetCursorPosition(21, 11);
            Console.WriteLine(@"                   \/     \/     \/     \/    \/          ");
            Console.SetCursorPosition(21, 12);
            Console.WriteLine(@"___________.__             ________                       ");
            Console.SetCursorPosition(21, 13);
            Console.WriteLine(@"\__    ___/|  |__   ____  /  _____/_____    _____   ____  ");
            Console.SetCursorPosition(21, 14);
            Console.WriteLine(@"  |    |   |  |  \_/ __ \/   \  ___\__  \  /     \_/ __ \ ");
            Console.SetCursorPosition(21, 15);
            Console.WriteLine(@"  |    |   |   Y  \  ___/\    \_\  \/ __ \|  Y Y  \  ___/ ");
            Console.SetCursorPosition(21, 16);
            Console.WriteLine(@"  |____|   |___|  /\___ \ \______  (____  /__|_|  /\___ \ ");
            Console.SetCursorPosition(21, 17);
            Console.WriteLine(@"                \/     \/        \/     \/      \/     \/ ");

            Console.ForegroundColor = ConsoleColor.White;
            Console.SetCursorPosition(85, 32);
            Console.WriteLine("Created By:");
            Console.SetCursorPosition(80, 33);
            Console.WriteLine("\"Eek! the Cat\" TeAm");
            Console.ResetColor();

            try
            {
                StreamReader reader = new StreamReader("../../maps/map " + 1.ToString().PadLeft(2, '0') + ".txt");

                Console.BackgroundColor = ConsoleColor.Black;
                Console.SetCursorPosition(31, 20);
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Snake Name :  ");
                Console.SetCursorPosition(45, 22);
                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.WriteLine("(min 1 letter - max 10 letters)");

                Console.SetCursorPosition(45, 20);
                Console.ForegroundColor = ConsoleColor.Green;
                snakeName = ReadString(10);

                Console.BackgroundColor = ConsoleColor.Black;
                Console.SetCursorPosition(31, 24);
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Difficulty :  ");
                Console.SetCursorPosition(45, 26);
                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.WriteLine("(Type \"1\" for Easy, \"2\" for Medium, \"3\" for Hard)");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(45, 24);
                string difficultInput = ReadString(1);
                long difficult;
                Console.ResetColor();

                while (!long.TryParse(difficultInput, out difficult) || difficult == 0 || difficult > 3 || difficult < 1)
                {
                    try
                    {
                        Console.SetCursorPosition(45, 24);
                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.WriteLine(new string(' ', 150));
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.SetCursorPosition(45, 24);
                        difficultInput = ReadString(1);
                        Console.ResetColor();
                    }
                    catch (Exception) { }
                }

                switch (difficult)
                {
                    case 1: sleepTime = 110; difficulty = "Easy"; lifeTime = 10000; bonusFoodTime = 10; break;
                    case 2: sleepTime = 90; difficulty = "Medium"; lifeTime = 8000; bonusFoodTime = 8; break;
                    case 3: sleepTime = 70; difficulty = "Hard"; lifeTime = 6000; bonusFoodTime = 6; break;
                    default: break;
                }
                Console.ResetColor();
            }
            catch (DirectoryNotFoundException)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.BackgroundColor = ConsoleColor.Black;
                Console.SetCursorPosition(35, 23);
                Console.WriteLine("Sorry But You don't have Maps :(");
                Console.SetCursorPosition(99, 33);
                Console.ResetColor();

                Console.Beep(500, 200);
                while (true)
                {
                    if (Console.KeyAvailable)
                    {
                        Environment.Exit(0);
                    }
                }
            }
            music.Stop();
            background.Close();
        }
예제 #50
0
 public void Stop()
 {
     player.Stop();
 }
예제 #51
0
        private static void PlaySoundFromFile(string filePath)
        {
            using (var player = new SoundPlayer(filePath))
            {
                try
                {
                    player.Stop();
                    player.Play();
                }
                catch (TypeInitializationException)
                {
                    MessageBox.Show("The sound file is corrupted (is not in the correct format)! Sound will be disabled!", "Sound file is corrupted?!");
                    musicAvalible = false;
                }
                catch (ArgumentNullException)
                {
                    MessageBox.Show("The sound file path is empty? The sound will be disabled!", "The sound file path is empty?!");
                    SfxOn = false;
                }
                catch (ArgumentException)
                {
                    MessageBox.Show("The sound file path is empty? The sound will be disabled!", "The sound file path is empty?!");
                    SfxOn = false;
                }
                catch (FileNotFoundException)
                {
                    MessageBox.Show(string.Format("The file {0} was not found! Sound will be disabled!", filePath), "File not found!");
                    SfxOn = false;
                }
                catch (FileLoadException)
                {
                    MessageBox.Show(string.Format("The file {0} cannot be loaded! The sound will be disabled!", filePath), "File cannot be loaded!");
                    SfxOn = false;
                }
                catch (IOException)
                {
                    MessageBox.Show(string.Format(@"Input Output error occured while trying to open {0} ! The sound will
be disabled!", filePath), "Input Output error!");
                    SfxOn = false;
                }
                catch (UnauthorizedAccessException)
                {
                    MessageBox.Show(string.Format(@"You don't have permission to access {0} ! The sound will
be disabled!", filePath), "You don't have permission to access this file");
                    SfxOn = false;
                }
                catch (SecurityException)
                {
                    MessageBox.Show(string.Format(@"You don't have permission to access {0} ! The sound will
be disabled!", filePath), "You don't have permission to access this file");
                    SfxOn = false;
                }
            }
        }
예제 #52
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sp">SoundPlayer对象</param>
 public static void StopWAV(SoundPlayer sp)
 {
     sp.Stop();
 }
예제 #53
0
            public Implementation(PetrolPumpWindow petrolPump)
            {
                SComboBox<IPump> logic = new SComboBox<IPump>(
                    new IPump[]
                    {
                        new LifeCyclePump(),
                        new AccumulatePulsesPump(),
                        new ShowDollarsPump(),
                        new ClearSalePump(),
                        new KeypadPump(),
                        new PresetAmountPump()
                    },
                    p => p.GetType().FullName);
                petrolPump.LogicComboBoxPlaceholder.Children.Add(logic);

                STextField textPrice1 = new STextField("2.149") { Width = 100 };
                petrolPump.Price1Placeholder.Children.Add(textPrice1);

                STextField textPrice2 = new STextField("2.341") { Width = 100 };
                petrolPump.Price2Placeholder.Children.Add(textPrice2);

                STextField textPrice3 = new STextField("1.499") { Width = 100 };
                petrolPump.Price3Placeholder.Children.Add(textPrice3);

                Func<string, double> parseDoubleSafe = s =>
                {
                    double n;
                    if (double.TryParse(s, out n))
                    {
                        return n;
                    }

                    return 0.0;
                };

                StreamSink<Key> sKey = new StreamSink<Key>();
                Dictionary<Key, FrameworkElement> containersByKey = new Dictionary<Key, FrameworkElement>
                {
                    { Key.One, petrolPump.Keypad1Button },
                    { Key.Two, petrolPump.Keypad2Button },
                    { Key.Three, petrolPump.Keypad3Button },
                    { Key.Four, petrolPump.Keypad4Button },
                    { Key.Five, petrolPump.Keypad5Button },
                    { Key.Six, petrolPump.Keypad6Button },
                    { Key.Seven, petrolPump.Keypad7Button },
                    { Key.Eight, petrolPump.Keypad8Button },
                    { Key.Nine, petrolPump.Keypad9Button },
                    { Key.Zero, petrolPump.Keypad0Button },
                    { Key.Clear, petrolPump.KeypadClearButton }
                };
                foreach (KeyValuePair<Key, FrameworkElement> containerAndKey in containersByKey)
                {
                    containerAndKey.Value.MouseDown += async (sender, args) =>
                    {
                        if (args.LeftButton == MouseButtonState.Pressed)
                        {
                            await Task.Run(() => sKey.Send(containerAndKey.Key));
                        }
                    };
                }

                CellLoop<UpDown> nozzle1 = new CellLoop<UpDown>();
                CellLoop<UpDown> nozzle2 = new CellLoop<UpDown>();
                CellLoop<UpDown> nozzle3 = new CellLoop<UpDown>();

                Cell<double> calibration = Cell.Constant(0.001);
                Cell<double> price1 = textPrice1.Text.Map(parseDoubleSafe);
                Cell<double> price2 = textPrice2.Text.Map(parseDoubleSafe);
                Cell<double> price3 = textPrice3.Text.Map(parseDoubleSafe);
                CellSink<Stream<Unit>> csClearSale = new CellSink<Stream<Unit>>(Sodium.Stream.Never<Unit>());
                Stream<Unit> sClearSale = csClearSale.SwitchS();

                StreamSink<int> sFuelPulses = new StreamSink<int>();
                Cell<Outputs> outputs = logic.SelectedItem.Map(
                    pump => pump.Create(new Inputs(
                        Operational.Updates(nozzle1),
                        Operational.Updates(nozzle2),
                        Operational.Updates(nozzle3),
                        sKey,
                        sFuelPulses,
                        calibration,
                        price1,
                        price2,
                        price3,
                        sClearSale)));

                Cell<Delivery> delivery = outputs.Map(o => o.Delivery).SwitchC();
                Cell<string> presetLcd = outputs.Map(o => o.PresetLcd).SwitchC();
                Cell<string> saleCostLcd = outputs.Map(o => o.SaleCostLcd).SwitchC();
                Cell<string> saleQuantityLcd = outputs.Map(o => o.SaleQuantityLcd).SwitchC();
                Cell<string> priceLcd1 = outputs.Map(o => o.PriceLcd1).SwitchC();
                Cell<string> priceLcd2 = outputs.Map(o => o.PriceLcd2).SwitchC();
                Cell<string> priceLcd3 = outputs.Map(o => o.PriceLcd3).SwitchC();
                Stream<Unit> sBeep = outputs.Map(o => o.SBeep).SwitchS();
                Stream<Sale> sSaleComplete = outputs.Map(o => o.SSaleComplete).SwitchS();

                SoundPlayer beepPlayer = new SoundPlayer(GetResourceStream(@"sounds\beep.wav"));
                this.listeners.Add(sBeep.Listen(_ => new Thread(() => beepPlayer.PlaySync()) { IsBackground = true }.Start()));

                SoundPlayer fastRumblePlayer = new SoundPlayer(GetResourceStream(@"sounds\fast.wav"));
                Action stopFast = () => { };
                Action playFast = () =>
                {
                    ManualResetEvent mre = new ManualResetEvent(false);
                    new Thread(() =>
                    {
                        fastRumblePlayer.PlayLooping();
                        mre.WaitOne();
                        fastRumblePlayer.Stop();
                    })
                    { IsBackground = true }.Start();
                    stopFast = () => mre.Set();
                };

                SoundPlayer slowRumblePlayer = new SoundPlayer(GetResourceStream(@"sounds\slow.wav"));
                Action stopSlow = () => { };
                Action playSlow = () =>
                {
                    ManualResetEvent mre = new ManualResetEvent(false);
                    new Thread(() =>
                    {
                        slowRumblePlayer.PlayLooping();
                        mre.WaitOne();
                        slowRumblePlayer.Stop();
                    })
                    { IsBackground = true }.Start();
                    stopSlow = () => mre.Set();
                };

                this.listeners.Add(delivery.Changes().Listen(d =>
                {
                    petrolPump.Dispatcher.InvokeIfNecessary(() =>
                    {
                        if (d == Delivery.Fast1 || d == Delivery.Fast2 || d == Delivery.Fast3)
                        {
                            playFast();
                        }
                        else
                        {
                            stopFast();
                        }

                        if (d == Delivery.Slow1 || d == Delivery.Slow2 || d == Delivery.Slow3)
                        {
                            playSlow();
                        }
                        else
                        {
                            stopSlow();
                        }
                    });
                }));

                StackPanel presetLcdStackPanel = new StackPanel { Orientation = Orientation.Horizontal };
                petrolPump.PresetPlaceholder.Children.Add(presetLcdStackPanel);
                this.listeners.Add(presetLcd.Listen(t => petrolPump.Dispatcher.InvokeIfNecessary(() => petrolPump.SetLcdDigits(presetLcdStackPanel, t, 5, true))));

                StackPanel saleCostStackPanel = new StackPanel { Orientation = Orientation.Horizontal };
                petrolPump.DollarsPlaceholder.Children.Add(saleCostStackPanel);
                this.listeners.Add(saleCostLcd.Listen(t => petrolPump.Dispatcher.InvokeIfNecessary(() => petrolPump.SetLcdDigits(saleCostStackPanel, t, 5, true))));

                StackPanel saleQuantityLcdStackPanel = new StackPanel { Orientation = Orientation.Horizontal };
                petrolPump.LitersPlaceholder.Children.Add(saleQuantityLcdStackPanel);
                this.listeners.Add(saleQuantityLcd.Listen(t => petrolPump.Dispatcher.InvokeIfNecessary(() => petrolPump.SetLcdDigits(saleQuantityLcdStackPanel, t, 5, true))));

                StackPanel priceLcd1StackPanel = new StackPanel { Orientation = Orientation.Horizontal };
                petrolPump.Fuel1Placeholder.Children.Add(priceLcd1StackPanel);
                this.listeners.Add(priceLcd1.Listen(t => petrolPump.Dispatcher.InvokeIfNecessary(() => petrolPump.SetLcdDigits(priceLcd1StackPanel, t, 5, false))));

                StackPanel priceLcd2StackPanel = new StackPanel { Orientation = Orientation.Horizontal };
                petrolPump.Fuel2Placeholder.Children.Add(priceLcd2StackPanel);
                this.listeners.Add(priceLcd2.Listen(t => petrolPump.Dispatcher.InvokeIfNecessary(() => petrolPump.SetLcdDigits(priceLcd2StackPanel, t, 5, false))));

                StackPanel priceLcd3StackPanel = new StackPanel { Orientation = Orientation.Horizontal };
                petrolPump.Fuel3Placeholder.Children.Add(priceLcd3StackPanel);
                this.listeners.Add(priceLcd3.Listen(t => petrolPump.Dispatcher.InvokeIfNecessary(() => petrolPump.SetLcdDigits(priceLcd3StackPanel, t, 5, false))));

                Dictionary<CellLoop<UpDown>, Image> nozzles = new Dictionary<CellLoop<UpDown>, Image>
                {
                    { nozzle1, petrolPump.Nozzle1Image },
                    { nozzle2, petrolPump.Nozzle2Image },
                    { nozzle3, petrolPump.Nozzle3Image }
                };
                this.listeners.AddRange(nozzles.Select(nozzle => nozzle.Key.Listen(p => petrolPump.Dispatcher.InvokeIfNecessary(() => nozzle.Value.Margin = p == UpDown.Up ? new Thickness(0, 0, 0, 0) : new Thickness(0, 30, 0, 0)))));

                foreach (KeyValuePair<CellLoop<UpDown>, Image> nozzle in nozzles)
                {
                    StreamSink<Unit> nozzleClicks = new StreamSink<Unit>();
                    nozzle.Value.MouseDown += async (sender, args) =>
                    {
                        if (args.LeftButton == MouseButtonState.Pressed)
                        {
                            await Task.Run(() => nozzleClicks.Send(Unit.Value));
                        }
                    };
                    nozzle.Key.Loop(nozzleClicks.Snapshot(nozzle.Key, (_, n) => n == UpDown.Down ? UpDown.Up : UpDown.Down).Hold(UpDown.Down));
                }

                this.listeners.Add(sSaleComplete.Listen(sale =>
                {
                    Task.Run(() =>
                    {
                        petrolPump.Dispatcher.InvokeIfNecessary(() =>
                        {
                            SaleCompleteDialog dialog = new SaleCompleteDialog(
                                sale.Fuel.ToString(),
                                Formatters.FormatPrice(sale.Price, null),
                                Formatters.FormatSaleCost(sale.Cost),
                                Formatters.FormatSaleQuantity(sale.Quantity));
                            dialog.Owner = petrolPump;
                            csClearSale.Send(dialog.SOkClicked);
                            dialog.Show();
                            IListener l = null;
                            // ReSharper disable once RedundantAssignment
                            l = dialog.SOkClicked.Listen(_ =>
                            {
                                petrolPump.Dispatcher.InvokeIfNecessary(() => dialog.Close());

                                // ReSharper disable once AccessToModifiedClosure
                                using (l)
                                {
                                }
                            });
                        });
                    });
                }));

                Task.Run(async () =>
                {
                    while (true)
                    {
                        Transaction.RunVoid(() =>
                        {
                            switch (delivery.Sample())
                            {
                                case Delivery.Fast1:
                                case Delivery.Fast2:
                                case Delivery.Fast3:
                                    sFuelPulses.Send(40);
                                    break;
                                case Delivery.Slow1:
                                case Delivery.Slow2:
                                case Delivery.Slow3:
                                    sFuelPulses.Send(2);
                                    break;
                            }
                        });

                        await Task.Delay(200).ConfigureAwait(false);
                    }
                    // ReSharper disable once FunctionNeverReturns
                });
            }
예제 #54
0
 private void musicPlayer(string newText, string filename)
 {
     if (Globals.mediaPlayerActivated == true)
     {
         Globals.wmplayer.URL = filename;
         using (SoundPlayer player = new SoundPlayer(filename))
         {
             if (newText == "start")
             {
                 mediaPlayerOverlay.newMedia(Globals.mediaFileName[Globals.mediaFileIndex]);
                 //Globals.wmplayer.controls.play();
                 while (Globals.wmplayer.playState == WMPLib.WMPPlayState.wmppsPlaying)
                 {
                     if(Globals.wmplayer.playState == WMPLib.WMPPlayState.wmppsPaused)
                     {
                         //musicPlayer("start", Globals.mediaFileName[Globals.mediaFileIndex]);
                     }
                 }
             }
             if (newText == "stop")
             {
                 Globals.wmplayer.controls.stop();
                 player.Stop();
             }
         }
     }
 }
예제 #55
0
        static void Main( string[] args )
        {
            SetFieldSize ();
            Console.ReadKey();  //uncomment if you want to wait for a key to start the game

            using (SoundPlayer intro = new SoundPlayer ( "../../External Files/introZ.wav" ))
            {
                intro.PlayLooping ();
                Thread.Sleep(1400);
                PrintStartScreen ();
                ChooseLevel ();
                ChooseSpeed ();
                ChooseName();
                intro.Stop ();
            }

            CreateField();

            using (SoundPlayer gameSound = new SoundPlayer ( "../../External Files/game.wav" ))
            {
                gameSound.PlayLooping ();
                WaitForStart ();
                stopwatch.Start ();

                while (true)
                {
                    ReadKey();

                    DrawScoreBoard ();

                    //Move
                    MovePad ();
                    MoveBall ();
                    MovePowerUps ();

                    ReadKey (); // Implements In-Game Menu

                    //Print
                    PrintBall ();
                    PrintPowerUps ();
                    PrintPad ();

                    //Checks
                    BouncePad ();
                    BounceWalls ();
                    BreakBricks ();
                    GetBonusCheck ();

                    CheckEndOfGame ();
                    CheckEndOfLevel();
                    if (gameOver || levelFinished) { break; }

                    Thread.Sleep ( threadSpeed );

                }
                gameSound.Stop ();
                stopwatch.Stop ();
            }
            EndGameScreen ();
        }
예제 #56
0
        static void EndGameScreen()
        {
            using (SoundPlayer outro = new SoundPlayer ( "../../External Files/outro.wav" ))
            {
                outro.PlayLooping ();
                Console.Clear ();
                string[] gameOverLogo = new string[9];

                gameOverLogo[0] = @"  ____     _    __  __ _____ ";
                gameOverLogo[1] = @" / ___|   / \  |  \/  | ____|";
                gameOverLogo[2] = @" | |  _  / _ \ | |\/| |  _|  ";
                gameOverLogo[3] = @" | |_| |/ ___ \| |  | | |___ ";
                gameOverLogo[4] = @" \_____/_/   \_\_|__|_|_____|";
                gameOverLogo[5] = @"  / _ \ \   / / ____|  _ \";
                gameOverLogo[6] = @" | | | \ \ / /|  _| | |_) |";
                gameOverLogo[7] = @" | |_| |\ V / | |___|  _ <  ";
                gameOverLogo[8] = @"  \___/  \_/  |_____|_| \_\ ";

                for (int i = 0; i < gameOverLogo.Length; i++)
                {
                    WriteOnPosition ( fieldHeight / 2 - 10 + i, fieldWidth / 2 - 10, gameOverLogo[i], ConsoleColor.Yellow );
                }

                TimeSpan time = new TimeSpan ();
                time = stopwatch.Elapsed;

                WriteOnPosition ( fieldHeight / 2 + 1, fieldWidth / 2 - fieldWidth * 5 / 100, "Final Score: ", ConsoleColor.Yellow );
                WriteOnPosition ( fieldHeight / 2 + 1, fieldWidth / 2 - fieldWidth * 5 / 100 + 13, score.ToString (), ConsoleColor.White );
                WriteOnPosition ( fieldHeight / 2 + 3, fieldWidth / 2 - fieldWidth * 5 / 100, "Your Time: ", ConsoleColor.Yellow );
                WriteOnPosition ( fieldHeight / 2 + 3, fieldWidth / 2 - fieldWidth * 5 / 100 + 13, CalulateTime ( time ), ConsoleColor.White );

                RecordScore();
                PrintHighscore();

                WriteOnPosition ( fieldHeight / 2 + 14, fieldWidth / 2 - fieldWidth * 5 / 100 - 4, "Press any key to exit.. ", ConsoleColor.Red );
                Console.ReadKey ();
                outro.Stop ();
            }
        }
예제 #57
0
 private void Yov_FormLoad(object sender, EventArgs e)
 {
     SoundPlayer backgroundSound = new SoundPlayer(Program.ResourcesFolder + "background.wav");
     backgroundSound.Stop();
 }
        private void CheckExchangeConnectivity()
        {
            LogManager.WriteLog("Inside CheckExchangeConnectivity", LogManager.enumLogLevel.Info);

            SoundPlayer HndPayBeep = new SoundPlayer();
            Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                       {
                           lblDate.Visibility = Visibility.Hidden;
                       }));
            try
            {
                if (File.Exists(Settings.Handpay_Wav_Path))
                {
                    HndPayBeep.SoundLocation = Settings.Handpay_Wav_Path;
                }
                else
                {
                    HndPayBeep.Stream = BMC.Presentation.POS.Properties.Resources.HandPay;
                }
            }
            catch (Exception Ex)
            {
                LogManager.WriteLog("Could not load sound File:" + Ex.Message, LogManager.enumLogLevel.Error);
            }

            while (true)
            {
                try
                {

                    if (!String.IsNullOrEmpty(_exchangeConnectionString))
                    {
                        using (SqlConnection objSQLConn = new SqlConnection(System.Text.RegularExpressions.Regex.Replace(_exchangeConnectionString, "CONNECTION TIMEOUT=[0-9]*", "CONNECTION TIMEOUT=5")))
                        {

                            objSQLConn.Open();
                            if (Settings.HandPayBeepEnabled.ToUpper() != "Y")
                            {
                                SqlCommand ocmd = new SqlCommand("Select Top 1 1 from Site With(NOLOCK)", objSQLConn);
                                ocmd.ExecuteNonQuery();
                            }

                            Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                            {
                                lblDatabase.Background = LiGreen;//System.Windows.Media.Brushes.YellowGreen;
                            }));

                            try
                            {

                                if (Settings.HandPayBeepEnabled == "Y")
                                {
                                    if (objSQLConn.State == ConnectionState.Open)
                                    {
                                        SqlCommand oCmd = new SqlCommand("rsp_GETHandPayStatus", objSQLConn);
                                        oCmd.CommandTimeout = 10;
                                        int iHndPay = (int)oCmd.ExecuteScalar();
                                        if (iHndPay > 0)
                                        {
                                            HndPayBeep.PlayLooping();
                                        }
                                        else
                                        {
                                            HndPayBeep.Stop();
                                        }
                                    }
                                }

                            }
                            catch
                            {
                                LogManager.WriteLog("Error->HandPayBeep", LogManager.enumLogLevel.Error);
                                HndPayBeep.Stop();
                                throw;
                            }
                            Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate
                            {
                                pnlStatus.Background = (System.Windows.Media.Brush)FindResource("BGStatusBar");
                            }));

                            try
                            {
                                if (!IsServiceActive())
                                {
                                    Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                                    {
                                        btnServices.Background = LiRed;// System.Windows.Media.Brushes.Red;
                                    }));
                                }
                                else
                                {
                                    Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                                    {
                                        btnServices.Background = LiGreen;// System.Windows.Media.Brushes.YellowGreen;
                                    }));
                                }
                            }
                            catch (Exception)
                            {
                                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                                {
                                    btnServices.Background = LiRed;// System.Windows.Media.Brushes.Red;
                                }));
                            }
                            Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                                   {
                                       GetNotificationCount();
                                       if (lblwelcome.Visibility == Visibility.Visible)
                                       {
                                           lblwelcome.Visibility = Visibility.Hidden;
                                           lblUsername.Visibility = Visibility.Hidden;
                                           lblDate.Visibility = Visibility.Visible;

                                       }
                                       else
                                       {
                                           lblwelcome.Visibility = Visibility.Visible;
                                           lblUsername.Visibility = Visibility.Visible;
                                           lblDate.Visibility = Visibility.Hidden;
                                       }
                                   }));
                            Thread.Sleep(_exchangeServerCheckInterval);
                        }
                    }
                    else
                    {
                        Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                        {
                            lblDatabase.Background = LiRed;// System.Windows.Media.Brushes.Red;
                            btnServices.Background = LiRed;// System.Windows.Media.Brushes.Red;
                        }));
                    }

                }
                catch (ThreadAbortException)
                {
                    LogManager.WriteLog(string.Format("Thread [{0:D}] was aborted.", Thread.CurrentThread.ManagedThreadId), LogManager.enumLogLevel.Error);

                    Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                    {
                        //pnlStatus.Background = System.Windows.Media.Brushes.DarkRed;
                        lblDatabase.Background = LiRed;// System.Windows.Media.Brushes.Red;

                        btnServices.Background = LiRed;// System.Windows.Media.Brushes.Red;
                    }));


                    Thread.Sleep(_exchangeServerCheckInterval);
                }
                catch (Exception ex)
                {
                    ExceptionManager.Publish(ex);

                    Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                    {
                        //pnlStatus.Background = System.Windows.Media.Brushes.DarkRed;
                        lblDatabase.Background = LiRed;// System.Windows.Media.Brushes.Red;
                        btnServices.Background = LiRed;// System.Windows.Media.Brushes.Red;
                    }));

                    Thread.Sleep(_exchangeServerCheckInterval);

                }
                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                     {
                         if (lblDatabase.Background == LiRed)
                         {
                             if (s_status != null)
                             {
                                 s_status.LoadServicesDetails(_serviceDetails, false, false);
                             }
                         }
                     }));


            }
        }
예제 #59
0
파일: Tetris.cs 프로젝트: GPTrixie/Tetris
        private void playSimpleSound()
        {
            simpleSound=new SoundPlayer();
            if (tetris.Musique != 0)
            {
                simpleSound.SoundLocation = @"./Musique\theme" + tetris.Musique + ".wav";
                simpleSound.PlayLooping();
            }
            else
            {
                simpleSound.Stop();

            }
        }
 private void _audioPlay_Click(object sender, EventArgs e)
 {
     var lvi = _audioPatterns.SelectedItems.Cast<ListViewItem>().FirstOrDefault();
     if (lvi != null)
     {
         var setting = (AudioPatternSetting)lvi.Tag;
         string fileName = _audioFileService.ConvertToWav(setting.FileName);
         var player = new SoundPlayer(fileName);
         player.PlayLooping();
         Thread.Sleep(5000);
         player.Stop();
     }
 }