跳到主要内容

github/tai

公开

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

提交记录
修改Core/Event/ObserverEventHandler.cs+3 −2看文件
@@ -1,4 +1,5 @@
1删除:using System;
1新增:using Core.Models.AppObserver;
2新增:using System;
23using System.Collections.Generic;
34using System.Linq;
45using System.Text;
@@ -6,5 +7,5 @@ using System.Threading.Tasks;
67
78namespace Core.Event
89{
9删除: public delegate void ObserverEventHandler(string processName, string description, string file);
10新增: public delegate void ObserverEventHandler(AppObserverEventArgs args);
1011}
新增Core/Models/AppObserver/AppObserverEventArgs.cs+28 −0看文件
@@ -0,0 +1,28 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.Linq;
4新增:using System.Text;
5新增:using System.Threading.Tasks;
6新增:
7新增:namespace Core.Models.AppObserver
8新增:{
9新增: public class AppObserverEventArgs
10新增: {
11新增: private IntPtr _handle;
12新增: private string _processName;
13新增: private string _description;
14新增: private string _file;
15新增:
16新增: public string ProcessName { get { return _processName; } }
17新增: public string Description { get { return _description; } }
18新增: public string File { get { return _file; } }
19新增: public IntPtr Handle { get { return _handle; } }
20新增: public AppObserverEventArgs(string processName, string description, string file, IntPtr handle)
21新增: {
22新增: _processName = processName;
23新增: _description = description;
24新增: _file = file;
25新增: _handle = handle;
26新增: }
27新增: }
28新增:}
修改Core/Servicers/Instances/AppObserver.cs+5 −4看文件
@@ -1,5 +1,6 @@
11using Core.Event;
22using Core.Librarys;
3新增:using Core.Models.AppObserver;
34using Core.Servicers.Interfaces;
45using System;
56using System.Collections.Generic;
@@ -40,7 +41,6 @@ namespace Core.Servicers.Instances
4041
4142 private async void Handle(IntPtr hwnd)
4243 {
43删除: Debug.WriteLine(hwnd);
4444 string processName = String.Empty, processFileName = String.Empty, processDescription = String.Empty;
4545
4646 var processResult = await Task.Run(() =>
@@ -102,7 +102,7 @@ namespace Core.Servicers.Instances
102102 return processName;
103103 });
104104
105删除: EventInvoke(processName, processDescription, processFileName);
105新增: EventInvoke(processName, processDescription, processFileName, hwnd);
106106 }
107107
108108 /// <summary>
@@ -170,9 +170,10 @@ namespace Core.Servicers.Instances
170170 }
171171 return new string[] { processName, processFileName, processID.ToString() };
172172 }
173删除: private void EventInvoke(string processName, string description, string filename)
173新增: private void EventInvoke(string processName, string description, string filename, IntPtr handle)
174174 {
175删除: OnAppActive?.Invoke(processName, description, filename);
175新增: var args = new AppObserverEventArgs(processName, description, filename, handle);
176新增: OnAppActive?.Invoke(args);
176177 }
177178
178179 public void Stop()