From 4ac45ebab346e1b22709ef263b8baa18f2865c54 Mon Sep 17 00:00:00 2001 From: shusann01116 <26602565+shusann01116@users.noreply.github.com> Date: Sat, 7 Aug 2021 04:35:56 +0900 Subject: [PATCH 01/12] Changed default window size and Application Title --- PSO2Logger/ViewModels/MainWindowViewModel.cs | 2 +- PSO2Logger/Views/MainWindow.xaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PSO2Logger/ViewModels/MainWindowViewModel.cs b/PSO2Logger/ViewModels/MainWindowViewModel.cs index 20bb32f..e3b3207 100644 --- a/PSO2Logger/ViewModels/MainWindowViewModel.cs +++ b/PSO2Logger/ViewModels/MainWindowViewModel.cs @@ -6,7 +6,7 @@ namespace PSO2Logger.ViewModels { public class MainWindowViewModel : BindableBase { - private string _title = "Prism Application"; + private string _title = "PSO2 Logger"; public string Title { get { return _title; } set { SetProperty(ref _title, value); } diff --git a/PSO2Logger/Views/MainWindow.xaml b/PSO2Logger/Views/MainWindow.xaml index a195b24..c5bb8ce 100644 --- a/PSO2Logger/Views/MainWindow.xaml +++ b/PSO2Logger/Views/MainWindow.xaml @@ -9,7 +9,7 @@ xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" prism:ViewModelLocator.AutoWireViewModel="True" - Title="{Binding Title}" Height="350" Width="525" + Title="{Binding Title}" Height="720" Width="1440" mah:SaveWindowPosition="True"> From 39f76c264d883e237d396f4ee0c6bd82e72c3093 Mon Sep 17 00:00:00 2001 From: shusann01116 <26602565+shusann01116@users.noreply.github.com> Date: Sat, 7 Aug 2021 14:26:12 +0900 Subject: [PATCH 02/12] =?UTF-8?q?FileWatcherService=E3=81=AE=E3=83=91?= =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=BC=E3=83=9E=E3=83=B3=E3=82=B9=E3=81=8C?= =?UTF-8?q?=E6=82=AA=E3=81=99=E3=81=8E=E3=81=9F=E3=81=AE=E3=81=A7MockWatch?= =?UTF-8?q?erService=E3=81=AB=E5=B7=AE=E3=81=97=E6=9B=BF=E3=81=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PSO2Logger.Services/MockWatcherService.cs | 26 +++++++++++++++++++++++ PSO2Logger/App.xaml.cs | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 PSO2Logger.Services/MockWatcherService.cs diff --git a/PSO2Logger.Services/MockWatcherService.cs b/PSO2Logger.Services/MockWatcherService.cs new file mode 100644 index 0000000..c4f46cb --- /dev/null +++ b/PSO2Logger.Services/MockWatcherService.cs @@ -0,0 +1,26 @@ +using PSO2Logger.Interfaces; +using PSO2Logger.Interfaces.Core; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace PSO2Logger.Services { + public class MockWatcherService : IWatcherService { + public string FolderPath { get; set; } + public string FileName { get; set; } + public bool CanRaiseEvent { get; set; } = true; + + public event EventHandler OnChanged; + + public void RunScanRoop() { + var watcherEventArgs = new WatcherEventArgs(null, WatchType.FileChanged); + while (CanRaiseEvent is true) { + Thread.Sleep(1000); + OnChanged?.Invoke(this, watcherEventArgs); + } + } + } +} diff --git a/PSO2Logger/App.xaml.cs b/PSO2Logger/App.xaml.cs index e8b74af..12efb58 100644 --- a/PSO2Logger/App.xaml.cs +++ b/PSO2Logger/App.xaml.cs @@ -18,7 +18,7 @@ protected override Window CreateShell() { } protected override void RegisterTypes(IContainerRegistry containerRegistry) { - containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton, ChatLogService>(); } From b8f28529ed02950ca091060938a16c317cfcef1c Mon Sep 17 00:00:00 2001 From: shusann01116 <26602565+shusann01116@users.noreply.github.com> Date: Sat, 7 Aug 2021 14:32:25 +0900 Subject: [PATCH 03/12] Deleted IChatDataStore interface --- .../Interfaces/IChatDataStore.cs | 20 ------------------- 1 file changed, 20 deletions(-) delete mode 100644 Modules/PSO2Logger.Modules.Chat/Interfaces/IChatDataStore.cs diff --git a/Modules/PSO2Logger.Modules.Chat/Interfaces/IChatDataStore.cs b/Modules/PSO2Logger.Modules.Chat/Interfaces/IChatDataStore.cs deleted file mode 100644 index f30ced1..0000000 --- a/Modules/PSO2Logger.Modules.Chat/Interfaces/IChatDataStore.cs +++ /dev/null @@ -1,20 +0,0 @@ -using PSO2Logger.Interfaces; -using PSO2Logger.Models; -using Reactive.Bindings; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace PSO2Logger.Modules.Chat.Interfaces { - interface IChatDataStore { - ReactiveCollection ChatLines { get; } - ILogService LogService { get; } - IWatcherService WatcherService { get; } - - IList GetNewLines(); - void OverrideLogService(ILogService logService); - void OverrideWatcherService(IWatcherService watcherService); - } -} From a38cbd778ee76075569ced13d9c47604039fdf7d Mon Sep 17 00:00:00 2001 From: shusann01116 <26602565+shusann01116@users.noreply.github.com> Date: Sat, 7 Aug 2021 14:34:11 +0900 Subject: [PATCH 04/12] Refactor DataGridBehavior --- .../Behaviors/DataGridBehavior.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Modules/PSO2Logger.Modules.Chat/Behaviors/DataGridBehavior.cs b/Modules/PSO2Logger.Modules.Chat/Behaviors/DataGridBehavior.cs index 5e8cd30..5f92247 100644 --- a/Modules/PSO2Logger.Modules.Chat/Behaviors/DataGridBehavior.cs +++ b/Modules/PSO2Logger.Modules.Chat/Behaviors/DataGridBehavior.cs @@ -7,13 +7,16 @@ namespace PSO2Logger.Modules.Chat.Behaviors { class DataGridBehavior { public static readonly DependencyProperty AutoscrollProperty = DependencyProperty.RegisterAttached( - "Autoscroll", typeof(bool), typeof(DataGridBehavior), new PropertyMetadata(default(bool), OnAutoScrollPropertyChanged)); + "Autoscroll", + typeof(bool), + typeof(DataGridBehavior), + new PropertyMetadata(default(bool), OnAutoScrollPropertyChanged) + ); - private static readonly Dictionary handlersDict = new Dictionary(); + private static readonly Dictionary handlersDict = new(); private static void OnAutoScrollPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) { - var dataGrid = dependencyObject as DataGrid; - if (dataGrid == null) { + if (dependencyObject is not DataGrid dataGrid) { throw new InvalidOperationException("Dependency object is not DataGrid."); } From b92643c7b5bb80671e5e6e061a469d0f7c596268 Mon Sep 17 00:00:00 2001 From: shusann01116 <26602565+shusann01116@users.noreply.github.com> Date: Sat, 7 Aug 2021 14:34:24 +0900 Subject: [PATCH 05/12] Refactor codes --- Modules/PSO2Logger.Modules.Chat/Models/ChatDataStore.cs | 1 - .../ViewModels/CombinedChatViewModel.cs | 9 +-------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Modules/PSO2Logger.Modules.Chat/Models/ChatDataStore.cs b/Modules/PSO2Logger.Modules.Chat/Models/ChatDataStore.cs index 2e91805..f442737 100644 --- a/Modules/PSO2Logger.Modules.Chat/Models/ChatDataStore.cs +++ b/Modules/PSO2Logger.Modules.Chat/Models/ChatDataStore.cs @@ -8,7 +8,6 @@ using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; -using System.Text; using System.Threading.Tasks; namespace PSO2Logger.Modules.Chat.Models { diff --git a/Modules/PSO2Logger.Modules.Chat/ViewModels/CombinedChatViewModel.cs b/Modules/PSO2Logger.Modules.Chat/ViewModels/CombinedChatViewModel.cs index 7f4bf16..fb054e5 100644 --- a/Modules/PSO2Logger.Modules.Chat/ViewModels/CombinedChatViewModel.cs +++ b/Modules/PSO2Logger.Modules.Chat/ViewModels/CombinedChatViewModel.cs @@ -1,15 +1,8 @@ -using Prism.Commands; -using Prism.Mvvm; -using Prism.Regions; -using PSO2Logger.Core; +using Prism.Mvvm; using PSO2Logger.Interfaces; using PSO2Logger.Models; using PSO2Logger.Modules.Chat.Models; -using System; -using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Collections.Specialized; -using System.Linq; using System.Windows.Data; namespace PSO2Logger.Modules.Chat.ViewModels { From 1cbf1f30a8a0fd770366d693e2a0c8630d460236 Mon Sep 17 00:00:00 2001 From: shusann01116 <26602565+shusann01116@users.noreply.github.com> Date: Sat, 7 Aug 2021 14:59:04 +0900 Subject: [PATCH 06/12] Changed Setting Window to show folder path used by Services. --- .../PSO2Logger.Modules.Settings.csproj | 1 + .../ViewModels/SettingViewModel.cs | 25 +++++++++++++-- .../Views/Setting.xaml | 31 ++++++++++++++----- PSO2Logger/App.xaml.cs | 1 + 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/Modules/PSO2Logger.Modules.Settings/PSO2Logger.Modules.Settings.csproj b/Modules/PSO2Logger.Modules.Settings/PSO2Logger.Modules.Settings.csproj index f815cdc..9fa7780 100644 --- a/Modules/PSO2Logger.Modules.Settings/PSO2Logger.Modules.Settings.csproj +++ b/Modules/PSO2Logger.Modules.Settings/PSO2Logger.Modules.Settings.csproj @@ -13,5 +13,6 @@ + \ No newline at end of file diff --git a/Modules/PSO2Logger.Modules.Settings/ViewModels/SettingViewModel.cs b/Modules/PSO2Logger.Modules.Settings/ViewModels/SettingViewModel.cs index 2056ecc..2bbeef0 100644 --- a/Modules/PSO2Logger.Modules.Settings/ViewModels/SettingViewModel.cs +++ b/Modules/PSO2Logger.Modules.Settings/ViewModels/SettingViewModel.cs @@ -1,19 +1,40 @@ using Prism.Commands; using Prism.Mvvm; +using PSO2Logger.Interfaces; +using PSO2Logger.Models; using System; using System.Collections.Generic; +using System.IO; using System.Linq; namespace PSO2Logger.Modules.Settings.ViewModels { public class SettingViewModel : BindableBase { + private readonly ILogService logService; + private readonly IWatcherService watcherService; + private string _folderPath; + public string FolderPath { get { return _folderPath; } - set { SetProperty(ref _folderPath, value); } + set { + SetProperty(ref _folderPath, value); + UpdateServiceFolderPath(value); + } + } + + public SettingViewModel(ILogService logService, IWatcherService watcherService) { + this.logService = logService; + this.watcherService = watcherService; + + FolderPath = logService.FolderPath; } - public SettingViewModel() { + private void UpdateServiceFolderPath(string folderPath) { + if (!Directory.Exists(folderPath)) + return; + this.logService.FolderPath = folderPath; + this.watcherService.FolderPath = folderPath; } } } diff --git a/Modules/PSO2Logger.Modules.Settings/Views/Setting.xaml b/Modules/PSO2Logger.Modules.Settings/Views/Setting.xaml index c93f269..17cdde2 100644 --- a/Modules/PSO2Logger.Modules.Settings/Views/Setting.xaml +++ b/Modules/PSO2Logger.Modules.Settings/Views/Setting.xaml @@ -15,13 +15,28 @@ - - - - - - + + + + + + + + + + + + + + + +