public MainContainer() { pomodoroTimerModelSetting = new PomodoroTimerSetting(); pomodoroModelTimer = new PomodoroTimer(pomodoroTimerModelSetting); PomodoroTimerSettings = new PomodoroViewModelTimerSettings(pomodoroTimerModelSetting); PomodoroTimer = new PomodoroViewModelTimer(pomodoroModelTimer); ViewModelCommand command = new ViewModelCommand(PomodoroTimer, "IsStopped"); command.Predicate = o => PomodoroTimer.IsStopped; command.Action = o => loaderSaver.Save(pomodoroTimerModelSetting); SaveSettingCommand = command; }
public PomodoroViewModelTimer(PomodoroTimer _pomodoroTimer) { pomodoroTimer = _pomodoroTimer; ViewModelCommand command; command = new ViewModelCommand(this, new List<string>() { "IsStopped", "IsWorking" }); command.Action = o => pomodoroTimer.PlayTimer(); command.Predicate = o => { return pomodoroTimer.IsStopped || !pomodoroTimer.IsStopped && !pomodoroTimer.IsWorking; }; StartCommand = command; command = new ViewModelCommand(this, "IsStopped"); command.Action = o => pomodoroTimer.StopTimer(); command.Predicate = o => true; StopCommand = command; command = new ViewModelCommand(this, "IsWorking"); command.Action = o => pomodoroTimer.PauseTimer(); command.Predicate = o => { return pomodoroTimer.IsWorking; }; PauseCommand = command; command = new ViewModelCommand(this, "IsStopped"); command.Action = o => pomodoroTimer.GoToNextPeriod(); command.Predicate = o => pomodoroTimer.IsStopped; GoToNextPeriodCommand = command; command = new ViewModelCommand(this, "IsStopped"); command.Action = o => pomodoroTimer.GoToPreviosPeriod(); command.Predicate = o => pomodoroTimer.IsStopped; GoToPreviosPeriodCommand = command; UpdateValue(pomodoroTimer); pomodoroTimer.Updated += pomodoroTimer_Updated; }