跳到主要内容

github/tai

公开

Tai · Windows 软件与网站使用时长统计。上游 Planshit/Tai 的源码镜像,非灵栈原创;MIT 许可。来源:https://github.com/Planshit/Tai 。本次为手动同步,暂不提供安装包。

提交记录
修改Core/Servicers/Instances/Sleepdiscover.cs+25 −0看文件
@@ -2,6 +2,7 @@
22using Core.Event;
33using Core.Librarys;
44using Core.Servicers.Interfaces;
5新增:using Microsoft.Win32;
56using System;
67using System.Collections.Generic;
78using System.Diagnostics;
@@ -32,6 +33,30 @@ namespace Core.Servicers.Instances
3233 {
3334 this.observer = observer;
3435 observer.OnAppActive += Observer_OnAppActive;
36新增: SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(OnPowerModeChanged);
37新增: }
38新增:
39新增: private void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e)
40新增: {
41新增: switch (e.Mode)
42新增: {
43新增: case PowerModes.Suspend:
44新增: //电脑休眠
45新增: if (status == SleepStatus.Wake)
46新增: {
47新增: status = SleepStatus.Sleep;
48新增: SleepStatusChanged?.Invoke(status);
49新增: }
50新增: break;
51新增: case PowerModes.Resume:
52新增: //电脑恢复
53新增: if (status == SleepStatus.Sleep)
54新增: {
55新增: status = SleepStatus.Wake;
56新增: SleepStatusChanged?.Invoke(status);
57新增: }
58新增: break;
59新增: }
3560 }
3661
3762 private void Observer_OnAppActive(string processName, string description, string file)