Esempio n. 1
0
        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;
        }
 private void UpdateValue(PomodoroTimer model)
 {
     CurrentPreriodTime = model.CurrentPreriodTime;
     CurrentPeriod = model.CurrentPeriod;
     CurrentTime = model.CurrentTime;
     IsStopped = model.IsStopped;
     IsWorking = model.IsWorking;
 }
Esempio n. 4
0
 public Pomodoro()
 {
     LoaderSaver = new LoaderSaver();
     Setting = LoaderSaver.Load();
     Timer = new PomodoroTimer(Setting);
 }
Esempio n. 5
0
 /// <summary>
 /// Конструтоктор состояния паузы
 /// </summary>
 /// <param name="_pomodoroTimer">Таймеры</param>
 public PauseState(PomodoroTimer _pomodoroTimer)
 {
     pomodoroTimer = _pomodoroTimer;
 }