From f4b71bd0bef781de516304bef9f9f97c7355b4cf Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Fri, 11 Jul 2025 09:09:07 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=96=B0Config=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 部分迁移自 #12315 --- .../Configuration/{ => Factory}/ConfigFactory.cs | 8 +++++--- .../{ => Factory}/PropertyChangedEventDetailArgs.cs | 2 +- .../Configuration/{ => Global}/AnnouncementInfo.cs | 2 +- src/MaaWpfGui/Configuration/{ => Global}/GUI.cs | 2 +- src/MaaWpfGui/Configuration/{ => Global}/Timer.cs | 3 ++- src/MaaWpfGui/Configuration/{ => Global}/VersionUpdate.cs | 2 +- src/MaaWpfGui/Configuration/Root.cs | 2 ++ .../Configuration/{ => Single}/SpecificConfig.cs | 2 +- src/MaaWpfGui/Helper/ToastNotification.cs | 2 +- src/MaaWpfGui/Main/Bootstrapper.cs | 2 +- src/MaaWpfGui/Utilities/BadModules.cs | 2 +- src/MaaWpfGui/ViewModels/UI/AnnouncementViewModel.cs | 2 +- .../UserControl/Settings/GuiSettingsUserControlModel.cs | 4 ++-- .../UserControl/Settings/IssueReportUserControlModel.cs | 2 +- 14 files changed, 21 insertions(+), 16 deletions(-) rename src/MaaWpfGui/Configuration/{ => Factory}/ConfigFactory.cs (98%) rename src/MaaWpfGui/Configuration/{ => Factory}/PropertyChangedEventDetailArgs.cs (96%) rename src/MaaWpfGui/Configuration/{ => Global}/AnnouncementInfo.cs (97%) rename src/MaaWpfGui/Configuration/{ => Global}/GUI.cs (98%) rename src/MaaWpfGui/Configuration/{ => Global}/Timer.cs (94%) rename src/MaaWpfGui/Configuration/{ => Global}/VersionUpdate.cs (98%) rename src/MaaWpfGui/Configuration/{ => Single}/SpecificConfig.cs (96%) diff --git a/src/MaaWpfGui/Configuration/ConfigFactory.cs b/src/MaaWpfGui/Configuration/Factory/ConfigFactory.cs similarity index 98% rename from src/MaaWpfGui/Configuration/ConfigFactory.cs rename to src/MaaWpfGui/Configuration/Factory/ConfigFactory.cs index 64af5f7baf..d20a45d592 100644 --- a/src/MaaWpfGui/Configuration/ConfigFactory.cs +++ b/src/MaaWpfGui/Configuration/Factory/ConfigFactory.cs @@ -23,13 +23,15 @@ using System.Text.Json.Serialization; using System.Text.Unicode; using System.Threading; using System.Threading.Tasks; +using MaaWpfGui.Configuration.Global; +using MaaWpfGui.Configuration.Single; using MaaWpfGui.Helper; using ObservableCollections; using Serilog; [assembly: PropertyChanged.FilterType("MaaWpfGui.Configuration.")] -namespace MaaWpfGui.Configuration +namespace MaaWpfGui.Configuration.Factory { public static class ConfigFactory { @@ -387,8 +389,8 @@ namespace MaaWpfGui.Configuration { get { - List lists = new List(Root.Configurations.Count); - using IEnumerator> enumerator = Root.Configurations.GetEnumerator(); + var lists = new List(Root.Configurations.Count); + using var enumerator = Root.Configurations.GetEnumerator(); while (enumerator.MoveNext()) { lists.Add(enumerator.Current.Key); diff --git a/src/MaaWpfGui/Configuration/PropertyChangedEventDetailArgs.cs b/src/MaaWpfGui/Configuration/Factory/PropertyChangedEventDetailArgs.cs similarity index 96% rename from src/MaaWpfGui/Configuration/PropertyChangedEventDetailArgs.cs rename to src/MaaWpfGui/Configuration/Factory/PropertyChangedEventDetailArgs.cs index e8e10dc212..0f4fabc499 100644 --- a/src/MaaWpfGui/Configuration/PropertyChangedEventDetailArgs.cs +++ b/src/MaaWpfGui/Configuration/Factory/PropertyChangedEventDetailArgs.cs @@ -14,7 +14,7 @@ #nullable enable using System.ComponentModel; -namespace MaaWpfGui.Configuration +namespace MaaWpfGui.Configuration.Factory { // https://github.com/dotnet/runtime/issues/27252 public class PropertyChangedEventDetailArgs : PropertyChangedEventArgs diff --git a/src/MaaWpfGui/Configuration/AnnouncementInfo.cs b/src/MaaWpfGui/Configuration/Global/AnnouncementInfo.cs similarity index 97% rename from src/MaaWpfGui/Configuration/AnnouncementInfo.cs rename to src/MaaWpfGui/Configuration/Global/AnnouncementInfo.cs index 94df6ff182..3e923aad5f 100644 --- a/src/MaaWpfGui/Configuration/AnnouncementInfo.cs +++ b/src/MaaWpfGui/Configuration/Global/AnnouncementInfo.cs @@ -13,7 +13,7 @@ using System.ComponentModel; -namespace MaaWpfGui.Configuration +namespace MaaWpfGui.Configuration.Global { public class AnnouncementInfo : INotifyPropertyChanged { diff --git a/src/MaaWpfGui/Configuration/GUI.cs b/src/MaaWpfGui/Configuration/Global/GUI.cs similarity index 98% rename from src/MaaWpfGui/Configuration/GUI.cs rename to src/MaaWpfGui/Configuration/Global/GUI.cs index 72b74526fb..76fb698297 100644 --- a/src/MaaWpfGui/Configuration/GUI.cs +++ b/src/MaaWpfGui/Configuration/Global/GUI.cs @@ -15,7 +15,7 @@ using System.ComponentModel; using MaaWpfGui.Helper; using MaaWpfGui.Models; -namespace MaaWpfGui.Configuration +namespace MaaWpfGui.Configuration.Global { public class GUI : INotifyPropertyChanged { diff --git a/src/MaaWpfGui/Configuration/Timer.cs b/src/MaaWpfGui/Configuration/Global/Timer.cs similarity index 94% rename from src/MaaWpfGui/Configuration/Timer.cs rename to src/MaaWpfGui/Configuration/Global/Timer.cs index dac17f6a15..90ebbcd5a4 100644 --- a/src/MaaWpfGui/Configuration/Timer.cs +++ b/src/MaaWpfGui/Configuration/Global/Timer.cs @@ -12,8 +12,9 @@ // using System.Text.Json.Serialization; +using MaaWpfGui.Configuration.Factory; -namespace MaaWpfGui.Configuration +namespace MaaWpfGui.Configuration.Global { public class Timer { diff --git a/src/MaaWpfGui/Configuration/VersionUpdate.cs b/src/MaaWpfGui/Configuration/Global/VersionUpdate.cs similarity index 98% rename from src/MaaWpfGui/Configuration/VersionUpdate.cs rename to src/MaaWpfGui/Configuration/Global/VersionUpdate.cs index fe05dffbdc..bba1262b6c 100644 --- a/src/MaaWpfGui/Configuration/VersionUpdate.cs +++ b/src/MaaWpfGui/Configuration/Global/VersionUpdate.cs @@ -14,7 +14,7 @@ #nullable enable using System.ComponentModel; -namespace MaaWpfGui.Configuration +namespace MaaWpfGui.Configuration.Global { public class VersionUpdate : INotifyPropertyChanged { diff --git a/src/MaaWpfGui/Configuration/Root.cs b/src/MaaWpfGui/Configuration/Root.cs index b5d937adbc..4fd3bdc81d 100644 --- a/src/MaaWpfGui/Configuration/Root.cs +++ b/src/MaaWpfGui/Configuration/Root.cs @@ -14,6 +14,8 @@ #nullable enable using System.ComponentModel; using System.Text.Json.Serialization; +using MaaWpfGui.Configuration.Global; +using MaaWpfGui.Configuration.Single; using ObservableCollections; namespace MaaWpfGui.Configuration diff --git a/src/MaaWpfGui/Configuration/SpecificConfig.cs b/src/MaaWpfGui/Configuration/Single/SpecificConfig.cs similarity index 96% rename from src/MaaWpfGui/Configuration/SpecificConfig.cs rename to src/MaaWpfGui/Configuration/Single/SpecificConfig.cs index 85615be5f1..a0254b937e 100644 --- a/src/MaaWpfGui/Configuration/SpecificConfig.cs +++ b/src/MaaWpfGui/Configuration/Single/SpecificConfig.cs @@ -14,7 +14,7 @@ using System.Text.Json.Serialization; using ObservableCollections; -namespace MaaWpfGui.Configuration +namespace MaaWpfGui.Configuration.Single { public class SpecificConfig { diff --git a/src/MaaWpfGui/Helper/ToastNotification.cs b/src/MaaWpfGui/Helper/ToastNotification.cs index 8452d4bc38..cfaf1eb29d 100644 --- a/src/MaaWpfGui/Helper/ToastNotification.cs +++ b/src/MaaWpfGui/Helper/ToastNotification.cs @@ -24,7 +24,7 @@ using System.Runtime.InteropServices; using System.Text; using System.Windows.Interop; using HandyControl.Controls; -using MaaWpfGui.Configuration; +using MaaWpfGui.Configuration.Factory; using MaaWpfGui.Helper.Notification; using MaaWpfGui.WineCompat; using Microsoft.Win32; diff --git a/src/MaaWpfGui/Main/Bootstrapper.cs b/src/MaaWpfGui/Main/Bootstrapper.cs index 01de401148..3f81156ade 100644 --- a/src/MaaWpfGui/Main/Bootstrapper.cs +++ b/src/MaaWpfGui/Main/Bootstrapper.cs @@ -27,7 +27,7 @@ using System.Windows.Interop; using System.Windows.Media; using System.Windows.Threading; using GlobalHotKey; -using MaaWpfGui.Configuration; +using MaaWpfGui.Configuration.Factory; using MaaWpfGui.Constants; using MaaWpfGui.Helper; using MaaWpfGui.Properties; diff --git a/src/MaaWpfGui/Utilities/BadModules.cs b/src/MaaWpfGui/Utilities/BadModules.cs index d671734406..1ace5ef17d 100644 --- a/src/MaaWpfGui/Utilities/BadModules.cs +++ b/src/MaaWpfGui/Utilities/BadModules.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -using MaaWpfGui.Configuration; +using MaaWpfGui.Configuration.Factory; using MaaWpfGui.Helper; using Windows.Win32; diff --git a/src/MaaWpfGui/ViewModels/UI/AnnouncementViewModel.cs b/src/MaaWpfGui/ViewModels/UI/AnnouncementViewModel.cs index 400012fa81..eb51a87edf 100644 --- a/src/MaaWpfGui/ViewModels/UI/AnnouncementViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/AnnouncementViewModel.cs @@ -19,7 +19,7 @@ using System.Threading.Tasks; using System.Windows.Input; using HandyControl.Controls; using HandyControl.Tools.Command; -using MaaWpfGui.Configuration; +using MaaWpfGui.Configuration.Factory; using MaaWpfGui.Constants; using MaaWpfGui.Helper; using Serilog; diff --git a/src/MaaWpfGui/ViewModels/UserControl/Settings/GuiSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/Settings/GuiSettingsUserControlModel.cs index 399e31f4cc..35428fc2df 100644 --- a/src/MaaWpfGui/ViewModels/UserControl/Settings/GuiSettingsUserControlModel.cs +++ b/src/MaaWpfGui/ViewModels/UserControl/Settings/GuiSettingsUserControlModel.cs @@ -16,14 +16,14 @@ using System; using System.Collections.Generic; using System.Linq; using System.Windows; -using MaaWpfGui.Configuration; +using MaaWpfGui.Configuration.Factory; using MaaWpfGui.Constants; using MaaWpfGui.Helper; using MaaWpfGui.Main; using MaaWpfGui.Utilities.ValueType; using MaaWpfGui.ViewModels.UI; using Stylet; -using DarkModeType = MaaWpfGui.Configuration.GUI.DarkModeType; +using DarkModeType = MaaWpfGui.Configuration.Global.GUI.DarkModeType; namespace MaaWpfGui.ViewModels.UserControl.Settings; diff --git a/src/MaaWpfGui/ViewModels/UserControl/Settings/IssueReportUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/Settings/IssueReportUserControlModel.cs index 677ebad681..c9c786b2ed 100644 --- a/src/MaaWpfGui/ViewModels/UserControl/Settings/IssueReportUserControlModel.cs +++ b/src/MaaWpfGui/ViewModels/UserControl/Settings/IssueReportUserControlModel.cs @@ -20,7 +20,7 @@ using System.Linq; using System.Windows; using HandyControl.Controls; using HandyControl.Data; -using MaaWpfGui.Configuration; +using MaaWpfGui.Configuration.Factory; using MaaWpfGui.Constants; using MaaWpfGui.Helper; using MaaWpfGui.Main;