diff --git a/src/Local/ProjectEye/Core/Service/MainService.cs b/src/Local/ProjectEye/Core/Service/MainService.cs index af3ecec..1b29b25 100644 --- a/src/Local/ProjectEye/Core/Service/MainService.cs +++ b/src/Local/ProjectEye/Core/Service/MainService.cs @@ -43,6 +43,14 @@ public class MainService : IService /// private DispatcherTimer useeye_timer; /// + /// 日期更改计时,用于处理日期变化 + /// + private DispatcherTimer date_timer; + /// + /// 日期更改计时重置标记 + /// + private bool isDateTimerReset; + /// /// 预提醒操作 /// private PreAlertAction preAlertAction; @@ -129,6 +137,9 @@ public void Init() useeye_timer = new DispatcherTimer(); useeye_timer.Tick += new EventHandler(useeye_timer_Tick); useeye_timer.Interval = new TimeSpan(0, 10, 0); + + date_timer = new DispatcherTimer(); + date_timer.Tick += new EventHandler(date_timer_Tick); /****调试模式代码****/ #if DEBUG //30秒提示休息 @@ -145,11 +156,18 @@ public void Init() //记录鼠标坐标 SaveCursorPos(); + UpdateDateTimer(); + Start(); config.Changed += Config_Changed; + + + } + + private void Config_Changed(object sender, EventArgs e) { var oldOptions = sender as OptionsModel; @@ -210,6 +228,25 @@ private void leave_timer_Tick(object sender, EventArgs e) SaveCursorPos(); } + private void date_timer_Tick(object sender, EventArgs e) + { + + date_timer.Stop(); + if (!isDateTimerReset) + { + //重置统计时间 + statistic.StatisticUseEyeData(); + //延迟2分钟后重置timer + isDateTimerReset = true; + date_timer.Interval = new TimeSpan(0, 2, 0); + date_timer.Start(); + } + else + { + UpdateDateTimer(); + } + } + #region 获取下一次休息剩余分钟数 public double GetRestCountdownMinutes() { @@ -403,7 +440,7 @@ private void ShowTipWindow() } else { - if (isBreakReset()) + if (IsBreakReset()) { statistic.Add(StatisticType.SkipCount, 1); ReStartWorkTimerWatch(); @@ -509,7 +546,7 @@ public void SetPreAlertAction(PreAlertAction preAlertAction) /// 是否跳过本次休息 /// /// true跳过,false不跳过 - public bool isBreakReset() + public bool IsBreakReset() { if (!config.options.General.Noreset) { @@ -573,5 +610,25 @@ public void CreateTipWindows() } } #endregion + + #region 更新日期更改计时时间 + /// + /// 更新日期更改计时时间 + /// + private void UpdateDateTimer() + { + + DateTime now = DateTime.Now; + DateTime morrow = new DateTime(now.Year, now.Month, now.Day, 23, 59, 0); + int diffseconds = (int)morrow.Subtract(now).TotalSeconds; + if (diffseconds < 0) + { + diffseconds = 0; + } + date_timer.Interval = new TimeSpan(0, 0, diffseconds); + date_timer.Start(); + isDateTimerReset = false; + } + #endregion } } diff --git a/src/Local/ProjectEye/Core/Service/PreAlertService.cs b/src/Local/ProjectEye/Core/Service/PreAlertService.cs index 3d30d84..18bef87 100644 --- a/src/Local/ProjectEye/Core/Service/PreAlertService.cs +++ b/src/Local/ProjectEye/Core/Service/PreAlertService.cs @@ -226,7 +226,7 @@ private void preAlertTimer_Tick(object sender, EventArgs e) //到达预提醒时间弹出通知 Debug.WriteLine(DateTime.Now.ToString()); - if (main.isBreakReset()) + if (main.IsBreakReset()) { //跳过本次 SetPreAlertAction(PreAlertAction.Break); diff --git a/src/Local/ProjectEye/Core/Win32APIHelper.cs b/src/Local/ProjectEye/Core/Win32APIHelper.cs index d0155c4..9f2b807 100644 --- a/src/Local/ProjectEye/Core/Win32APIHelper.cs +++ b/src/Local/ProjectEye/Core/Win32APIHelper.cs @@ -128,6 +128,13 @@ public static WindowInfo GetFocusWindowInfo() //非最大化状态下计算判断全屏 result.IsFullScreen = result.Width >= SystemParameters.PrimaryScreenWidth && result.Height >= SystemParameters.PrimaryScreenHeight; } + //浏览器全屏判断 + if (result.ClassName.ToLower().IndexOf("chrome_widgetwin") != -1) + { + //chrome浏览器比较特殊,全屏模式不能被识别,需要另外计算 + result.IsFullScreen = result.Width >= SystemParameters.PrimaryScreenWidth && result.Height >= SystemParameters.PrimaryScreenHeight; + result.IsZoomed = !result.IsFullScreen; + } return result; } #endregion