public void OnTimerStateChanged(object sender, TimerEventArgs e) { switch (Pomodoro.State) { case TimerServiceState.Stopped: CommandLabel = "Start"; break; case TimerServiceState.Running: CommandLabel = "Pause"; break; case TimerServiceState.Paused: CommandLabel = "Resume"; break; default: break; } Display = Pomodoro.TimeString(); Progress = Pomodoro.Progress; ((JFCommand)CancelTimerCommand).RaiseCanExecuteChanged(); }
public TimerViewModel() { CurrentSession = new PomodoroSession(); Pomodoro = new Pomodoro(10, 5); Display = Pomodoro.TimeString(); Pomodoro.IntervalComplete += OnIntervalComplete; Pomodoro.StateChanged += OnTimerStateChanged; Pomodoro.ModeChanged += OnPomodoroChanged; ToggleStartCommand = new JFCommand( _ => true, _ => { ToggleTimer(); } ); CancelTimerCommand = new JFCommand( _ => Pomodoro.State != TimerServiceState.Stopped, _ => { StopTimer(); } ); }