Ejemplo n.º 1
0
        private void StopTimer()
        {
            TimerActive = false;

            //Get our start and stop buttons to update their enabled status appropriately
            StartTimerCommand.RaiseCanExecuteChanged();
            StopTimerCommand.RaiseCanExecuteChanged();
        }
Ejemplo n.º 2
0
        public void StartTimer()
        {
            DateStarted = DateTime.Now;
            TimerActive = true;

            //Call RaiseCanExecuteChanged to enable or disable the Start and Stop buttons appropriately
            StartTimerCommand.RaiseCanExecuteChanged();
            StopTimerCommand.RaiseCanExecuteChanged();
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Stop([FromBody] StopTimerCommand command)
        {
            var currentUsername = _userService.GetCurrentUser(this.User).Username;

            command.Username = currentUsername;

            var result = await _mediator.Send(command);

            return(Ok(result));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Called when timer tick event raises.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnTimerTick(object sender, EventArgs e)
        {
            _counter++;
            int seconds = _duration * 60 - _counter;

            RemainingTime = BreakTimerHelper.GetFormattedTimeFromSeconds(seconds);
            if (seconds == 0)
            {
                StopTimerCommand.Execute(null);
            }
        }
 private void UpdateInfo()
 {
     exerciseService = new ExerciseService("ExercisesDbConnection");
     Sections        = mapperDTOToPresent.Map <ObservableCollection <CheckedListExerciseItem> >(exerciseService.GetAll());
     timeLeft        = selectedInterval;
     OnPropertyChanged("TimeLeft");
     if (_shouldStartLoop)
     {
         _isTimerStarted = true;
         StopTimerCommand.RaiseCanExecuteChanged();
         StartTimerCommand.RaiseCanExecuteChanged();
         timer.Start();
     }
 }
 private void timer_Tick(object sender, EventArgs e)
 {
     timeLeft--;
     if (timeLeft >= 0)
     {
         OnPropertyChanged("TimeLeft");
     }
     else
     {
         _isTimerStarted = false;
         StopTimerCommand.RaiseCanExecuteChanged();
         StartTimerCommand.RaiseCanExecuteChanged();
         timer.Stop();
         _shouldStartLoop = true;
         ShowExercisesWindow();
     }
 }
 private void StartTime(object arg)
 {
     if (selectedInterval == 0)
     {
         MessageBox.Show("Нужно выбрать интервал между разминками", "Ошибочка!", MessageBoxButton.OK);
     }
     else if (Sections.Where(checkBox => checkBox.IsChecked == true).Count() < 3)
     {
         MessageBox.Show("Нужно выбрать минимум три упражнения для разминки", "Ошибочка!", MessageBoxButton.OK);
     }
     else
     {
         timeLeft        = selectedInterval;
         _isTimerStarted = true;
         StopTimerCommand.RaiseCanExecuteChanged();
         StartTimerCommand.RaiseCanExecuteChanged();
         exerciseService.UpdateChosenExercises(mapperPresentToDTO.Map <ExerciseDTO[]>(Sections.ToArray()));
         timer.Start();
     }
 }
        /// <summary>
        /// When power mode changed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e)
        {
            switch (e.Mode)
            {
            case PowerModes.Suspend:
                if (_timer.IsEnabled)
                {
                    StopTimerCommand.Execute(null);
                    _isPowerModeChanged = true;
                }
                break;

            case PowerModes.Resume:
                if (_isPowerModeChanged)
                {
                    StartTimerCommand.Execute(null);
                    _isPowerModeChanged = false;
                    CommandManager.InvalidateRequerySuggested();
                }
                break;
            }
        }
        /// <summary>
        /// Timer tick event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnTimerTick(object sender, EventArgs e)
        {
            _counter++;
            int seconds = BreakTimer.Frequency * 60 - _counter;

            RemainingTime = BreakTimerHelper.GetFormattedTimeFromSeconds(seconds);
            if (UserIdleHelper.GetLastInputTime() == BreakTimer.IdleResetTime * 60 && BreakTimer.IsIdleResetActive)
            {
                StopTimerCommand.Execute(null);
            }
            else if (seconds == BreakTimer.NextBreakAlert)
            {
                StopTimerCommand.Execute(null);
                if (BreakTimer.NextBreakAlert != 0)
                {
                    NotifyNextBreak(BreakTimer.NextBreakAlert);
                }
                else
                {
                    StartRelaxation();
                }
            }
        }