private async void EndShortBreak() { if (Configuration.SaveStats) { Configuration.ShortBreaksCompleted++; UpdateStats(); } UIViewModels.ShortLongBreakTimeRemaining.NextShortBreak = LocalizedEnvironment.Translation.EyesGuard.Waiting; UIViewModels.NotifyIcon.NextShortBreak = LocalizedEnvironment.Translation.EyesGuard.Waiting; await CurrentShortBreakWindow.HideUsingLinearAnimationAsync(); if (CurrentShortBreakWindow != null) { ((ShortBreakWindow)CurrentShortBreakWindow).LetItClose = true; CurrentShortBreakWindow.Close(); CurrentShortBreakWindow = null; } if (!App.Configuration.OnlyOneShortBreak && Configuration.ProtectionState == GuardStates.Protecting) { ShortBreakHandler.Start(); } LongBreakHandler.Start(); ShortDurationCounter.Stop(); UIViewModels.HeaderMenu.ManualBreakEnabled = true; }
public static void UpdateTimeHandlers() { if (Configuration.ProtectionState == GuardStates.Protecting) { if (!(Configuration.OnlyOneShortBreak && ShortBreakShownOnce)) { ShortBreakHandler.Start(); } LongBreakHandler.Start(); } else if (Configuration.ProtectionState == GuardStates.NotProtecting) { ShortBreakHandler.Stop(); LongBreakHandler.Stop(); } }
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; }
private void Application_Startup(object sender, StartupEventArgs e) { // Check if application is running by startup if (e.Args.Length > 0 && e.Args[0] == "/auto") { LaunchMinimized = true; } Configurations.Configuration.InitializeLocalFolder(); Configurations.Configuration.LoadSettingsFromFile(); InitalizeLocalizedEnvironment(); if (programInstancesCount > 1) { MessageBox.Show(LocalizedEnvironment.Translation.Application.DoNotRunMultipleInstances); Shutdown(); } InitializeIdleDetector(Configuration.SystemIdleDetectionEnabled); ToolTipService.ShowDurationProperty.OverrideMetadata( typeof(DependencyObject), new FrameworkPropertyMetadata(int.MaxValue)); if (Configuration.CustomShortMessages.Length == 0) { Configuration.CustomShortMessages = new string[] { "Stare far-off" }; } BasePrequirementsLoaded = true; // Ignore paused protecting state if (Configuration.ProtectionState == GuardStates.PausedProtecting) { Configuration.ProtectionState = GuardStates.Protecting; } if ((int)Configuration.ShortBreakGap.TotalMinutes < 1) { Configuration.ShortBreakGap = new TimeSpan(0, 1, 0); } if ((int)Configuration.LongBreakGap.TotalMinutes < 5) { Configuration.LongBreakGap = new TimeSpan(0, 5, 0); } if ((int)Configuration.ShortBreakDuration.TotalSeconds < 2) { Configuration.ShortBreakDuration = new TimeSpan(0, 0, 2); } if ((int)Configuration.LongBreakDuration.TotalSeconds < 5) { Configuration.LongBreakDuration = new TimeSpan(0, 0, 5); } Configuration.SaveSettingsToFile(); NextShortBreak = Configuration.ShortBreakGap; NextLongBreak = Configuration.LongBreakGap; ShortBreakVisibleTime = Configuration.ShortBreakDuration; LongBreakVisibleTime = Configuration.LongBreakDuration; if (Configuration.ProtectionState == GuardStates.Protecting) { ShortBreakHandler.Start(); LongBreakHandler.Start(); } UpdateShortTimeString(); UpdateLongTimeString(); UpdateKeyTimeVisible(); UpdateStats(); ShortBreakHandler.Tick += ShortBreakHandler_Tick; LongBreakHandler.Tick += LongBreakHandler_Tick; PauseHandler.Tick += PauseHandler_Tick; ShortDurationCounter.Tick += ShortDurationCounter_Tick; LongDurationCounter.Tick += LongDurationCounter_Tick; TaskbarIcon = "App.GlobalTaskbarIcon".Translate <TaskbarIcon>(); TaskbarIcon.DataContext = UIViewModels.NotifyIcon; UpdateTaskbarIcon(); if (TaskbarIcon != null && !Configuration.TrayNotificationSaidBefore) { TaskbarIcon.ShowBalloonTip( LocalizedEnvironment.Translation.Application.Notifications.FirstLaunch.Title, LocalizedEnvironment.Translation.Application.Notifications.FirstLaunch.Message, BalloonIcon.Info); Configuration.TrayNotificationSaidBefore = true; Configuration.SaveSettingsToFile(); } }