コード例 #1
0
        private void StopTimer()
        {
            TimerActive = false;

            //Get our start and stop buttons to update their enabled status appropriately
            StartTimerCommand.RaiseCanExecuteChanged();
            StopTimerCommand.RaiseCanExecuteChanged();
        }
コード例 #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();
        }
コード例 #3
0
 private void StopTime(object arg)
 {
     _isTimerStarted  = false;
     _shouldStartLoop = false;
     StopTimerCommand.RaiseCanExecuteChanged();
     StartTimerCommand.RaiseCanExecuteChanged();
     timer.Stop();
     timeLeft = 0;
     OnPropertyChanged("TimeLeft");
 }
コード例 #4
0
        public async Task <IActionResult> Start([FromBody] StartTimerCommand command)
        {
            var currentUsername = _userService.GetCurrentUser(this.User).Username;

            command.Username = currentUsername;

            var result = await _mediator.Send(command);

            return(Ok(result));
        }
コード例 #5
0
 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();
     }
 }
コード例 #6
0
        void TimerView_SizeChanged(object sender, EventArgs e)
        {
            if (Width == 0 || Height == 0)
            {
                return;
            }

            if (TrackBar == null || ProgressBar == null)
            {
                return;
            }

            if (Children.Count == 0)
            {
                //ensure track-bar gets full width and height as parent
                AddTrackBar();

                //ensure progress-bar gets full height, but width can be changed
                AddProgressBar();

                //if timer-label available, ensure it gets full width and height
                if (TimerLabel != null)
                {
                    AddTimerLabel();
                    TimerLabel.SetBinding(BindingContextProperty, new Binding(nameof(RemainingTime), source: this));
                }

                if (AutoStart)
                {
                    StartTimerCommand.Execute(Time);
                }
            }
            else
            {
                if (IsTimerRunning)
                {
                    //if timer runnnig already - restart animation
                    ProgressBar.CancelWidthToAnimation();
                    StartTimerCommand.Execute(null); //Use remaining time
                }
                else
                {
                    SetProgressBarWidth();
                }
            }
        }
コード例 #7
0
 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();
     }
 }
コード例 #8
0
        /// <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;
            }
        }
コード例 #9
0
        /// <summary>
        ///     Notify the user about the next break.
        /// </summary>
        /// <param name="seconds"></param>
        private void NotifyNextBreak(int seconds)
        {
            BreakNotifierViewModel breakNotifierViewModel = new BreakNotifierViewModel(seconds);
            BreakNotifierView      breakNotifierView      = new BreakNotifierView {
                DataContext = breakNotifierViewModel
            };

            if (breakNotifierView.ShowDialog() == true)
            {
                if (breakNotifierViewModel.IsManuallyStopped)
                {
                    return;
                }
                else if (breakNotifierViewModel.IsNextBreakSkipped)
                {
                    StartTimerCommand.Execute(null);
                }
                else
                {
                    StartRelaxation();
                }
            }
        }