diff --git a/VPet.Solution/Models/GraphicsSettingsModel.cs b/VPet.Solution/Models/GraphicsSettingModel.cs similarity index 94% rename from VPet.Solution/Models/GraphicsSettingsModel.cs rename to VPet.Solution/Models/GraphicsSettingModel.cs index 2994d67..515d8e7 100644 --- a/VPet.Solution/Models/GraphicsSettingsModel.cs +++ b/VPet.Solution/Models/GraphicsSettingModel.cs @@ -3,7 +3,7 @@ using System.Windows; namespace VPet.Solution.Models; -public class GraphicsSettingsModel : ObservableClass +public class GraphicsSettingModel : ObservableClass { private double _zoomLevel = 1; @@ -138,12 +138,12 @@ public class GraphicsSettingsModel : ObservableClass // set => SetProperty(ref _startRecordLastPoint, value); //} - private ObservablePoint _startRecordPoint; + private ObservablePoint _startRecordPoint; /// /// 设置中桌宠启动的位置 /// - public ObservablePoint StartRecordPoint + public ObservablePoint StartRecordPoint { get => _startRecordPoint; set => SetProperty(ref _startRecordPoint, value); diff --git a/VPet.Solution/Models/SettingsModel.cs b/VPet.Solution/Models/InteractiveSettingModel.cs similarity index 71% rename from VPet.Solution/Models/SettingsModel.cs rename to VPet.Solution/Models/InteractiveSettingModel.cs index 36ce8de..42ba843 100644 --- a/VPet.Solution/Models/SettingsModel.cs +++ b/VPet.Solution/Models/InteractiveSettingModel.cs @@ -1,35 +1,19 @@ -using FastMember; -using HKW.HKWUtils.Observable; -using System.ComponentModel; -using System.Windows; -using VPet.Solution.Properties; +using HKW.HKWUtils.Observable; using VPet_Simulator.Core; -using VPet_Simulator.Windows.Interface; namespace VPet.Solution.Models; -public class SettingsModel : ObservableClass +public class InteractiveSettingModel : ObservableClass { - private GraphicsSettingsModel _graphicsSettings; - public GraphicsSettingsModel GraphicsSettings - { - get => _graphicsSettings; - set => SetProperty(ref _graphicsSettings, value); - } + private string _petName; - public SettingsModel(Setting setting) + /// + /// 宠物名称 + /// + public string PetName { - GraphicsSettings = LoadGraphicsSettings(setting); - } - - private GraphicsSettingsModel LoadGraphicsSettings(Setting setting) - { - var graphicsSettings = new GraphicsSettingsModel(); - var sourceAccessor = ObjectAccessor.Create(setting); - var targetAccessor = ObjectAccessor.Create(graphicsSettings); - foreach (var property in typeof(GraphicsSettingsModel).GetProperties()) - targetAccessor[property.Name] = sourceAccessor[property.Name]; - return graphicsSettings; + get => _petName; + set => SetProperty(ref _petName, value); } private double _voiceVolume; @@ -43,22 +27,6 @@ public class SettingsModel : ObservableClass set => SetProperty(ref _voiceVolume, value); } - /// - /// 数据收集是否被禁止(当日) - /// - public bool DiagnosisDayEnable { get; } = true; - - private bool _diagnosis; - - /// - /// 是否启用数据收集 - /// - public bool Diagnosis - { - get => _diagnosis; - set => SetProperty(ref _diagnosis, value); - } - private GameSave.ModeType _calFunState; /// @@ -70,39 +38,6 @@ public class SettingsModel : ObservableClass set => SetProperty(ref _calFunState, value); } - private int _diagnosisInterval; - - /// - /// 数据收集频率 - /// - public int DiagnosisInterval - { - get => _diagnosisInterval; - set => SetProperty(ref _diagnosisInterval, value); - } - - private int _autoSaveInterval; - - /// - /// 自动保存频率 (min) - /// - public int AutoSaveInterval - { - get => _autoSaveInterval; - set => SetProperty(ref _autoSaveInterval, value); - } - - private int _backupSaveMaxNum; - - /// - /// 备份保存最大数量 - /// - public int BackupSaveMaxNum - { - get => _backupSaveMaxNum; - set => SetProperty(ref _backupSaveMaxNum, value); - } - private bool _petHelper; /// diff --git a/VPet.Solution/Models/SettingModel.cs b/VPet.Solution/Models/SettingModel.cs new file mode 100644 index 0000000..c158088 --- /dev/null +++ b/VPet.Solution/Models/SettingModel.cs @@ -0,0 +1,80 @@ +using FastMember; +using HKW.HKWUtils.Observable; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Windows; +using VPet.Solution.Properties; +using VPet_Simulator.Windows.Interface; + +namespace VPet.Solution.Models; + +public class SettingModel : ObservableClass +{ + private string _name; + + /// + /// 名称 + /// + public string Name + { + get => _name; + set => SetProperty(ref _name, value); + } + + private string _filePath; + + /// + /// 路径 + /// + public string FilePath + { + get => _filePath; + set => SetProperty(ref _filePath, value); + } + + private GraphicsSettingModel _graphicsSetting; + public GraphicsSettingModel GraphicsSetting + { + get => _graphicsSetting; + set => SetProperty(ref _graphicsSetting, value); + } + + private SystemSettingModel _systemSetting; + + public SystemSettingModel SystemSetting + { + get => _systemSetting; + set => SetProperty(ref _systemSetting, value); + } + + private InteractiveSettingModel _interactiveSetting; + public InteractiveSettingModel InteractiveSetting + { + get => _interactiveSetting; + set => SetProperty(ref _interactiveSetting, value); + } + + public SettingModel(Setting setting) + { + GraphicsSetting = LoadGraphicsSettings(setting); + } + + private GraphicsSettingModel LoadGraphicsSettings(Setting setting) + { + var graphicsSettings = new GraphicsSettingModel(); + var sourceAccessor = ObjectAccessor.Create(setting); + var targetAccessor = ObjectAccessor.Create(graphicsSettings); + foreach (var property in typeof(GraphicsSettingModel).GetProperties()) + { + if (sourceAccessor[property.Name] is Point point) + { + targetAccessor[property.Name] = new ObservablePoint(point); + } + else + { + targetAccessor[property.Name] = sourceAccessor[property.Name]; + } + } + return graphicsSettings; + } +} diff --git a/VPet.Solution/Models/SystemSettingModel.cs b/VPet.Solution/Models/SystemSettingModel.cs new file mode 100644 index 0000000..91e412b --- /dev/null +++ b/VPet.Solution/Models/SystemSettingModel.cs @@ -0,0 +1,53 @@ +namespace VPet.Solution.Models; + +public class SystemSettingModel : ObservableClass +{ + /// + /// 数据收集是否被禁止(当日) + /// + public bool DiagnosisDayEnable { get; } = true; + + private bool _diagnosis; + + /// + /// 是否启用数据收集 + /// + public bool Diagnosis + { + get => _diagnosis; + set => SetProperty(ref _diagnosis, value); + } + + private int _diagnosisInterval; + + /// + /// 数据收集频率 + /// + public int DiagnosisInterval + { + get => _diagnosisInterval; + set => SetProperty(ref _diagnosisInterval, value); + } + + private int _autoSaveInterval; + + /// + /// 自动保存频率 (min) + /// + public int AutoSaveInterval + { + get => _autoSaveInterval; + set => SetProperty(ref _autoSaveInterval, value); + } + + private int _backupSaveMaxNum; + + /// + /// 备份保存最大数量 + /// + public int BackupSaveMaxNum + { + get => _backupSaveMaxNum; + set => SetProperty(ref _backupSaveMaxNum, value); + } +} diff --git a/VPet.Solution/Utils/Expansions.cs b/VPet.Solution/Utils/Expansions.cs index a08259d..94d8aba 100644 --- a/VPet.Solution/Utils/Expansions.cs +++ b/VPet.Solution/Utils/Expansions.cs @@ -292,7 +292,7 @@ public static class Extensions /// /// 视图模型类型 /// 窗口 - public static Lazy SetViewModel(this Window window, EventHandler? closedEvent = null) + public static T SetViewModel(this Window window, EventHandler? closedEvent = null) where T : new() { if (window.DataContext is null) @@ -308,7 +308,7 @@ public static class Extensions }; window.Closed += closedEvent; } - return new(() => (T)window.DataContext); + return (T)window.DataContext; } /// @@ -316,10 +316,10 @@ public static class Extensions /// /// 视图模型类型 /// 页面 - public static Lazy SetViewModel(this Page page) + public static T SetViewModel(this Page page) where T : new() { - return new(() => (T)(page.DataContext ??= new T())); + return (T)(page.DataContext ??= new T()); } } diff --git a/VPet.Solution/Utils/ObservablePoint.cs b/VPet.Solution/Utils/ObservablePoint.cs index eff89d6..9b2ab93 100644 --- a/VPet.Solution/Utils/ObservablePoint.cs +++ b/VPet.Solution/Utils/ObservablePoint.cs @@ -1,22 +1,23 @@ -namespace HKW.HKWUtils; +using System.Diagnostics; +using System.Windows; + +namespace HKW.HKWUtils; /// /// 可观察地点 /// -/// 类型 -public class ObservablePoint - : ObservableClass>, - IEquatable> +[DebuggerDisplay("X = {X}, Y = {Y}")] +public class ObservablePoint : ObservableClass, IEquatable { - private T _x; - public T X + private double _x; + public double X { get => _x; set => SetProperty(ref _x, value); } - private T _y; - public T Y + private double _y; + public double Y { get => _y; set => SetProperty(ref _y, value); @@ -24,17 +25,23 @@ public class ObservablePoint public ObservablePoint() { } - public ObservablePoint(T x, T y) + public ObservablePoint(double x, double y) { X = x; Y = y; } + public ObservablePoint(Point point) + { + X = point.X; + Y = point.Y; + } + /// /// 复制一个新的对象 /// /// 新对象 - public ObservablePoint Copy() + public ObservablePoint Copy() { return new(X, Y); } @@ -50,28 +57,113 @@ public class ObservablePoint /// public override bool Equals(object? obj) { - return obj is ObservablePoint temp - && EqualityComparer.Default.Equals(X, temp.X) - && EqualityComparer.Default.Equals(Y, temp.Y); + return obj is ObservablePoint temp + && EqualityComparer.Default.Equals(X, temp.X) + && EqualityComparer.Default.Equals(Y, temp.Y); } /// - public bool Equals(ObservablePoint? other) + public bool Equals(ObservablePoint? other) { return Equals(obj: other); } /// - public static bool operator ==(ObservablePoint a, ObservablePoint b) + public static bool operator ==(ObservablePoint a, ObservablePoint b) { return Equals(a, b); } /// - public static bool operator !=(ObservablePoint a, ObservablePoint b) + public static bool operator !=(ObservablePoint a, ObservablePoint b) { return Equals(a, b) is not true; } #endregion } + +///// +///// 可观察地点 +///// +///// 类型 +//public class ObservablePoint +// : ObservableClass>, +// IEquatable> +//{ +// private T _x; +// public T X +// { +// get => _x; +// set => SetProperty(ref _x, value); +// } + +// private T _y; +// public T Y +// { +// get => _y; +// set => SetProperty(ref _y, value); +// } + +// public ObservablePoint() { } + +// public ObservablePoint(T x, T y) +// { +// X = x; +// Y = y; +// } + +// /// +// /// 复制一个新的对象 +// /// +// /// 新对象 +// public ObservablePoint Copy() +// { +// return new(X, Y); +// } + +// #region Create + +// public static ObservablePoint Create(Point point) +// { +// return new(point.X, point.Y); +// } + +// #endregion + +// #region Other + +// /// +// public override int GetHashCode() +// { +// return HashCode.Combine(X, Y); +// } + +// /// +// public override bool Equals(object? obj) +// { +// return obj is ObservablePoint temp +// && EqualityComparer.Default.Equals(X, temp.X) +// && EqualityComparer.Default.Equals(Y, temp.Y); +// } + +// /// +// public bool Equals(ObservablePoint? other) +// { +// return Equals(obj: other); +// } + +// /// +// public static bool operator ==(ObservablePoint a, ObservablePoint b) +// { +// return Equals(a, b); +// } + +// /// +// public static bool operator !=(ObservablePoint a, ObservablePoint b) +// { +// return Equals(a, b) is not true; +// } + +// #endregion +//} diff --git a/VPet.Solution/Utils/ObservableRect.cs b/VPet.Solution/Utils/ObservableRect.cs index 49924a7..da0d563 100644 --- a/VPet.Solution/Utils/ObservableRect.cs +++ b/VPet.Solution/Utils/ObservableRect.cs @@ -1,30 +1,30 @@ namespace HKW.HKWUtils; -public class ObservableRect : ObservableClass>, IEquatable> +public class ObservableRect : ObservableClass, IEquatable { - private T _x; - public T X + private double _x; + public double X { get => _x; set => SetProperty(ref _x, value); } - private T _y; - public T Y + private double _y; + public double Y { get => _y; set => SetProperty(ref _y, value); } - private T _width; - public T Width + private double _width; + public double Width { get => _width; set => SetProperty(ref _width, value); } - private T _heigth; - public T Height + private double _heigth; + public double Height { get => _heigth; set => SetProperty(ref _heigth, value); @@ -32,7 +32,7 @@ public class ObservableRect : ObservableClass>, IEquatable< public ObservableRect() { } - public ObservableRect(T x, T y, T width, T hetght) + public ObservableRect(double x, double y, double width, double hetght) { X = x; Y = y; @@ -44,7 +44,7 @@ public class ObservableRect : ObservableClass>, IEquatable< /// 复制一个新的对象 /// /// 新对象 - public ObservableRect Copy() + public ObservableRect Copy() { return new(X, Y, Width, Height); } @@ -60,27 +60,27 @@ public class ObservableRect : ObservableClass>, IEquatable< /// public override bool Equals(object? obj) { - return obj is ObservableRect temp - && EqualityComparer.Default.Equals(X, temp.X) - && EqualityComparer.Default.Equals(Y, temp.Y) - && EqualityComparer.Default.Equals(Width, temp.Width) - && EqualityComparer.Default.Equals(Height, temp.Height); + return obj is ObservableRect temp + && EqualityComparer.Default.Equals(X, temp.X) + && EqualityComparer.Default.Equals(Y, temp.Y) + && EqualityComparer.Default.Equals(Width, temp.Width) + && EqualityComparer.Default.Equals(Height, temp.Height); } /// - public bool Equals(ObservableRect? other) + public bool Equals(ObservableRect? other) { return Equals(obj: other); } /// - public static bool operator ==(ObservableRect a, ObservableRect b) + public static bool operator ==(ObservableRect a, ObservableRect b) { return Equals(a, b); } /// - public static bool operator !=(ObservableRect a, ObservableRect b) + public static bool operator !=(ObservableRect a, ObservableRect b) { return Equals(a, b) is not true; } diff --git a/VPet.Solution/VPet.Solution.csproj b/VPet.Solution/VPet.Solution.csproj index e0769c3..10a4148 100644 --- a/VPet.Solution/VPet.Solution.csproj +++ b/VPet.Solution/VPet.Solution.csproj @@ -75,26 +75,28 @@ Designer - + + + - - - - - - - CustomizedSettingsPage.xaml + + + + + + + CustomizedSettingPage.xaml - - DiagnosticSettingsPage.xaml + + DiagnosticSettingPage.xaml - - ModSettingsPage.xaml + + ModSettingPage.xaml - - SystemSettingsPage.xaml + + SystemSettingPage.xaml MSBuild:Compile @@ -108,19 +110,19 @@ MSBuild:Compile Designer - + Designer MSBuild:Compile - + Designer MSBuild:Compile - + Designer MSBuild:Compile - + Designer MSBuild:Compile @@ -132,14 +134,14 @@ App.xaml Code - - + + - - GraphicsSettingsPage.xaml + + GraphicsSettingPage.xaml - - InteractiveSettingsPage.xaml + + InteractiveSettingPage.xaml MainWindow.xaml @@ -185,11 +187,11 @@ NativeStyles.xaml - + Designer MSBuild:Compile - + Designer MSBuild:Compile diff --git a/VPet.Solution/ViewModels/SystemSettingsPageVM.cs b/VPet.Solution/ViewModels/CustomizedSettingPageVM.cs similarity index 79% rename from VPet.Solution/ViewModels/SystemSettingsPageVM.cs rename to VPet.Solution/ViewModels/CustomizedSettingPageVM.cs index 842b6d0..b289aa8 100644 --- a/VPet.Solution/ViewModels/SystemSettingsPageVM.cs +++ b/VPet.Solution/ViewModels/CustomizedSettingPageVM.cs @@ -6,4 +6,4 @@ using System.Threading.Tasks; namespace VPet.Solution.ViewModels; -public class SystemSettingsPageVM { } +public class CustomizedSettingPageVM { } diff --git a/VPet.Solution/ViewModels/CustomizedSettingsPageVM.cs b/VPet.Solution/ViewModels/DiagnosticSettingPageVM.cs similarity index 78% rename from VPet.Solution/ViewModels/CustomizedSettingsPageVM.cs rename to VPet.Solution/ViewModels/DiagnosticSettingPageVM.cs index 965acfb..30d8ed6 100644 --- a/VPet.Solution/ViewModels/CustomizedSettingsPageVM.cs +++ b/VPet.Solution/ViewModels/DiagnosticSettingPageVM.cs @@ -6,4 +6,4 @@ using System.Threading.Tasks; namespace VPet.Solution.ViewModels; -public class CustomizedSettingsPageVM { } +public class DiagnosticSettingPageVM { } diff --git a/VPet.Solution/ViewModels/DiagnosticSettingsPageVM.cs b/VPet.Solution/ViewModels/DiagnosticSettingsPageVM.cs deleted file mode 100644 index 683ebe5..0000000 --- a/VPet.Solution/ViewModels/DiagnosticSettingsPageVM.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace VPet.Solution.ViewModels; - -public class DiagnosticSettingsPageVM { } diff --git a/VPet.Solution/ViewModels/GraphicsSettingPageVM.cs b/VPet.Solution/ViewModels/GraphicsSettingPageVM.cs new file mode 100644 index 0000000..8c9537b --- /dev/null +++ b/VPet.Solution/ViewModels/GraphicsSettingPageVM.cs @@ -0,0 +1,32 @@ +using HKW.HKWUtils.Observable; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VPet.Solution.Models; + +namespace VPet.Solution.ViewModels; + +public class GraphicsSettingPageVM : ObservableClass +{ + private GraphicsSettingModel _graphicsSetting; + public GraphicsSettingModel GraphicsSetting + { + get => _graphicsSetting; + set => SetProperty(ref _graphicsSetting, value); + } + + public GraphicsSettingPageVM() + { + MainWindowVM.Current.PropertyChangedX += Current_PropertyChangedX; + } + + private void Current_PropertyChangedX(MainWindowVM sender, PropertyChangedXEventArgs e) + { + if (e.PropertyName == nameof(MainWindowVM.CurrentSetting)) + { + GraphicsSetting = sender.CurrentSetting.GraphicsSetting; + } + } +} diff --git a/VPet.Solution/ViewModels/GraphicsSettingsPageVM.cs b/VPet.Solution/ViewModels/GraphicsSettingsPageVM.cs deleted file mode 100644 index 5164388..0000000 --- a/VPet.Solution/ViewModels/GraphicsSettingsPageVM.cs +++ /dev/null @@ -1,19 +0,0 @@ -using HKW.HKWUtils.Observable; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using VPet.Solution.Models; - -namespace VPet.Solution.ViewModels; - -public class GraphicsSettingsPageVM : ObservableClass -{ - private GraphicsSettingsModel _graphicsSettings; - public GraphicsSettingsModel GraphicsSettings - { - get => _graphicsSettings; - set => SetProperty(ref _graphicsSettings, value); - } -} diff --git a/VPet.Solution/ViewModels/InteractiveSettingPageVM.cs b/VPet.Solution/ViewModels/InteractiveSettingPageVM.cs new file mode 100644 index 0000000..31f5092 --- /dev/null +++ b/VPet.Solution/ViewModels/InteractiveSettingPageVM.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VPet.Solution.Models; + +namespace VPet.Solution.ViewModels; + +public class InteractiveSettingPageVM : ObservableClass +{ + private InteractiveSettingModel _systemSetting; + public InteractiveSettingModel InteractiveSetting + { + get => _systemSetting; + set => SetProperty(ref _systemSetting, value); + } + + public InteractiveSettingPageVM() + { + MainWindowVM.Current.PropertyChangedX += Current_PropertyChangedX; + } + + private void Current_PropertyChangedX(MainWindowVM sender, PropertyChangedXEventArgs e) + { + if (e.PropertyName == nameof(MainWindowVM.CurrentSetting)) + { + InteractiveSetting = sender.CurrentSetting.InteractiveSetting; + } + } +} diff --git a/VPet.Solution/ViewModels/InteractiveSettingsPageVM.cs b/VPet.Solution/ViewModels/InteractiveSettingsPageVM.cs deleted file mode 100644 index 1b7fbb6..0000000 --- a/VPet.Solution/ViewModels/InteractiveSettingsPageVM.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace VPet.Solution.ViewModels; - -public class InteractiveSettingsPageVM { } diff --git a/VPet.Solution/ViewModels/MainWindowVM.cs b/VPet.Solution/ViewModels/MainWindowVM.cs index c8893a1..9a71c46 100644 --- a/VPet.Solution/ViewModels/MainWindowVM.cs +++ b/VPet.Solution/ViewModels/MainWindowVM.cs @@ -1,22 +1,89 @@ using HKW.HKWUtils.Observable; +using LinePutScript; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using VPet.Solution.Models; using VPet_Simulator.Windows.Interface; namespace VPet.Solution.ViewModels; public class MainWindowVM : ObservableClass { - public MainWindowVM() { } + public static MainWindowVM Current { get; private set; } - public static void LoadSettings(string path) + private SettingModel _currentSettings; + public SettingModel CurrentSetting { - foreach (var file in Directory.EnumerateFiles(path)) + get => _currentSettings; + set => SetProperty(ref _currentSettings, value); + } + + private readonly ObservableCollection _settings = new(); + + private IEnumerable _showSettings; + public IEnumerable ShowSettings + { + get => _showSettings; + set => SetProperty(ref _showSettings, value); + } + + private string _searchSetting; + public string SearchSetting + { + get => _searchSetting; + set => SetProperty(ref _searchSetting, value); + } + + public MainWindowVM() + { + Current = this; + ShowSettings = _settings; + + foreach (var s in LoadSettings()) + _settings.Add(s); + + PropertyChanged += MainWindowVM_PropertyChanged; + } + + private void MainWindowVM_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == nameof(SearchSetting)) { - var setting = new Setting(path); + if (string.IsNullOrWhiteSpace(SearchSetting)) + ShowSettings = _settings; + else + ShowSettings = _settings.Where( + s => s.Name.Contains(SearchSetting, StringComparison.OrdinalIgnoreCase) + ); + } + } + + public static IEnumerable LoadSettings() + { + foreach ( + var file in Directory + .EnumerateFiles(Environment.CurrentDirectory) + .Where( + (s) => + { + if (s.EndsWith(".lps") is false) + return false; + return Path.GetFileName(s).StartsWith("Setting"); + } + ) + ) + { + var setting = new Setting(File.ReadAllText(file)); + yield return new SettingModel(setting) + { + Name = Path.GetFileNameWithoutExtension(file), + FilePath = file + }; } } } diff --git a/VPet.Solution/ViewModels/ModSettingsPageVM.cs b/VPet.Solution/ViewModels/ModSettingPageVM.cs similarity index 81% rename from VPet.Solution/ViewModels/ModSettingsPageVM.cs rename to VPet.Solution/ViewModels/ModSettingPageVM.cs index bef412e..007f7c6 100644 --- a/VPet.Solution/ViewModels/ModSettingsPageVM.cs +++ b/VPet.Solution/ViewModels/ModSettingPageVM.cs @@ -6,4 +6,4 @@ using System.Threading.Tasks; namespace VPet.Solution.ViewModels; -public class ModSettingsPageVM { } +public class ModSettingPageVM { } diff --git a/VPet.Solution/ViewModels/SystemSettingPageVM.cs b/VPet.Solution/ViewModels/SystemSettingPageVM.cs new file mode 100644 index 0000000..427f061 --- /dev/null +++ b/VPet.Solution/ViewModels/SystemSettingPageVM.cs @@ -0,0 +1,32 @@ +using HKW.HKWUtils.Observable; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VPet.Solution.Models; + +namespace VPet.Solution.ViewModels; + +public class SystemSettingPageVM : ObservableClass +{ + private SystemSettingModel _systemSetting; + public SystemSettingModel SystemSetting + { + get => _systemSetting; + set => SetProperty(ref _systemSetting, value); + } + + public SystemSettingPageVM() + { + MainWindowVM.Current.PropertyChangedX += Current_PropertyChangedX; + } + + private void Current_PropertyChangedX(MainWindowVM sender, PropertyChangedXEventArgs e) + { + if (e.PropertyName == nameof(MainWindowVM.CurrentSetting)) + { + SystemSetting = sender.CurrentSetting.SystemSetting; + } + } +} diff --git a/VPet.Solution/Views/CustomizedSettingsPage.xaml b/VPet.Solution/Views/CustomizedSettingPage.xaml similarity index 94% rename from VPet.Solution/Views/CustomizedSettingsPage.xaml rename to VPet.Solution/Views/CustomizedSettingPage.xaml index b9fec7e..930e508 100644 --- a/VPet.Solution/Views/CustomizedSettingsPage.xaml +++ b/VPet.Solution/Views/CustomizedSettingPage.xaml @@ -1,5 +1,5 @@  diff --git a/VPet.Solution/Views/CustomizedSettingsPage.xaml.cs b/VPet.Solution/Views/CustomizedSettingPage.xaml.cs similarity index 86% rename from VPet.Solution/Views/CustomizedSettingsPage.xaml.cs rename to VPet.Solution/Views/CustomizedSettingPage.xaml.cs index c0ada56..d606593 100644 --- a/VPet.Solution/Views/CustomizedSettingsPage.xaml.cs +++ b/VPet.Solution/Views/CustomizedSettingPage.xaml.cs @@ -14,12 +14,13 @@ using System.Windows.Navigation; using System.Windows.Shapes; namespace VPet.Solution.Views; + /// /// CustomizedSettingsPage.xaml 的交互逻辑 /// -public partial class CustomizedSettingsPage : Page +public partial class CustomizedSettingPage : Page { - public CustomizedSettingsPage() + public CustomizedSettingPage() { InitializeComponent(); } diff --git a/VPet.Solution/Views/DiagnosticSettingsPage.xaml b/VPet.Solution/Views/DiagnosticSettingPage.xaml similarity index 97% rename from VPet.Solution/Views/DiagnosticSettingsPage.xaml rename to VPet.Solution/Views/DiagnosticSettingPage.xaml index 3add345..4ec30ec 100644 --- a/VPet.Solution/Views/DiagnosticSettingsPage.xaml +++ b/VPet.Solution/Views/DiagnosticSettingPage.xaml @@ -1,5 +1,5 @@  diff --git a/VPet.Solution/Views/DiagnosticSettingsPage.xaml.cs b/VPet.Solution/Views/DiagnosticSettingPage.xaml.cs similarity index 86% rename from VPet.Solution/Views/DiagnosticSettingsPage.xaml.cs rename to VPet.Solution/Views/DiagnosticSettingPage.xaml.cs index d07c1cb..9a21967 100644 --- a/VPet.Solution/Views/DiagnosticSettingsPage.xaml.cs +++ b/VPet.Solution/Views/DiagnosticSettingPage.xaml.cs @@ -14,12 +14,13 @@ using System.Windows.Navigation; using System.Windows.Shapes; namespace VPet.Solution.Views; + /// /// DiagnosticSettingsPage.xaml 的交互逻辑 /// -public partial class DiagnosticSettingsPage : Page +public partial class DiagnosticSettingPage : Page { - public DiagnosticSettingsPage() + public DiagnosticSettingPage() { InitializeComponent(); } diff --git a/VPet.Solution/Views/GraphicsSettingsPage.xaml b/VPet.Solution/Views/GraphicsSettingPage.xaml similarity index 92% rename from VPet.Solution/Views/GraphicsSettingsPage.xaml rename to VPet.Solution/Views/GraphicsSettingPage.xaml index cbcb91d..c976350 100644 --- a/VPet.Solution/Views/GraphicsSettingsPage.xaml +++ b/VPet.Solution/Views/GraphicsSettingPage.xaml @@ -1,5 +1,5 @@  @@ -39,14 +39,14 @@ x:Name="TopMostBox" Grid.Column="1" Content="{ll:Str '将桌宠置于顶层'}" - IsChecked="{Binding GraphicsSettings.TopMost}" + IsChecked="{Binding GraphicsSetting.TopMost}" Style="{DynamicResource Switch_BaseStyle}" ToolTip="{ll:Str '将桌宠置于顶层'}" /> @@ -88,7 +88,7 @@ x:Name="FullScreenBox" Grid.Column="1" Content="{ll:Str 支持更大缩放倍率}" - IsChecked="{Binding GraphicsSettings.IsBiggerScreen}" + IsChecked="{Binding GraphicsSetting.IsBiggerScreen}" Style="{DynamicResource Switch_BaseStyle}" ToolTip="{ll:Str 解锁缩放限制}" /> @@ -112,7 +112,7 @@ SmallChange="0.05" Style="{DynamicResource Slider_BaseStyle}" TickFrequency="0.05" - Value="{Binding GraphicsSettings.ZoomLevel}" /> + Value="{Binding GraphicsSetting.ZoomLevel}" /> + Value="{Binding GraphicsSetting.Resolution}" /> @@ -184,7 +184,7 @@ x:Name="FontBox" Grid.Column="1" IsEnabled="False" - SelectedItem="{Binding GraphicsSettings.Font}" + SelectedItem="{Binding GraphicsSetting.Font}" Style="{DynamicResource ComboBox_BaseStyle}" /> @@ -205,7 +205,7 @@ x:Name="StartPlace" Grid.Column="1" Content="{ll:Str 保存为退出位置}" - IsChecked="{Binding GraphicsSettings.StartRecordLast}" + IsChecked="{Binding GraphicsSetting.StartRecordLast}" Style="{DynamicResource Switch_BaseStyle}" ToolTip="{ll:Str 游戏退出位置为下次桌宠启动出现的位置}" /> @@ -213,14 +213,14 @@ + Value="{Binding GraphicsSetting.StartRecordPoint.X}" />