private void TryShowPauseAdvice()
        {
            try
            {
                if (SettingsSingleton.getInstance().shouldDisplayPauseAdvices())
                {
                    if (File.Exists("DefaultPauseAdvices.txt"))
                    {
                        var lines = File.ReadAllLines("DefaultPauseAdvices.txt");
                        if (lines != null && lines.Length > 0)
                        {
                            lines.Where(x => x.Length > 0).ToList()
                            .ForEach(x => DBSingleton.getInstance().InsertAdvice(x));
                        }
                        File.WriteAllText("DefaultPauseAdvices.txt", "");
                    }

                    string randomAdvice = DBSingleton.getInstance().GetRandomAdvice();

                    notifier.ShowSuccess($"Pause suggestion: '{randomAdvice}'"); //MessageBox.Show(randomAdvice);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show($"Error on TryShowPauseAdvice: {e.Message}");
            }
        }
        private void OnAtentionTimerdEvent(object source, ElapsedEventArgs e)
        {
            if (++deadTimeSeconds >= SettingsSingleton.getInstance().getSecondsUntilDesperateAlert())
            {
                this.Dispatcher.Invoke(() =>
                {
                    if (deadTimeSeconds % 2 == 0)
                    {
                        this.Icon = new BitmapImage(new Uri("pack://application:,,,/OpenPomodoro;component/img/attention-icon.png"));
                    }
                    else
                    {
                        this.Icon = new BitmapImage(new Uri("pack://application:,,,/OpenPomodoro;component/img/tomato-icon.png"));
                    }

                    if (deadTimeSeconds % 7 == 0)
                    {
                        this.Background = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0));
                    }
                    else
                    {
                        this.Background = new SolidColorBrush(Color.FromArgb(255, 233, 236, 255));
                    }

                    if (deadTimeSeconds % 40 == 0)
                    {
                        System.Media.SystemSounds.Beep.Play();
                    }
                });
            }
        }
Beispiel #3
0
        public static SettingsSingleton getInstance()
        {
            if (_instance == null)
            {
                _instance = new SettingsSingleton();

                _instance.LoadSettings();
            }
            return(_instance);
        }
 private void menuStartLongPause_Click(object sender, RoutedEventArgs e)
 {
     targetSeconds = SettingsSingleton.getInstance().GetDurationLongPause();
     this.SetWindowState(WStates.PAUSING_LONG);
 }
        private void SetWindowState(int state)
        {
            CleanMenu();

            previouWindowState = currentWindowState;
            currentWindowState = state;

            switch (state)
            {
            case WStates.DEFAULT:
                ClearAlert();
                mainBar.Value            = 0;
                menuStartWork.Visibility = Visibility.Visible;
                break;

            case WStates.WORKING:
                ClearAlert();
                ChangeTheme("red");
                targetSeconds = SettingsSingleton.getInstance().getDurationWork();;
                Pomodoros.Add(WORK_INPROGRESS);
                startTime = DateTime.Now;
                workTimer.Start();
                menuCancelProgres.Visibility        = Visibility.Visible;
                menuForceCompleteProgres.Visibility = Visibility.Visible;
                PomodoroDatabase.DBSingleton.getInstance().StartPomodoro();
                break;

            case WStates.FINISHED_WORK:
                Pomodoros.Remove(WORK_INPROGRESS);
                Pomodoros.Add(WORK_COMPLETED);
                SetWindowState(WStates.STOP);
                PomodoroDatabase.DBSingleton.getInstance().CompletePomodoro();
                break;

            case WStates.STOP:     // = CANCEL
                workTimer.Stop();
                Pomodoros.Remove(WORK_INPROGRESS);
                Pomodoros.Remove(PAUSE_IN_PROGRES);
                System.Media.SystemSounds.Asterisk.Play();
                System.Media.SystemSounds.Asterisk.Play();
                SetWindowState(WStates.ALERTING);
                break;

            case WStates.PAUSING:
            case WStates.PAUSING_LONG:
                ClearAlert();
                ChangeTheme("green");
                Pomodoros.Add(PAUSE_IN_PROGRES);
                startTime = DateTime.Now;
                workTimer.Start();
                menuCancelProgres.Visibility        = Visibility.Visible;
                menuForceCompleteProgres.Visibility = Visibility.Visible;
                TryShowPauseAdvice();
                break;

            case WStates.FINISHED_PAUSE:
                Pomodoros.Remove(PAUSE_IN_PROGRES);
                if (previouWindowState == WStates.PAUSING_LONG)
                {
                    Pomodoros.Add(PAUSE_COMPLETED);
                    Pomodoros.Add(PAUSE_COMPLETED);
                    Pomodoros.Add(PAUSE_COMPLETED);
                }
                else
                {
                    Pomodoros.Add(PAUSE_COMPLETED);
                }
                SetWindowState(WStates.STOP);
                break;

            case WStates.ALERTING:
                ChangeTheme("blue");

                menuStartShortPause.Visibility = Visibility.Visible;
                menuStartLongPause.Visibility  = Visibility.Visible;
                menuStartWork.Visibility       = Visibility.Visible;

                deadTimeSeconds = 0;
                getAttentionTimer.Start();

                break;
            }
        }