예제 #1
0
        private void tbtStop_Click(object sender, EventArgs e)
        {
            foreach (Thread t in pingThreads)
            {
                try
                {
                    t.Abort();
                }
                catch (Exception)
                {
                }
            }
            pingThreads.Clear();
            pingStatus.Clear();

            string timestamp = DateTime.Now.ToString();

            lvwLog.Items.Add(timestamp);
            lastidx++;

            tmrBanner.Stop();

            lvwLog.Items[lastidx].SubItems.Add("Ping Stop");

            tbtStart.Enabled = true;
            tbtSvchk.Enabled = true;
            tbtStop.Enabled  = false;
            tbtAdd.Enabled   = true;

            player.Close();

            if (ischk)
            {
            }
        }
예제 #2
0
 public void Dispose()
 {
     if (me != null)
     {
         me.Stop();
         me.Close();
         me = null;
     }
 }
예제 #3
0
 private void timer4_Tick(object sender, EventArgs e)
 {
     if (alive == true)
     {
         gr.DrawImage(drone.droneimg, drone.position);
         time4 += timer4.Interval;
         if (time4 >= 10)
         {
             time4 = 0;
             if (drone.position.Y < 300 && posit == false)
             {
                 drone.position.Y += 3;
                 if (drone.position.Y > 270)
                 {
                     posit = true;
                 }
             }
             if (drone.position.Y > 100 && posit == true)
             {
                 drone.position.Y -= 3;
                 if (drone.position.Y < 130)
                 {
                     posit = false;
                 }
             }
         }
         if (pictureBox2.Width == 0)
         {
             alive = false;
         }
     }
     if (alive == false && message == false)
     {
         time4 += timer4.Interval;
         gr.DrawImage(drone.deaddrone[drone.currentimage], drone.position);
         if (time4 >= 50)
         {
             drone.currentimage++;
             if (drone.currentimage == 6)
             {
                 System.Windows.Media.MediaPlayer backgroundMusic;
                 backgroundMusic = new System.Windows.Media.MediaPlayer();
                 backgroundMusic.Open(new Uri(Directory.GetCurrentDirectory() + "\\guchimuchi.wav"));
                 backgroundMusic.Play();
                 message         = true;
                 backgroundMusic = new System.Windows.Media.MediaPlayer();
                 backgroundMusic.Open(new Uri(Directory.GetCurrentDirectory() + "\\golos.wav"));
                 backgroundMusic.Play();
                 MessageBox.Show("Вы пабидили)))");
                 backgroundMusic.Stop();
                 backgroundMusic.Close();
                 this.Close();
             }
         }
     }
 }
예제 #4
0
 private void PlayMusic(int a)
 {
     System.Windows.Media.MediaPlayer backgroundMusic;
     backgroundMusic = new System.Windows.Media.MediaPlayer();
     backgroundMusic.Open(new Uri(Directory.GetCurrentDirectory() + "\\Harppen.wav"));
     backgroundMusic.Play();
     if (a == 0)
     {
         backgroundMusic.Stop();
         backgroundMusic.Close();
     }
 }
예제 #5
0
 private void timer3_Tick(object sender, EventArgs e)
 {
     gr.DrawImage(vehicle.imagesvehicles[vehicle.currentimage], vehicle.position);
     time3 += timer3.Interval;
     if (time3 >= 10 && viselzagran == false)
     {
         vehicle.position.X -= 10;
         time3 = 0;
         if (vehicle.position.X < -500)
         {
             viselzagran = true;
         }
     }
     if (viselzagran == true)
     {
         vehicle.currentimage++;
         if (vehicle.currentimage == 4)
         {
             vehicle.currentimage = 0;
         }
         vehicle.position.X = 1500;
         viselzagran        = false;
         udar = false;
     }
     if (vehicle.position.Y + 20 > player.position.Y && vehicle.position.Y - 10 < player.position.Y && vehicle.position.X + 50 > player.position.X && vehicle.position.X - 40 < player.position.X && udar == false)
     {
         System.Windows.Media.MediaPlayer backgroundMusic;
         backgroundMusic = new System.Windows.Media.MediaPlayer();
         backgroundMusic.Open(new Uri(Directory.GetCurrentDirectory() + "\\uron.wav"));
         backgroundMusic.Play();
         udar      = true;
         HP.Width -= 100;
     }
     if (HP.Width == 0 && message == false)
     {
         System.Windows.Media.MediaPlayer backgroundMusic;
         backgroundMusic = new System.Windows.Media.MediaPlayer();
         backgroundMusic.Open(new Uri(Directory.GetCurrentDirectory() + "\\golos.wav"));
         backgroundMusic.Play();
         message = true;
         MessageBox.Show("Вы погибли(((");
         backgroundMusic.Stop();
         backgroundMusic.Close();
         this.Close();
     }
 }
예제 #6
0
        TimeSpan GetWaveDuration(string fileName)
        {
            try
            {
                var player = new System.Windows.Media.MediaPlayer();
                player.Open(new Uri(fileName, UriKind.Absolute));
                var duration = player.NaturalDuration;
                player.Close();

                if (duration.HasTimeSpan)
                {
                    return(duration.TimeSpan);
                }
            }
            catch
            {
            }
            return(TimeSpan.Zero);
        }
예제 #7
0
 public static void MediaEnded(Action <bool> StartStopTimer, bool forceStop = false)
 {
     if (remainingNotifications > 0 && forceStop == false)
     {
         remainingNotifications--;
         player.Stop();
         Thread.Sleep(300);
         player.Play();
     }
     else
     {
         player.Close();
         soundIsPlaying = false;
         player         = new System.Windows.Media.MediaPlayer(); // doesn't work otherwise?
         if (StartStopTimer != null)
         {
             StartStopTimer(false);
         }
     }
 }
예제 #8
0
        private void createSession()
        {
            var playlists = readPlaylists();

            while (playlists.Count > 0)
            {
                Random r        = new Random();
                int    i        = r.Next(playlists.Count);
                string playlist = playlists[i];
                lock (playlists)
                {
                    playlists.RemoveAt(i);
                }

                var songs = readSongs(playlist);

                if (songs.Count > 0)
                {
                    int hourInSec = 60 * 60;
                    int duration  = 0;

                    var programme = new List <string>();

                    while (duration < hourInSec)
                    {
                        r = new Random();
                        if (songs.Count > 1)
                        {
                            i = r.Next(songs.Count - 1);
                        }
                        else if (songs.Count == 0)
                        {
                            songs = readSongs(playlist);
                        }
                        else
                        {
                            i = 0;
                        }

                        string song = songs[i];
                        songs.RemoveAt(i);

                        programme.Add(song);

                        System.Windows.Media.MediaPlayer m = new System.Windows.Media.MediaPlayer();
                        m.Open(new Uri(song));
                        while (!m.NaturalDuration.HasTimeSpan)
                        {
                            ;
                        }
                        duration += (int)m.NaturalDuration.TimeSpan.TotalSeconds;
                        m.Close();
                    }

                    lock (programmes)
                    {
                        string key = new FileInfo(playlist).Name;

                        if (!programmes.ContainsKey(key))
                        {
                            programmes.Add(key, programme);
                        }
                    }
                }
            }
        }