Skip to content

Commit

Permalink
Merge pull request #49 from Planshit/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
noberumotto authored May 10, 2020
2 parents 33b8742 + 3fc73da commit ab5ee03
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
61 changes: 59 additions & 2 deletions src/Local/ProjectEye/Core/Service/MainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ public class MainService : IService
/// </summary>
private DispatcherTimer useeye_timer;
/// <summary>
/// 日期更改计时,用于处理日期变化
/// </summary>
private DispatcherTimer date_timer;
/// <summary>
/// 日期更改计时重置标记
/// </summary>
private bool isDateTimerReset;
/// <summary>
/// 预提醒操作
/// </summary>
private PreAlertAction preAlertAction;
Expand Down Expand Up @@ -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秒提示休息
Expand All @@ -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;
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -403,7 +440,7 @@ private void ShowTipWindow()
}
else
{
if (isBreakReset())
if (IsBreakReset())
{
statistic.Add(StatisticType.SkipCount, 1);
ReStartWorkTimerWatch();
Expand Down Expand Up @@ -509,7 +546,7 @@ public void SetPreAlertAction(PreAlertAction preAlertAction)
/// 是否跳过本次休息
/// </summary>
/// <returns>true跳过,false不跳过</returns>
public bool isBreakReset()
public bool IsBreakReset()
{
if (!config.options.General.Noreset)
{
Expand Down Expand Up @@ -573,5 +610,25 @@ public void CreateTipWindows()
}
}
#endregion

#region 更新日期更改计时时间
/// <summary>
/// 更新日期更改计时时间
/// </summary>
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
}
}
2 changes: 1 addition & 1 deletion src/Local/ProjectEye/Core/Service/PreAlertService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions src/Local/ProjectEye/Core/Win32APIHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ab5ee03

Please sign in to comment.