From 5bbfa1c83e8e8f0c46dd3018a1a0b4d1f3a89130 Mon Sep 17 00:00:00 2001
From: miyaji255 <84168445+miyaji255@users.noreply.github.com>
Date: Wed, 21 Feb 2024 21:15:56 +0900
Subject: [PATCH] =?UTF-8?q?=E3=83=97=E3=83=AD=E3=82=B0=E3=83=AC=E3=82=B9?=
=?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=92=E6=9B=B4=E6=96=B0=E3=81=A7=E3=81=8D?=
=?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/IDisplayStateChangeService.cs | 16 ++++++++++
.../Services/INotifyStateChangedService.cs | 11 -------
KoeBook/App.xaml.cs | 2 +-
KoeBook/KoeBook.csproj | 4 +++
KoeBook/Services/DisplayStateChangeService.cs | 30 +++++++++++++++++++
KoeBook/Services/NotifyStateChangedService.cs | 19 ------------
6 files changed, 51 insertions(+), 31 deletions(-)
create mode 100644 KoeBook.Core/Contracts/Services/IDisplayStateChangeService.cs
delete mode 100644 KoeBook.Core/Contracts/Services/INotifyStateChangedService.cs
create mode 100644 KoeBook/Services/DisplayStateChangeService.cs
delete mode 100644 KoeBook/Services/NotifyStateChangedService.cs
diff --git a/KoeBook.Core/Contracts/Services/IDisplayStateChangeService.cs b/KoeBook.Core/Contracts/Services/IDisplayStateChangeService.cs
new file mode 100644
index 0000000..0896753
--- /dev/null
+++ b/KoeBook.Core/Contracts/Services/IDisplayStateChangeService.cs
@@ -0,0 +1,16 @@
+using KoeBook.Core.Models;
+
+namespace KoeBook.Core.Contracts.Services;
+
+public interface IDisplayStateChangeService
+{
+ ///
+ /// 状態を更新します
+ ///
+ void UpdateState(BookProperties bookProperties, GenerationState state);
+
+ ///
+ /// プログレスバーを更新します
+ ///
+ void UpdateProgress(BookProperties bookProperties, int progress, int maximum);
+}
diff --git a/KoeBook.Core/Contracts/Services/INotifyStateChangedService.cs b/KoeBook.Core/Contracts/Services/INotifyStateChangedService.cs
deleted file mode 100644
index 5faaf02..0000000
--- a/KoeBook.Core/Contracts/Services/INotifyStateChangedService.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using KoeBook.Core.Models;
-
-namespace KoeBook.Core.Contracts.Services;
-
-public interface INotifyStateChangedService
-{
- ///
- /// 状態が移行したことを通知します
- ///
- void OnStateChanged(BookProperties bookProperties, GenerationState state);
-}
diff --git a/KoeBook/App.xaml.cs b/KoeBook/App.xaml.cs
index f373a56..9658cb1 100644
--- a/KoeBook/App.xaml.cs
+++ b/KoeBook/App.xaml.cs
@@ -68,7 +68,7 @@ public App()
services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
- services.AddSingleton();
+ services.AddSingleton();
// Core Services
services.AddSingleton();
diff --git a/KoeBook/KoeBook.csproj b/KoeBook/KoeBook.csproj
index 74966d7..a8f17d5 100644
--- a/KoeBook/KoeBook.csproj
+++ b/KoeBook/KoeBook.csproj
@@ -58,6 +58,10 @@
+
+
+
+
true
diff --git a/KoeBook/Services/DisplayStateChangeService.cs b/KoeBook/Services/DisplayStateChangeService.cs
new file mode 100644
index 0000000..13e6b63
--- /dev/null
+++ b/KoeBook/Services/DisplayStateChangeService.cs
@@ -0,0 +1,30 @@
+using KoeBook.Contracts.Services;
+using KoeBook.Core.Contracts.Services;
+using KoeBook.Core.Models;
+
+namespace KoeBook.Services;
+
+internal class DisplayStateChangeService(IGenerationTaskService taskService) : IDisplayStateChangeService
+{
+ private readonly IGenerationTaskService _taskService = taskService;
+
+ public void UpdateProgress(BookProperties bookProperties, int progress, int maximum)
+ {
+ var taskService = _taskService; // thisをキャプチャしないようにする
+ _ = App.MainWindow.DispatcherQueue.TryEnqueue(() =>
+ {
+ var task = taskService.GetProcessingTask(bookProperties.Id);
+ task.MaximumProgress = maximum;
+ task.Progress = progress;
+ });
+ }
+
+ public void UpdateState(BookProperties bookProperties, GenerationState state)
+ {
+ var taskService = _taskService; // thisをキャプチャしないようにする
+ _ = App.MainWindow.DispatcherQueue.TryEnqueue(() =>
+ {
+ taskService.GetProcessingTask(bookProperties.Id).State = state;
+ });
+ }
+}
diff --git a/KoeBook/Services/NotifyStateChangedService.cs b/KoeBook/Services/NotifyStateChangedService.cs
deleted file mode 100644
index 92928e3..0000000
--- a/KoeBook/Services/NotifyStateChangedService.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using KoeBook.Contracts.Services;
-using KoeBook.Core.Contracts.Services;
-using KoeBook.Core.Models;
-
-namespace KoeBook.Services;
-
-internal class NotifyStateChangedService(IGenerationTaskService taskService) : INotifyStateChangedService
-{
- private readonly IGenerationTaskService _taskService = taskService;
-
- public void OnStateChanged(BookProperties bookProperties, GenerationState state)
- {
- var taskService = _taskService; // thisをキャプチャしないようにする
- _ = App.MainWindow.DispatcherQueue.TryEnqueue(() =>
- {
- taskService.GetProcessingTask(bookProperties.Id).State = state;
- });
- }
-}