diff --git a/.editorconfig b/.editorconfig
index 5f3f6ee..61c8ce4 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -7,3 +7,134 @@ dotnet_diagnostic.CS1573.severity = suggestion
dotnet_diagnostic.CS1570.severity = suggestion
# CS8632: 只能在 "#nullable" 注释上下文内的代码中使用可为 null 的引用类型的注释。
dotnet_diagnostic.CS8632.severity = suggestion
+
+[*.cs]
+#### 命名样式 ####
+
+# 命名规则
+
+dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
+dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
+dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
+
+dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.types_should_be_pascal_case.symbols = types
+dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
+
+dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
+dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
+
+# 符号规范
+
+dotnet_naming_symbols.interface.applicable_kinds = interface
+dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.interface.required_modifiers =
+
+dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
+dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.types.required_modifiers =
+
+dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
+dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.non_field_members.required_modifiers =
+
+# 命名样式
+
+dotnet_naming_style.begins_with_i.required_prefix = I
+dotnet_naming_style.begins_with_i.required_suffix =
+dotnet_naming_style.begins_with_i.word_separator =
+dotnet_naming_style.begins_with_i.capitalization = pascal_case
+
+dotnet_naming_style.pascal_case.required_prefix =
+dotnet_naming_style.pascal_case.required_suffix =
+dotnet_naming_style.pascal_case.word_separator =
+dotnet_naming_style.pascal_case.capitalization = pascal_case
+
+dotnet_naming_style.pascal_case.required_prefix =
+dotnet_naming_style.pascal_case.required_suffix =
+dotnet_naming_style.pascal_case.word_separator =
+dotnet_naming_style.pascal_case.capitalization = pascal_case
+csharp_using_directive_placement = outside_namespace:silent
+csharp_style_expression_bodied_methods = false:silent
+csharp_style_expression_bodied_constructors = false:silent
+csharp_style_expression_bodied_operators = false:silent
+csharp_style_expression_bodied_properties = true:silent
+csharp_style_expression_bodied_indexers = true:silent
+csharp_style_expression_bodied_accessors = true:silent
+csharp_style_expression_bodied_lambdas = true:silent
+csharp_style_expression_bodied_local_functions = false:silent
+csharp_style_conditional_delegate_call = true:suggestion
+csharp_style_var_for_built_in_types = false:silent
+csharp_style_var_when_type_is_apparent = false:silent
+csharp_style_var_elsewhere = false:silent
+csharp_prefer_simple_using_statement = true:suggestion
+csharp_prefer_braces = true:silent
+csharp_style_namespace_declarations = file_scoped:silent
+csharp_style_prefer_method_group_conversion = true:silent
+csharp_style_prefer_top_level_statements = true:silent
+csharp_style_prefer_primary_constructors = true:suggestion
+csharp_prefer_static_local_function = true:suggestion
+csharp_style_prefer_readonly_struct = true:suggestion
+csharp_space_around_binary_operators = before_and_after
+csharp_indent_labels = one_less_than_current
+
+[*.vb]
+#### 命名样式 ####
+
+# 命名规则
+
+dotnet_naming_rule.interface_should_be_以_i_开始.severity = suggestion
+dotnet_naming_rule.interface_should_be_以_i_开始.symbols = interface
+dotnet_naming_rule.interface_should_be_以_i_开始.style = 以_i_开始
+
+dotnet_naming_rule.类型_should_be_帕斯卡拼写法.severity = suggestion
+dotnet_naming_rule.类型_should_be_帕斯卡拼写法.symbols = 类型
+dotnet_naming_rule.类型_should_be_帕斯卡拼写法.style = 帕斯卡拼写法
+
+dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.severity = suggestion
+dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.symbols = 非字段成员
+dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.style = 帕斯卡拼写法
+
+# 符号规范
+
+dotnet_naming_symbols.interface.applicable_kinds = interface
+dotnet_naming_symbols.interface.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
+dotnet_naming_symbols.interface.required_modifiers =
+
+dotnet_naming_symbols.类型.applicable_kinds = class, struct, interface, enum
+dotnet_naming_symbols.类型.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
+dotnet_naming_symbols.类型.required_modifiers =
+
+dotnet_naming_symbols.非字段成员.applicable_kinds = property, event, method
+dotnet_naming_symbols.非字段成员.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
+dotnet_naming_symbols.非字段成员.required_modifiers =
+
+# 命名样式
+
+dotnet_naming_style.以_i_开始.required_prefix = I
+dotnet_naming_style.以_i_开始.required_suffix =
+dotnet_naming_style.以_i_开始.word_separator =
+dotnet_naming_style.以_i_开始.capitalization = pascal_case
+
+dotnet_naming_style.帕斯卡拼写法.required_prefix =
+dotnet_naming_style.帕斯卡拼写法.required_suffix =
+dotnet_naming_style.帕斯卡拼写法.word_separator =
+dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case
+
+dotnet_naming_style.帕斯卡拼写法.required_prefix =
+dotnet_naming_style.帕斯卡拼写法.required_suffix =
+dotnet_naming_style.帕斯卡拼写法.word_separator =
+dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case
+
+[*.{cs,vb}]
+end_of_line = crlf
+dotnet_style_qualification_for_field = false:silent
+dotnet_style_qualification_for_property = false:silent
+dotnet_style_qualification_for_method = false:silent
+dotnet_style_qualification_for_event = false:silent
+dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
+indent_size = 4
+tab_width = 4
+dotnet_style_operator_placement_when_wrapping = beginning_of_line
+dotnet_diagnostic.CA1416.severity = none
\ No newline at end of file
diff --git a/VPet-Simulator.Core/VPet-Simulator.Core.csproj b/VPet-Simulator.Core/VPet-Simulator.Core.csproj
index 31dad19..d3b327f 100644
--- a/VPet-Simulator.Core/VPet-Simulator.Core.csproj
+++ b/VPet-Simulator.Core/VPet-Simulator.Core.csproj
@@ -23,10 +23,10 @@
-
+
-
-
+
+
diff --git a/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj b/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj
index aa9263b..25783f9 100644
--- a/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj
+++ b/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj
@@ -16,9 +16,9 @@
-
+
-
-
+
+
\ No newline at end of file
diff --git a/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj b/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj
index c5dc874..6fc7dbf 100644
--- a/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj
+++ b/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj
@@ -205,12 +205,12 @@
-
+
-
+
diff --git a/VPet.Solution/Models/SettingEditor/ModModel.cs b/VPet.Solution/Models/SettingEditor/ModModel.cs
new file mode 100644
index 0000000..a80d7b6
--- /dev/null
+++ b/VPet.Solution/Models/SettingEditor/ModModel.cs
@@ -0,0 +1,233 @@
+using System.ComponentModel;
+using System.Windows.Media.Imaging;
+using LinePutScript.Localization.WPF;
+
+namespace VPet.Solution.Models.SettingEditor;
+
+public class ModModel : ObservableClass
+{
+ #region ID
+ private string _id = string.Empty;
+ public string ID
+ {
+ get => _id;
+ set => SetProperty(ref _id, value);
+ }
+ #endregion
+
+ #region Name
+ private string _name = string.Empty;
+
+ ///
+ /// 名称
+ ///
+ [ReflectionProperty(nameof(ModLoader.Name))]
+ public string Name
+ {
+ get => _name;
+ set => SetProperty(ref _name, value);
+ }
+ #endregion
+
+ #region Description
+ private string _description = string.Empty;
+
+ ///
+ /// 描述
+ ///
+ [ReflectionProperty(nameof(ModLoader.Intro))]
+ public string Description
+ {
+ get => _description;
+ set => SetProperty(ref _description, value);
+ }
+ #endregion
+
+ #region Author
+ private string _author = string.Empty;
+
+ ///
+ /// 作者
+ ///
+ [ReflectionProperty(nameof(ModLoader.Author))]
+ public string Author
+ {
+ get => _author;
+ set => SetProperty(ref _author, value);
+ }
+ #endregion
+
+ #region ModVersion
+ private int _modVersion;
+
+ ///
+ /// 模组版本
+ ///
+ [ReflectionProperty(nameof(ModLoader.Ver))]
+ public int ModVersion
+ {
+ get => _modVersion;
+ set => SetProperty(ref _modVersion, value);
+ }
+ #endregion
+
+ #region GameVersion
+ private int _gameVersion;
+
+ ///
+ /// 游戏版本
+ ///
+ [ReflectionProperty(nameof(ModLoader.GameVer))]
+ public int GameVersion
+ {
+ get => _gameVersion;
+ set => SetProperty(ref _gameVersion, value);
+ }
+ #endregion
+
+ #region Tags
+ private HashSet _tags = null!;
+
+ ///
+ /// 功能
+ ///
+ [ReflectionProperty(nameof(ModLoader.Tags))]
+ public HashSet Tags
+ {
+ get => _tags;
+ set => SetProperty(ref _tags, value);
+ }
+ #endregion
+
+ #region Image
+ private BitmapImage _image = null!;
+
+ ///
+ /// 图像
+ ///
+ [ReflectionProperty(nameof(ModLoader.Image))]
+ public BitmapImage Image
+ {
+ get => _image;
+ set => SetProperty(ref _image, value);
+ }
+ #endregion
+
+ #region ItemId
+ private ulong _itemId;
+
+ [ReflectionProperty(nameof(ModLoader.ItemID))]
+ public ulong ItemId
+ {
+ get => _itemId;
+ set => SetProperty(ref _itemId, value);
+ }
+ #endregion
+
+
+ #region ModPath
+
+ private string _modPath = string.Empty;
+
+ [ReflectionProperty(nameof(ModLoader.ModPath))]
+ public string ModPath
+ {
+ get => _modPath;
+ set => SetProperty(ref _modPath, value);
+ }
+ #endregion
+
+ #region IsEnabled
+ private bool? _isEnabled = true;
+
+ ///
+ /// 启用状态
+ /// 已启用为 已禁用为 已失效为
+ ///
+ public bool? IsEnabled
+ {
+ get => _isEnabled;
+ set => SetProperty(ref _isEnabled, value);
+ }
+ #endregion
+
+ #region IsPass
+ private bool _isPass;
+
+ ///
+ /// 是通过检查的代码模组
+ ///
+ public bool IsPass
+ {
+ get => _isPass;
+ set => SetProperty(ref _isPass, value);
+ }
+ #endregion
+
+ #region IsMsg
+ private bool _isMsg;
+
+ ///
+ /// 是含有代码的模组
+ ///
+ public bool IsMsg
+ {
+ get => _isMsg;
+ set => SetProperty(ref _isMsg, value);
+ }
+ #endregion
+
+ #region State
+ private string _state = string.Empty;
+ public string State
+ {
+ get => _state;
+ set => SetProperty(ref _state, value);
+ }
+ #endregion
+
+
+ public ModModel()
+ {
+ IsEnabled = null;
+ RefreshState();
+ }
+
+ private void ModModel_PropertyChanged(
+ object? sender,
+ System.ComponentModel.PropertyChangedEventArgs e
+ )
+ {
+ if (e.PropertyName == nameof(IsEnabled))
+ {
+ RefreshState();
+ }
+ }
+
+ public ModModel(ModLoader loader)
+ {
+ PropertyChanged += ModModel_PropertyChanged;
+ ReflectionUtils.SetValue(loader, this);
+ RefreshState();
+ ID = Name;
+ Name = Name.Translate();
+ Description = Description.Translate();
+ LocalizeCore.BindingNotify.PropertyChanged += BindingNotify_PropertyChanged;
+ }
+
+ private void BindingNotify_PropertyChanged(object? sender, PropertyChangedEventArgs e)
+ {
+ Name = Name.Translate();
+ Description = Description.Translate();
+ }
+
+ public void RefreshState()
+ {
+ if (IsEnabled is true)
+ State = "已启用".Translate();
+ else if (IsEnabled is false)
+ State = "已禁用".Translate();
+ else
+ State = "已损坏".Translate();
+ }
+}
diff --git a/VPet.Solution/Models/SettingEditor/ModSettingModel.cs b/VPet.Solution/Models/SettingEditor/ModSettingModel.cs
index 43d12db..98eac13 100644
--- a/VPet.Solution/Models/SettingEditor/ModSettingModel.cs
+++ b/VPet.Solution/Models/SettingEditor/ModSettingModel.cs
@@ -1,16 +1,14 @@
-using HKW.HKWUtils.Observable;
-using LinePutScript;
-using LinePutScript.Localization.WPF;
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
-using System.Windows.Media.Imaging;
+using HKW.HKWUtils.Observable;
+using LinePutScript;
+using LinePutScript.Localization.WPF;
using VPet.Solution.Views.SettingEditor;
using VPet_Simulator.Windows.Interface;
@@ -23,7 +21,7 @@ public class ModSettingModel : ObservableClass
public const string MsgModLineName = "msgmod";
public const string WorkShopLineName = "workshop";
public static string ModDirectory = Path.Combine(Environment.CurrentDirectory, "mod");
- public static Dictionary LocalMods { get; private set; } = null;
+ public static Dictionary LocalMods { get; private set; } = null!;
#region Mods
private ObservableCollection _mods = new();
@@ -117,230 +115,3 @@ public class ModSettingModel : ObservableClass
}
#endregion
}
-
-public class ModModel : ObservableClass
-{
- #region ID
- private string _id;
- public string ID
- {
- get => _id;
- set => SetProperty(ref _id, value);
- }
- #endregion
-
- #region Name
- private string _name;
-
- ///
- /// 名称
- ///
- [ReflectionProperty(nameof(ModLoader.Name))]
- public string Name
- {
- get => _name;
- set => SetProperty(ref _name, value);
- }
- #endregion
-
- #region Description
- private string _description;
-
- ///
- /// 描述
- ///
- [ReflectionProperty(nameof(ModLoader.Intro))]
- public string Description
- {
- get => _description;
- set => SetProperty(ref _description, value);
- }
- #endregion
-
- #region Author
- private string _author;
-
- ///
- /// 作者
- ///
- [ReflectionProperty(nameof(ModLoader.Author))]
- public string Author
- {
- get => _author;
- set => SetProperty(ref _author, value);
- }
- #endregion
-
- #region ModVersion
- private int _modVersion;
-
- ///
- /// 模组版本
- ///
- [ReflectionProperty(nameof(ModLoader.Ver))]
- public int ModVersion
- {
- get => _modVersion;
- set => SetProperty(ref _modVersion, value);
- }
- #endregion
-
- #region GameVersion
- private int _gameVersion;
-
- ///
- /// 游戏版本
- ///
- [ReflectionProperty(nameof(ModLoader.GameVer))]
- public int GameVersion
- {
- get => _gameVersion;
- set => SetProperty(ref _gameVersion, value);
- }
- #endregion
-
- #region Tags
- private HashSet _tags;
-
- ///
- /// 功能
- ///
- [ReflectionProperty(nameof(ModLoader.Tags))]
- public HashSet Tags
- {
- get => _tags;
- set => SetProperty(ref _tags, value);
- }
- #endregion
-
- #region Image
- private BitmapImage _image;
-
- ///
- /// 图像
- ///
- [ReflectionProperty(nameof(ModLoader.Image))]
- public BitmapImage Image
- {
- get => _image;
- set => SetProperty(ref _image, value);
- }
- #endregion
-
- #region ItemId
- private ulong _itemId;
-
- [ReflectionProperty(nameof(ModLoader.ItemID))]
- public ulong ItemId
- {
- get => _itemId;
- set => SetProperty(ref _itemId, value);
- }
- #endregion
-
-
- #region ModPath
-
- private string _modPath;
-
- [ReflectionProperty(nameof(ModLoader.ModPath))]
- public string ModPath
- {
- get => _modPath;
- set => SetProperty(ref _modPath, value);
- }
- #endregion
-
- #region IsEnabled
- private bool? _isEnabled = true;
-
- ///
- /// 已启用
- ///
- public bool? IsEnabled
- {
- get => _isEnabled;
- set => SetProperty(ref _isEnabled, value);
- }
- #endregion
-
- #region IsPass
- private bool _isPass;
-
- ///
- /// 是通过检查的代码模组
- ///
- public bool IsPass
- {
- get => _isPass;
- set => SetProperty(ref _isPass, value);
- }
- #endregion
-
- #region IsMsg
- private bool _isMsg;
-
- ///
- /// 是含有代码的模组
- ///
- public bool IsMsg
- {
- get => _isMsg;
- set => SetProperty(ref _isMsg, value);
- }
- #endregion
-
- #region State
- private string _state;
- public string State
- {
- get => _state;
- set => SetProperty(ref _state, value);
- }
- #endregion
-
-
- public ModModel()
- {
- IsEnabled = null;
- RefreshState();
- }
-
- private void ModModel_PropertyChanged(
- object sender,
- System.ComponentModel.PropertyChangedEventArgs e
- )
- {
- if (e.PropertyName == nameof(IsEnabled))
- {
- RefreshState();
- }
- }
-
- public ModModel(ModLoader loader)
- {
- PropertyChanged += ModModel_PropertyChanged;
- ReflectionUtils.SetValue(loader, this);
- RefreshState();
- ID = Name;
- Name = Name.Translate();
- Description = Description.Translate();
- LocalizeCore.BindingNotify.PropertyChanged += BindingNotify_PropertyChanged;
- }
-
- private void BindingNotify_PropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- Name = Name.Translate();
- Description = Description.Translate();
- }
-
- public void RefreshState()
- {
- if (IsEnabled is true)
- State = "已启用".Translate();
- else if (IsEnabled is false)
- State = "已关闭".Translate();
- else
- State = "已损坏".Translate();
- }
-}
diff --git a/VPet.Solution/Models/SettingEditor/SettingModel.cs b/VPet.Solution/Models/SettingEditor/SettingModel.cs
index 6f30625..361e034 100644
--- a/VPet.Solution/Models/SettingEditor/SettingModel.cs
+++ b/VPet.Solution/Models/SettingEditor/SettingModel.cs
@@ -1,11 +1,11 @@
-using FastMember;
-using HKW.HKWUtils.Observable;
-using LinePutScript;
-using LinePutScript.Localization.WPF;
-using System.ComponentModel;
+using System.ComponentModel;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Windows;
+using FastMember;
+using HKW.HKWUtils.Observable;
+using LinePutScript;
+using LinePutScript.Localization.WPF;
using VPet.Solution.Properties;
using VPet_Simulator.Windows.Interface;
@@ -131,7 +131,7 @@ public class SettingModel : ObservableClass
}
}
- private void Notify_PropertyChanged(object sender, PropertyChangedEventArgs e)
+ private void Notify_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
IsChanged = true;
}
diff --git a/VPet.Solution/Utils/ElementHelper.cs b/VPet.Solution/Utils/ElementHelper.cs
index d270394..fde5281 100644
--- a/VPet.Solution/Utils/ElementHelper.cs
+++ b/VPet.Solution/Utils/ElementHelper.cs
@@ -1,7 +1,7 @@
-using HKW.WPF.Extensions;
-using System.Windows;
+using System.Windows;
using System.Windows.Data;
using System.Windows.Input;
+using HKW.WPF.Extensions;
namespace HKW.WPF.Helpers;
@@ -95,7 +95,7 @@ public static class ElementHelper
element.KeyDown -= Element_KeyDown;
element.KeyDown += Element_KeyDown;
- static void Element_KeyDown(object sender, KeyEventArgs e)
+ static void Element_KeyDown(object? sender, KeyEventArgs e)
{
if (sender is not FrameworkElement element)
return;
@@ -184,7 +184,7 @@ public static class ElementHelper
#endregion
#region Element
- static void Element_SizeChanged(object sender, SizeChangedEventArgs e)
+ static void Element_SizeChanged(object? sender, SizeChangedEventArgs e)
{
if (sender is not FrameworkElement element)
return;
diff --git a/VPet.Solution/Utils/Expansions.cs b/VPet.Solution/Utils/Expansions.cs
index 02f2268..28abfb2 100644
--- a/VPet.Solution/Utils/Expansions.cs
+++ b/VPet.Solution/Utils/Expansions.cs
@@ -340,7 +340,7 @@ public static class Extensions
window.Activate();
}
- private static void WindowCloseState_Closing(object sender, CancelEventArgs e)
+ private static void WindowCloseState_Closing(object? sender, CancelEventArgs e)
{
if (sender is not Window window)
return;
diff --git a/VPet.Solution/VPet.Solution.csproj b/VPet.Solution/VPet.Solution.csproj
index 6a83134..2989c90 100644
--- a/VPet.Solution/VPet.Solution.csproj
+++ b/VPet.Solution/VPet.Solution.csproj
@@ -19,11 +19,11 @@
-
+
-
-
+
+
\ No newline at end of file
diff --git a/VPet.Solution/ViewModels/MainWindowVM.cs b/VPet.Solution/ViewModels/MainWindowVM.cs
index 213f0df..be386f6 100644
--- a/VPet.Solution/ViewModels/MainWindowVM.cs
+++ b/VPet.Solution/ViewModels/MainWindowVM.cs
@@ -1,11 +1,11 @@
-using HKW.HKWUtils.Observable;
-using LinePutScript.Localization.WPF;
-using Panuon.WPF.UI;
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using HKW.HKWUtils.Observable;
+using LinePutScript.Localization.WPF;
+using Panuon.WPF.UI;
using VPet.Solution.Models.SettingEditor;
using VPet.Solution.ViewModels.SettingEditor;
using VPet_Simulator.Windows.Interface;
@@ -14,14 +14,14 @@ namespace VPet.Solution.ViewModels;
public class MainWindowVM : ObservableClass
{
- private readonly SettingModel _mainSetting;
+ private readonly SettingModel? _mainSetting;
public MainWindowVM()
{
LocalizeCore.StoreTranslation = true;
LocalizeCore.LoadDefaultCulture();
- _mainSetting = SettingWindowVM.Current.ShowSettings.FirstOrDefault(
- m => m.Name == nameof(Setting)
+ _mainSetting = SettingWindowVM.Current.ShowSettings.FirstOrDefault(m =>
+ m.Name == nameof(Setting)
);
if (string.IsNullOrWhiteSpace(_mainSetting?.GraphicsSetting?.Language))
CurrentCulture = LocalizeCore.CurrentCulture;
@@ -51,7 +51,7 @@ public class MainWindowVM : ObservableClass
}
#region Property
- public IEnumerable AvailableCultures => LocalizeCore.AvailableCultures;
+ public static IEnumerable AvailableCultures => LocalizeCore.AvailableCultures;
#region CurrentCulture
private string _currentCulture = string.Empty;
public string CurrentCulture
@@ -62,7 +62,8 @@ public class MainWindowVM : ObservableClass
SetProperty(ref _currentCulture, value);
LocalizeCore.LoadCulture(_currentCulture);
if (
- _mainSetting is not null && _mainSetting.GraphicsSetting.Language != _currentCulture
+ _mainSetting is not null
+ && _mainSetting.GraphicsSetting.Language != _currentCulture
)
{
_mainSetting.GraphicsSetting.Language = _currentCulture;
diff --git a/VPet.Solution/ViewModels/SaveViewer/SaveWindowVM.cs b/VPet.Solution/ViewModels/SaveViewer/SaveWindowVM.cs
index 34fb4e6..4c1ab6c 100644
--- a/VPet.Solution/ViewModels/SaveViewer/SaveWindowVM.cs
+++ b/VPet.Solution/ViewModels/SaveViewer/SaveWindowVM.cs
@@ -1,8 +1,4 @@
-using HKW.HKWUtils.Observable;
-using LinePutScript;
-using LinePutScript.Localization.WPF;
-using Panuon.WPF.UI;
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
@@ -10,6 +6,10 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
+using HKW.HKWUtils.Observable;
+using LinePutScript;
+using LinePutScript.Localization.WPF;
+using Panuon.WPF.UI;
using VPet.Solution.Models;
using VPet.Solution.Models.SaveViewer;
using VPet.Solution.Models.SettingEditor;
@@ -20,10 +20,10 @@ namespace VPet.Solution.ViewModels.SaveViewer;
public class SaveWindowVM : ObservableClass
{
- public static SaveWindowVM Current { get; private set; }
+ public static SaveWindowVM Current { get; private set; } = null!;
#region Properties
- private SaveModel _currentSave;
+ private SaveModel _currentSave = null!;
public SaveModel CurrentSave
{
get => _currentSave;
@@ -32,14 +32,14 @@ public class SaveWindowVM : ObservableClass
private readonly ObservableCollection _saves = new();
- private IEnumerable _showSaves;
+ private IEnumerable _showSaves = null!;
public IEnumerable ShowSaves
{
get => _showSaves;
set => SetProperty(ref _showSaves, value);
}
- private string _searchSave;
+ private string _searchSave = string.Empty;
public string SearchSave
{
get => _searchSave;
@@ -85,12 +85,12 @@ public class SaveWindowVM : ObservableClass
if (string.IsNullOrWhiteSpace(name))
ShowSaves = _saves;
else
- ShowSaves = _saves.Where(
- s => s.Name.Contains(SearchSave, StringComparison.OrdinalIgnoreCase)
+ ShowSaves = _saves.Where(s =>
+ s.Name.Contains(SearchSave, StringComparison.OrdinalIgnoreCase)
);
}
- private void SaveWindowVM_PropertyChanged(object sender, PropertyChangedEventArgs e)
+ private void SaveWindowVM_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(SearchSave))
{
diff --git a/VPet.Solution/ViewModels/SettingEditor/SettingWindowVM.cs b/VPet.Solution/ViewModels/SettingEditor/SettingWindowVM.cs
index 0b275d9..d943839 100644
--- a/VPet.Solution/ViewModels/SettingEditor/SettingWindowVM.cs
+++ b/VPet.Solution/ViewModels/SettingEditor/SettingWindowVM.cs
@@ -1,8 +1,4 @@
-using HKW.HKWUtils.Observable;
-using LinePutScript;
-using LinePutScript.Localization.WPF;
-using Panuon.WPF;
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
@@ -10,6 +6,10 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
+using HKW.HKWUtils.Observable;
+using LinePutScript;
+using LinePutScript.Localization.WPF;
+using Panuon.WPF;
using VPet.Solution.Models;
using VPet.Solution.Models.SettingEditor;
using VPet.Solution.Views.SettingEditor;
@@ -19,9 +19,9 @@ namespace VPet.Solution.ViewModels.SettingEditor;
public class SettingWindowVM : ObservableClass
{
- public static SettingWindowVM Current { get; private set; }
+ public static SettingWindowVM Current { get; private set; } = null!;
#region Properties
- private SettingModel _currentSetting;
+ private SettingModel _currentSetting = null!;
public SettingModel CurrentSetting
{
get => _currentSetting;
@@ -47,25 +47,30 @@ public class SettingWindowVM : ObservableClass
return;
}
}
- SetProperty(ref _currentSetting, value);
+ SetProperty(ref _currentSetting!, value);
}
}
- private readonly ObservableCollection _settings = new();
+ public readonly ObservableCollection Settings = new();
- private IEnumerable _showSettings;
+ #region ShowSettings
+ private IEnumerable _showSettings = null!;
public IEnumerable ShowSettings
{
get => _showSettings;
set => SetProperty(ref _showSettings, value);
}
- private string _searchSetting;
+ #endregion
+
+ #region SearchSetting
+ private string _searchSetting = string.Empty;
public string SearchSetting
{
get => _searchSetting;
set => SetProperty(ref _searchSetting, value);
}
+ #endregion
#endregion
@@ -104,7 +109,7 @@ public class SettingWindowVM : ObservableClass
{
Current = this;
LoadSettings();
- ShowSettings = _settings = new(_settings.OrderBy(m => m.Name));
+ ShowSettings = Settings = new(Settings.OrderBy(m => m.Name));
PropertyChanged += MainWindowVM_PropertyChanged;
OpenFileCommand.ExecuteCommand += OpenFileCommand_ExecuteCommand;
@@ -128,8 +133,8 @@ public class SettingWindowVM : ObservableClass
is not MessageBoxResult.Yes
)
return;
- for (var i = 0; i < _settings.Count; i++)
- _settings[i] = new SettingModel();
+ for (var i = 0; i < Settings.Count; i++)
+ Settings[i] = new SettingModel();
}
private void OpenFileInExplorerCommand_ExecuteCommand(SettingModel parameter)
@@ -155,7 +160,7 @@ public class SettingWindowVM : ObservableClass
is not MessageBoxResult.Yes
)
return;
- foreach (var setting in _settings)
+ foreach (var setting in Settings)
setting.Save();
}
@@ -177,7 +182,7 @@ public class SettingWindowVM : ObservableClass
is not MessageBoxResult.Yes
)
return;
- CurrentSetting = _settings[_settings.IndexOf(CurrentSetting)] = new SettingModel()
+ CurrentSetting = Settings[Settings.IndexOf(CurrentSetting)] = new SettingModel()
{
Name = CurrentSetting.Name,
FilePath = CurrentSetting.FilePath
@@ -188,14 +193,14 @@ public class SettingWindowVM : ObservableClass
public void RefreshShowSettings(string name)
{
if (string.IsNullOrWhiteSpace(name))
- ShowSettings = _settings;
+ ShowSettings = Settings;
else
- ShowSettings = _settings.Where(
- s => s.Name.Contains(SearchSetting, StringComparison.OrdinalIgnoreCase)
+ ShowSettings = Settings.Where(s =>
+ s.Name.Contains(SearchSetting, StringComparison.OrdinalIgnoreCase)
);
}
- private void MainWindowVM_PropertyChanged(object sender, PropertyChangedEventArgs e)
+ private void MainWindowVM_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(SearchSetting))
{
@@ -212,7 +217,7 @@ public class SettingWindowVM : ObservableClass
{
var setting = new Setting(File.ReadAllText(file));
var settingModel = new SettingModel(setting) { Name = fileName, FilePath = file };
- _settings.Add(settingModel);
+ Settings.Add(settingModel);
}
catch (Exception ex)
{
@@ -231,7 +236,7 @@ public class SettingWindowVM : ObservableClass
)
return;
var setting = new SettingModel() { Name = fileName, FilePath = file };
- _settings.Add(setting);
+ Settings.Add(setting);
setting.Save();
}
}
diff --git a/VPet.Solution/Views/MainWindow.xaml.cs b/VPet.Solution/Views/MainWindow.xaml.cs
index df87ac5..770c36a 100644
--- a/VPet.Solution/Views/MainWindow.xaml.cs
+++ b/VPet.Solution/Views/MainWindow.xaml.cs
@@ -1,10 +1,10 @@
-using HKW.HKWUtils;
-using LinePutScript.Localization.WPF;
-using Panuon.WPF.UI;
-using System.ComponentModel;
+using System.ComponentModel;
using System.Text;
using System.Windows;
using System.Windows.Controls;
+using HKW.HKWUtils;
+using LinePutScript.Localization.WPF;
+using Panuon.WPF.UI;
using VPet.Solution.Models.SettingEditor;
using VPet.Solution.ViewModels;
using VPet.Solution.Views.SaveViewer;
@@ -35,18 +35,20 @@ public partial class MainWindow : WindowX
Closed += MainWindow_Closed;
}
- private void MainWindow_Closed(object sender, EventArgs e)
+ private void MainWindow_Closed(object? sender, EventArgs e)
{
+ foreach (var mod in ModSettingModel.LocalMods)
+ mod.Value.Image?.CloseStream();
SettingWindow.CloseX();
SaveWindow.CloseX();
}
- private void Button_OpenSettingEditor_Click(object sender, RoutedEventArgs e)
+ private void Button_OpenSettingEditor_Click(object? sender, RoutedEventArgs e)
{
SettingWindow.ShowOrActivate();
}
- private void Button_OpenSaveViewer_Click(object sender, RoutedEventArgs e)
+ private void Button_OpenSaveViewer_Click(object? sender, RoutedEventArgs e)
{
SaveWindow.ShowOrActivate();
}
diff --git a/VPet.Solution/Views/SaveViewer/SaveWindow.xaml.cs b/VPet.Solution/Views/SaveViewer/SaveWindow.xaml.cs
index 310ee87..1eb5f54 100644
--- a/VPet.Solution/Views/SaveViewer/SaveWindow.xaml.cs
+++ b/VPet.Solution/Views/SaveViewer/SaveWindow.xaml.cs
@@ -1,8 +1,8 @@
-using HKW.HKWUtils;
-using Panuon.WPF.UI;
-using System.ComponentModel;
+using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
+using HKW.HKWUtils;
+using Panuon.WPF.UI;
using VPet.Solution.ViewModels.SaveViewer;
using VPet.Solution.ViewModels.SettingEditor;
@@ -28,7 +28,7 @@ public partial class SaveWindow : WindowX
Instance = this;
}
- private void Frame_Main_ContentRendered(object sender, EventArgs e)
+ private void Frame_Main_ContentRendered(object? sender, EventArgs e)
{
if (sender is not Frame frame)
return;
diff --git a/VPet.Solution/Views/SettingEditor/GraphicsSettingPage.xaml.cs b/VPet.Solution/Views/SettingEditor/GraphicsSettingPage.xaml.cs
index f00a53e..a59bdef 100644
--- a/VPet.Solution/Views/SettingEditor/GraphicsSettingPage.xaml.cs
+++ b/VPet.Solution/Views/SettingEditor/GraphicsSettingPage.xaml.cs
@@ -1,5 +1,4 @@
-using HKW.HKWUtils;
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -13,6 +12,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
+using HKW.HKWUtils;
using VPet.Solution.ViewModels.SettingEditor;
namespace VPet.Solution.Views.SettingEditor;
@@ -30,7 +30,7 @@ public partial class GraphicsSettingPage : Page
this.SetViewModel();
}
- private void Button_StartPoint_Click(object sender, RoutedEventArgs e)
+ private void Button_StartPoint_Click(object? sender, RoutedEventArgs e)
{
ViewModel.GraphicsSetting.StartRecordPoint = new(
SettingWindow.Instance.Left,
diff --git a/VPet.Solution/Views/SettingEditor/SettingWindow.xaml.cs b/VPet.Solution/Views/SettingEditor/SettingWindow.xaml.cs
index 34364c4..7495098 100644
--- a/VPet.Solution/Views/SettingEditor/SettingWindow.xaml.cs
+++ b/VPet.Solution/Views/SettingEditor/SettingWindow.xaml.cs
@@ -1,9 +1,9 @@
-using HKW.HKWUtils;
-using LinePutScript.Localization.WPF;
-using Panuon.WPF.UI;
-using System.ComponentModel;
+using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
+using HKW.HKWUtils;
+using LinePutScript.Localization.WPF;
+using Panuon.WPF.UI;
using VPet.Solution.ViewModels.SettingEditor;
namespace VPet.Solution.Views.SettingEditor;
@@ -32,7 +32,7 @@ public partial class SettingWindow : WindowX
Instance = this;
}
- private void SettingWindow_Closing(object sender, CancelEventArgs e)
+ private void SettingWindow_Closing(object? sender, CancelEventArgs e)
{
if (ViewModel?.CurrentSetting?.IsChanged is true)
{
@@ -61,7 +61,7 @@ public partial class SettingWindow : WindowX
}
}
- private void Frame_Main_ContentRendered(object sender, EventArgs e)
+ private void Frame_Main_ContentRendered(object? sender, EventArgs e)
{
if (sender is not Frame frame)
return;