示例#1
0
        private async void CloseLongBreak_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                LetItClose = true;
                if (App.Configuration.SaveStats)
                {
                    App.Configuration.LongBreaksFailed++;
                    App.Configuration.SaveSettingsToFile();
                }
                await App.CurrentLongBreakWindow.HideUsingLinearAnimationAsync();

                App.CurrentLongBreakWindow.Close();
                App.CurrentLongBreakWindow = null;
                App.ShortBreakShownOnce    = false;
                if (App.Configuration.ProtectionState == GuardStates.Protecting)
                {
                    App.ShortBreakHandler.Start();
                    App.LongBreakHandler.Start();
                }
                LongDurationCounter.Stop();
                App.UIViewModels.HeaderMenu.ManualBreakEnabled = true;
            }
            catch { }
        }
        public async void StartLongBreak()
        {
            ShortBreakHandler.Stop();
            LongBreakHandler.Stop();
            UIViewModels.HeaderMenu.ManualBreakEnabled             = false;
            UIViewModels.ShortLongBreakTimeRemaining.NextLongBreak = LocalizedEnvironment.Translation.EyesGuard.Resting;
            UIViewModels.NotifyIcon.NextLongBreak = LocalizedEnvironment.Translation.EyesGuard.Resting;

            NextShortBreak = App.Configuration.ShortBreakGap;
            NextLongBreak  = App.Configuration.LongBreakGap;

            var longWindow = new LongBreakWindow()
            {
                DataContext = UIViewModels.LongBreak
            };

            LongBreakVisibleTime = App.Configuration.LongBreakDuration;
            UIViewModels.LongBreak.TimeRemaining =
                LocalizedEnvironment.Translation.EyesGuard.LongBreakTimeRemaining.FormatWith(new
            {
                LongBreakVisibleTime.Hours,
                LongBreakVisibleTime.Minutes,
                LongBreakVisibleTime.Seconds
            });

            UIViewModels.LongBreak.CanCancel = (Configuration.ForceUserToBreak) ? Visibility.Collapsed : Visibility.Visible;

            if (CurrentShortBreakWindow != null)
            {
                ((ShortBreakWindow)CurrentShortBreakWindow).LetItClose = true;
                CurrentShortBreakWindow.Close();
                CurrentShortBreakWindow = null;
            }
            ShortDurationCounter.Stop();
            await longWindow.ShowUsingLinearAnimationAsync();

            longWindow.Show();
            longWindow.BringIntoView();
            longWindow.Focus();

            LongDurationCounter.Start();
        }
        private async Task EndLongBreak()
        {
            ((LongBreakWindow)CurrentLongBreakWindow).LetItClose = true;
            if (Configuration.SaveStats)
            {
                Configuration.LongBreaksCompleted++;
                UpdateStats();
            }
            await CurrentLongBreakWindow.HideUsingLinearAnimationAsync();

            CurrentLongBreakWindow.Close();
            CurrentLongBreakWindow = null;
            ShortBreakShownOnce    = false;
            if (Configuration.ProtectionState == GuardStates.Protecting)
            {
                ShortBreakHandler.Start();
                LongBreakHandler.Start();
            }
            LongDurationCounter.Stop();

            UIViewModels.HeaderMenu.ManualBreakEnabled = true;
        }