From 7da778699b140590a36ae65a2e0ce177a0942a8a Mon Sep 17 00:00:00 2001
From: Lightczx <1686188646@qq.com>
Date: Thu, 9 May 2024 16:25:21 +0800
Subject: [PATCH] code style
---
src/Snap.Hutao/Snap.Hutao/App.xaml.cs | 2 ++
.../Snap.Hutao/IdentifyMonitorWindow.xaml.cs | 1 +
.../ScreenCapture/GameScreenCaptureService.cs | 3 ++-
.../ScreenCapture/IGameScreenCaptureService.cs | 13 +++++++++++++
4 files changed, 18 insertions(+), 1 deletion(-)
create mode 100644 src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/IGameScreenCaptureService.cs
diff --git a/src/Snap.Hutao/Snap.Hutao/App.xaml.cs b/src/Snap.Hutao/Snap.Hutao/App.xaml.cs
index c1d79aa1..9e040829 100644
--- a/src/Snap.Hutao/Snap.Hutao/App.xaml.cs
+++ b/src/Snap.Hutao/Snap.Hutao/App.xaml.cs
@@ -48,6 +48,8 @@ public sealed partial class App : Application
/// 服务提供器
public App(IServiceProvider serviceProvider)
{
+ // DispatcherShutdownMode = DispatcherShutdownMode.OnExplicitShutdown;
+
// Load app resource
InitializeComponent();
activation = serviceProvider.GetRequiredService();
diff --git a/src/Snap.Hutao/Snap.Hutao/IdentifyMonitorWindow.xaml.cs b/src/Snap.Hutao/Snap.Hutao/IdentifyMonitorWindow.xaml.cs
index 604697b2..afbbeb6d 100644
--- a/src/Snap.Hutao/Snap.Hutao/IdentifyMonitorWindow.xaml.cs
+++ b/src/Snap.Hutao/Snap.Hutao/IdentifyMonitorWindow.xaml.cs
@@ -32,6 +32,7 @@ internal sealed partial class IdentifyMonitorWindow : Window
{
List windows = [];
+ // TODO: the order here is not sync with unity.
IReadOnlyList displayAreas = DisplayArea.FindAll();
for (int i = 0; i < displayAreas.Count; i++)
{
diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureService.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureService.cs
index b1d4376e..0f1367f2 100644
--- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureService.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureService.cs
@@ -17,7 +17,8 @@ using static Snap.Hutao.Win32.Macros;
namespace Snap.Hutao.Service.Game.Automation.ScreenCapture;
[ConstructorGenerated]
-internal sealed partial class GameScreenCaptureService
+[Injection(InjectAs.Singleton, typeof(IGameScreenCaptureService))]
+internal sealed partial class GameScreenCaptureService : IGameScreenCaptureService
{
private readonly ILogger logger;
diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/IGameScreenCaptureService.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/IGameScreenCaptureService.cs
new file mode 100644
index 00000000..84aefae5
--- /dev/null
+++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/IGameScreenCaptureService.cs
@@ -0,0 +1,13 @@
+// Copyright (c) DGP Studio. All rights reserved.
+// Licensed under the MIT license.
+
+using Snap.Hutao.Win32.Foundation;
+
+namespace Snap.Hutao.Service.Game.Automation.ScreenCapture;
+
+internal interface IGameScreenCaptureService
+{
+ bool IsSupported();
+
+ bool TryStartCapture(HWND hwnd, [NotNullWhen(true)] out GameScreenCaptureSession? session);
+}
\ No newline at end of file