提交记录修改Core/Core.csproj+2 −2看文件
改名Core/Servicers/Instances/Observer.cs → Core/Servicers/Instances/AppObserver.cs+3 −2看文件
修改Core/Servicers/Instances/Main.cs+7 −7看文件
改名Core/Servicers/Interfaces/IObserver.cs → Core/Servicers/Interfaces/IAppObserver.cs+1 −1看文件
修改UI/App.xaml.cs+2 −2看文件
| @@ -171,7 +171,7 @@ | ||
| 171 | 171 | <Compile Include="Librarys\Logger.cs" /> |
| 172 | 172 | <Compile Include="Servicers\Instances\DateTimeObserver.cs" /> |
| 173 | 173 | <Compile Include="Servicers\Instances\Main.cs" /> |
| 174 | 删除: <Compile Include="Servicers\Instances\Observer.cs" /> | |
| 174 | 新增: <Compile Include="Servicers\Instances\AppObserver.cs" /> | |
| 175 | 175 | <Compile Include="Servicers\Instances\Sleepdiscover.cs" /> |
| 176 | 176 | <Compile Include="Servicers\Interfaces\IAppConfig.cs" /> |
| 177 | 177 | <Compile Include="Servicers\Interfaces\ICategorys.cs" /> |
| @@ -179,7 +179,7 @@ | ||
| 179 | 179 | <Compile Include="Servicers\Interfaces\IData.cs" /> |
| 180 | 180 | <Compile Include="Servicers\Interfaces\IDateTimeObserver.cs" /> |
| 181 | 181 | <Compile Include="Servicers\Interfaces\IMain.cs" /> |
| 182 | 删除: <Compile Include="Servicers\Interfaces\IObserver.cs" /> | |
| 182 | 新增: <Compile Include="Servicers\Interfaces\IAppObserver.cs" /> | |
| 183 | 183 | <Compile Include="Servicers\Interfaces\ISleepdiscover.cs" /> |
| 184 | 184 | </ItemGroup> |
| 185 | 185 | <ItemGroup> |
| @@ -13,14 +13,14 @@ using System.Threading.Tasks; | ||
| 13 | 13 | |
| 14 | 14 | namespace Core.Servicers.Instances |
| 15 | 15 | { |
| 16 | 删除: public class Observer : IObserver | |
| 16 | 新增: public class AppObserver : IAppObserver | |
| 17 | 17 | { |
| 18 | 18 | private IntPtr hook; |
| 19 | 19 | Win32API.WinEventDelegate winEventDelegate; |
| 20 | 20 | |
| 21 | 21 | public event ObserverEventHandler OnAppActive; |
| 22 | 22 | |
| 23 | 删除: public Observer() | |
| 23 | 新增: public AppObserver() | |
| 24 | 24 | { |
| 25 | 25 | winEventDelegate = new Win32API.WinEventDelegate(WinEventProc); |
| 26 | 26 | } |
| @@ -40,6 +40,7 @@ namespace Core.Servicers.Instances | ||
| 40 | 40 | |
| 41 | 41 | private async void Handle(IntPtr hwnd) |
| 42 | 42 | { |
| 43 | 新增: Debug.WriteLine(hwnd); | |
| 43 | 44 | string processName = String.Empty, processFileName = String.Empty, processDescription = String.Empty; |
| 44 | 45 | |
| 45 | 46 | var processResult = await Task.Run(() => |
| @@ -20,7 +20,7 @@ namespace Core.Servicers.Instances | ||
| 20 | 20 | { |
| 21 | 21 | public class Main : IMain |
| 22 | 22 | { |
| 23 | 删除: private readonly IObserver observer; | |
| 23 | 新增: private readonly IAppObserver appObserver; | |
| 24 | 24 | private readonly IData data; |
| 25 | 25 | private readonly ISleepdiscover sleepdiscover; |
| 26 | 26 | private readonly IAppConfig appConfig; |
| @@ -83,14 +83,14 @@ namespace Core.Servicers.Instances | ||
| 83 | 83 | // 已经更新过的应用列表 |
| 84 | 84 | private List<string> updatedAppList = new List<string>(); |
| 85 | 85 | public Main( |
| 86 | 删除: IObserver observer, | |
| 86 | 新增: IAppObserver appObserver, | |
| 87 | 87 | IData data, |
| 88 | 88 | ISleepdiscover sleepdiscover, |
| 89 | 89 | IAppConfig appConfig, |
| 90 | 90 | IDateTimeObserver dateTimeObserver, |
| 91 | 91 | IAppData appData, ICategorys categories) |
| 92 | 92 | { |
| 93 | 删除: this.observer = observer; | |
| 93 | 新增: this.appObserver = appObserver; | |
| 94 | 94 | this.data = data; |
| 95 | 95 | this.sleepdiscover = sleepdiscover; |
| 96 | 96 | this.appConfig = appConfig; |
| @@ -102,7 +102,7 @@ namespace Core.Servicers.Instances | ||
| 102 | 102 | ConfigIgnoreProcessRegxList = new List<string>(); |
| 103 | 103 | ConfigIgnoreProcessList = new List<string>(); |
| 104 | 104 | |
| 105 | 删除: observer.OnAppActive += Observer_OnAppActive; | |
| 105 | 新增: appObserver.OnAppActive += Observer_OnAppActive; | |
| 106 | 106 | sleepdiscover.SleepStatusChanged += Sleepdiscover_SleepStatusChanged; |
| 107 | 107 | appConfig.ConfigChanged += AppConfig_ConfigChanged; |
| 108 | 108 | dateTimeObserver.OnDateTimeChanging += DateTimeObserver_OnDateTimeChanging; |
| @@ -175,16 +175,16 @@ namespace Core.Servicers.Instances | ||
| 175 | 175 | activeProcess = null; |
| 176 | 176 | |
| 177 | 177 | dateTimeObserver.Start(); |
| 178 | 删除: observer.Start(); | |
| 178 | 新增: appObserver.Start(); | |
| 179 | 179 | } |
| 180 | 180 | public void Stop() |
| 181 | 181 | { |
| 182 | 182 | dateTimeObserver.Stop(); |
| 183 | 删除: observer.Stop(); | |
| 183 | 新增: appObserver.Stop(); | |
| 184 | 184 | } |
| 185 | 185 | public void Exit() |
| 186 | 186 | { |
| 187 | 删除: observer?.Stop(); | |
| 187 | 新增: appObserver?.Stop(); | |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | |
| @@ -10,7 +10,7 @@ namespace Core.Servicers.Interfaces | ||
| 10 | 10 | /// <summary> |
| 11 | 11 | /// 观察者,用于监听应用程序获取焦点事件 |
| 12 | 12 | /// </summary> |
| 13 | 删除: public interface IObserver | |
| 13 | 新增: public interface IAppObserver | |
| 14 | 14 | { |
| 15 | 15 | /// <summary> |
| 16 | 16 | /// 启动观察 |
| @@ -182,7 +182,7 @@ namespace UI | ||
| 182 | 182 | private void ConfigureServices(IServiceCollection services) |
| 183 | 183 | { |
| 184 | 184 | // 核心服务 |
| 185 | 删除: services.AddSingleton<IObserver, Observer>(); | |
| 185 | 新增: services.AddSingleton<IAppObserver, AppObserver>(); | |
| 186 | 186 | services.AddSingleton<IMain, Main>(); |
| 187 | 187 | services.AddSingleton<IData, Data>(); |
| 188 | 188 | services.AddSingleton<ISleepdiscover, Sleepdiscover>(); |
| @@ -241,7 +241,7 @@ namespace UI | ||
| 241 | 241 | var main = serviceProvider.GetService<IMainServicer>(); |
| 242 | 242 | main.Start(); |
| 243 | 243 | |
| 244 | 删除: var observer = serviceProvider.GetService<IObserver>(); | |
| 244 | 新增: var observer = serviceProvider.GetService<IAppObserver>(); | |
| 245 | 245 | observer.OnAppActive += (p, d, f) => |
| 246 | 246 | { |
| 247 | 247 | Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => |

