Ejemplo n.º 1
0
 internal void DestroyBeepTimers()
 {
     if (MyBeepTimers != null)
     {
         MyBeepTimers.Delete();
         MyBeepTimers = null;
     }
 }
        private void StopBeeps()
        {
            if (CurrentlyPlayingBeeps == null)
            {
                return;
            }

            CurrentlyPlayingBeeps.Delete();
            CurrentlyPlayingBeeps     = null;
            TbBeepsPlayerBtnText.Text = "Play beeps";
            ImgBeepsPlayer.Source     = PlayIcon;
        }
        private void BtnPlayStopBeeps_Click(object sender, RoutedEventArgs e)
        {
            if (CurrentlyPlayingBeeps != null /* && CurrentlyPlayingBeeps.IsPlaying*/)
            {
                StopBeeps();
                return;
            }

            CurrentlyPlayingBeeps              = DgBeeps.Beeps.CreateBeepTimerCollection(null, true);
            CurrentlyPlayingBeeps.DoneRinging += CurrentlyPlayingBeeps_DoneRinging;
            TbBeepsPlayerBtnText.Text          = "Stop beeps";
            ImgBeepsPlayer.Source              = StopIcon;
        }
Ejemplo n.º 4
0
        internal BeepTimerCollection CreateBeepTimerCollection(TimerData td = null, bool startNow = false)
        {
            var btc = new BeepTimerCollection();

            btc.BeepTimers          = new DispatcherTimer[Count];
            btc.BeepDurations       = new int[Count];
            btc.BeepMsBeforeRinging = new int[Count];
            btc.BeepFrequecies      = new int[Count];

            int i = 0;

            foreach (Beep r in this)
            {
                var t = new DispatcherTimer(DispatcherPriority.Send);
                t.Tick += btc.TickHandler;

                btc.BeepTimers[i]          = t;
                btc.BeepMsBeforeRinging[i] = (int)r.MsBeforeRinging;
                btc.BeepDurations[i]       = (int)r.BeepDuration;
                btc.BeepFrequecies[i]      = (int)r.BeepFrequency;

                int interval = startNow ? 1 :
                               (int)td.CurrentTimeSpan.TotalMilliseconds -
                               btc.BeepMsBeforeRinging[i];

                if (interval > 0)
                {
                    t.Interval = TimeSpan.FromMilliseconds(interval);
                    t.Start();
                }

                ++i;
            }

            return(btc);
        }
Ejemplo n.º 5
0
        internal void UpdateBeepTimers()
        {
            DestroyBeepTimers();

            MyBeepTimers = MyDataFile.Beeps.CreateBeepTimerCollection(this);
        }
 private void CurrentlyPlayingBeeps_DoneRinging(object sender, EventArgs e)
 {
     CurrentlyPlayingBeeps     = null;
     TbBeepsPlayerBtnText.Text = "Play beeps";
     ImgBeepsPlayer.Source     = PlayIcon;
 }