// push on cancel button or call from method
 public void OnCancelButton()
 {
     timerTimer.Stop();
     ButtonStatModel = new ButtonStatModel {
         IsTimerStarted = false, IsTimerTicking = false, Text = "Старт", ButtonColor = SolidColorBrush.Parse("#1A361F"), TextColor = SolidColorBrush.Parse("#56D45B")
     };
     TimerModel = new TimerModel {
         Hours = timerHours, Minutes = timerMinutes, Seconds = timerSeconds
     };
 }
 public void OnStartButton()
 {
     // don't allow to start with default values
     if (TimerModel.Hours == 0 && TimerModel.Minutes == 0 && TimerModel.Seconds == 0)
     {
         return;
     }
     if (ButtonStatModel.IsTimerStarted == false)
     {
         ButtonStatModel = new ButtonStatModel {
             IsTimerStarted = true, IsTimerTicking = true, Text = "Пауза", ButtonColor = SolidColorBrush.Parse("#3D2809"), TextColor = SolidColorBrush.Parse("#D67E00")
         };
         timerHours   = TimerModel.Hours;
         timerMinutes = TimerModel.Minutes;
         timerSeconds = TimerModel.Seconds;
         timer        = new TimeSpan(TimerModel.Hours, TimerModel.Minutes, TimerModel.Seconds);
         timerTimer.Start();
     }
     else
     {
         if (ButtonStatModel.IsTimerTicking == true)
         {
             timerTimer.Stop();
             ButtonStatModel = new ButtonStatModel {
                 IsTimerStarted = true, IsTimerTicking = false, Text = "Дальше", ButtonColor = SolidColorBrush.Parse("#1A361F"), TextColor = SolidColorBrush.Parse("#56D45B")
             };
         }
         else
         {
             timerTimer.Start();
             ButtonStatModel = new ButtonStatModel {
                 IsTimerStarted = true, IsTimerTicking = true, Text = "Пауза", ButtonColor = SolidColorBrush.Parse("#3D2809"), TextColor = SolidColorBrush.Parse("#D67E00")
             };
         }
     }
 }
        public MainWindowViewModel(MainWindow mainWindow)
        {
            this.MainWindow = mainWindow;

            // set default values
            WeatherModel = new WeatherModel
            {
                Status = "Weather forecast is loading...",
                Fact   = new Fact
                {
                    Temp        = "Loading...",
                    Feels_like  = "Loading...",
                    Humidity    = "Loading...",
                    Pressure_mm = "Loading...",
                    UvIndex     = "Loading..."
                }
            };

            ToDoListModel = new ToDoListModel
            {
                Status        = "To-do list is loading...",
                toDoListItems = new List <ToDoListItem>()
            };

            TimerModel = new TimerModel
            {
                Hours   = 1,
                Minutes = 30,
                Seconds = 0
            };

            ButtonStatModel = new ButtonStatModel
            {
                IsTimerStarted = false,
                IsTimerTicking = false,
                Text           = "Старт",
                ButtonColor    = SolidColorBrush.Parse("#1A361F"),
                TextColor      = SolidColorBrush.Parse("#56D45B")
            };

            WidgetColor = new WidgetColor
            {
                TimeColor     = SolidColorBrush.Parse("#505356"),
                WeatherColor  = SolidColorBrush.Parse("#3F4041"),
                TimerColor    = SolidColorBrush.Parse("#282828"),
                TodoListColor = SolidColorBrush.Parse("#252328"),
                NewsColor     = SolidColorBrush.Parse("#4E4C48"),
                EngWordColor  = SolidColorBrush.Parse("#393E41")
            };

            EngTranslatedWordModel = new EngTranslatedWordModel
            {
                Status = "Word of the day is loading..."
            };

            NewsModel = new NewsModel
            {
                LatestTitle = "News are loading..."
            };

            // set timers condition
            timerForecast = new DispatcherTimer
            {
                Interval = TimeSpan.FromHours(1)
            };
            timerForecast.Tick += OnTimedEventForecast;
            timerForecast.Start();

            timerToDo = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(5)
            };
            timerToDo.Tick += OnTimedEventToDoList;
            timerToDo.Start();

            timerTime = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(1)
            };
            timerTime.Tick += OnTimedEventTime;
            timerTime.Start();

            timerTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(1)
            };
            timerTimer.Tick += OnTimedEventTimer;

            timerFlash = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(250)
            };
            timerFlash.Tick += OnTimedEventFlash;

            timerEngWord = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(500)
            };
            timerEngWord.Tick += OnTimedEvent5AM;
            timerEngWord.Start();

            timerNews = new DispatcherTimer
            {
                Interval = TimeSpan.FromMinutes(1)
            };
            timerNews.Tick += OnTimedEventNews;
            timerNews.Start();

            // trigger some events one time at start of project
            OnTimedEventForecast();
            OnTimedEventToDoList();
            OnTimedEventTime();
            OnTimedEvent5AM();
            OnTimedEventNews();
        }