예제 #1
0
        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}");
            }
        }
예제 #2
0
 private void DoSaveExecute()
 {
     Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
     try
     {
         if (IsEditing)
         {
             if (SelectedAdvice != null)
             {
                 DBSingleton.getInstance().DeleteAdvice(SelectedAdvice.id);
             }
         }
         DBSingleton.getInstance().InsertAdvice(NewAdvice);
         IsEditing = false;
     }
     catch (System.Exception ex)
     {
         MessageBox.Show("Exception found on DoSave :" + ex.Message);
     }
     finally
     {
         PopulateTheAdviceList();
         Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow;
     }
 }
예제 #3
0
 private void DoDeleteExecute()
 {
     Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
     try
     {
         if (SelectedAdvice != null)
         {
             if (MessageBox.Show("Do you confirm?", "???", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
             {
                 DBSingleton.getInstance().DeleteAdvice(SelectedAdvice.id);
             }
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show("Exception found on DoDelete :" + ex.Message);
     }
     finally
     {
         Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow;
         PopulateTheAdviceList();
     }
 }
예제 #4
0
        private void PopulateTheAdviceList()
        {
            try
            {
                TheAdviceList = new ObservableCollection <PauseAdvice>();

                var advices = DBSingleton.getInstance().GetAllAdvices();

                if (advices != null && advices.Count > 0)
                {
                    advices.ForEach(x => TheAdviceList.Add(x));
                }
            }
            catch (Exception e)
            {
                MessageBox.Show($"PopulateTheAdviceList: {e.Message}");
            }
            finally
            {
                RaisePropertyChanged("TheAdviceList");
                ResetAdvice();
                DBSingleton.getInstance().ResetAdviceViews(); // warning: bug generator!
            }
        }