更新 VPet.Solution

This commit is contained in:
Hakoyu 2023-12-30 22:54:49 +08:00
parent 9d43fdb6c9
commit 6aac99b85f
32 changed files with 556 additions and 243 deletions

View File

@ -3,7 +3,7 @@ using System.Windows;
namespace VPet.Solution.Models; namespace VPet.Solution.Models;
public class GraphicsSettingsModel : ObservableClass<SettingsModel> public class GraphicsSettingModel : ObservableClass<SettingModel>
{ {
private double _zoomLevel = 1; private double _zoomLevel = 1;
@ -138,12 +138,12 @@ public class GraphicsSettingsModel : ObservableClass<SettingsModel>
// set => SetProperty(ref _startRecordLastPoint, value); // set => SetProperty(ref _startRecordLastPoint, value);
//} //}
private ObservablePoint<double> _startRecordPoint; private ObservablePoint _startRecordPoint;
/// <summary> /// <summary>
/// 设置中桌宠启动的位置 /// 设置中桌宠启动的位置
/// </summary> /// </summary>
public ObservablePoint<double> StartRecordPoint public ObservablePoint StartRecordPoint
{ {
get => _startRecordPoint; get => _startRecordPoint;
set => SetProperty(ref _startRecordPoint, value); set => SetProperty(ref _startRecordPoint, value);

View File

@ -1,35 +1,19 @@
using FastMember; using HKW.HKWUtils.Observable;
using HKW.HKWUtils.Observable;
using System.ComponentModel;
using System.Windows;
using VPet.Solution.Properties;
using VPet_Simulator.Core; using VPet_Simulator.Core;
using VPet_Simulator.Windows.Interface;
namespace VPet.Solution.Models; namespace VPet.Solution.Models;
public class SettingsModel : ObservableClass<SettingsModel> public class InteractiveSettingModel : ObservableClass<InteractiveSettingModel>
{ {
private GraphicsSettingsModel _graphicsSettings; private string _petName;
public GraphicsSettingsModel GraphicsSettings
{
get => _graphicsSettings;
set => SetProperty(ref _graphicsSettings, value);
}
public SettingsModel(Setting setting) /// <summary>
/// 宠物名称
/// </summary>
public string PetName
{ {
GraphicsSettings = LoadGraphicsSettings(setting); get => _petName;
} set => SetProperty(ref _petName, value);
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;
} }
private double _voiceVolume; private double _voiceVolume;
@ -43,22 +27,6 @@ public class SettingsModel : ObservableClass<SettingsModel>
set => SetProperty(ref _voiceVolume, value); set => SetProperty(ref _voiceVolume, value);
} }
/// <summary>
/// 数据收集是否被禁止(当日)
/// </summary>
public bool DiagnosisDayEnable { get; } = true;
private bool _diagnosis;
/// <summary>
/// 是否启用数据收集
/// </summary>
public bool Diagnosis
{
get => _diagnosis;
set => SetProperty(ref _diagnosis, value);
}
private GameSave.ModeType _calFunState; private GameSave.ModeType _calFunState;
/// <summary> /// <summary>
@ -70,39 +38,6 @@ public class SettingsModel : ObservableClass<SettingsModel>
set => SetProperty(ref _calFunState, value); set => SetProperty(ref _calFunState, value);
} }
private int _diagnosisInterval;
/// <summary>
/// 数据收集频率
/// </summary>
public int DiagnosisInterval
{
get => _diagnosisInterval;
set => SetProperty(ref _diagnosisInterval, value);
}
private int _autoSaveInterval;
/// <summary>
/// 自动保存频率 (min)
/// </summary>
public int AutoSaveInterval
{
get => _autoSaveInterval;
set => SetProperty(ref _autoSaveInterval, value);
}
private int _backupSaveMaxNum;
/// <summary>
/// 备份保存最大数量
/// </summary>
public int BackupSaveMaxNum
{
get => _backupSaveMaxNum;
set => SetProperty(ref _backupSaveMaxNum, value);
}
private bool _petHelper; private bool _petHelper;
/// <summary> /// <summary>

View File

@ -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<SettingModel>
{
private string _name;
/// <summary>
/// 名称
/// </summary>
public string Name
{
get => _name;
set => SetProperty(ref _name, value);
}
private string _filePath;
/// <summary>
/// 路径
/// </summary>
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;
}
}

View File

@ -0,0 +1,53 @@
namespace VPet.Solution.Models;
public class SystemSettingModel : ObservableClass<SettingModel>
{
/// <summary>
/// 数据收集是否被禁止(当日)
/// </summary>
public bool DiagnosisDayEnable { get; } = true;
private bool _diagnosis;
/// <summary>
/// 是否启用数据收集
/// </summary>
public bool Diagnosis
{
get => _diagnosis;
set => SetProperty(ref _diagnosis, value);
}
private int _diagnosisInterval;
/// <summary>
/// 数据收集频率
/// </summary>
public int DiagnosisInterval
{
get => _diagnosisInterval;
set => SetProperty(ref _diagnosisInterval, value);
}
private int _autoSaveInterval;
/// <summary>
/// 自动保存频率 (min)
/// </summary>
public int AutoSaveInterval
{
get => _autoSaveInterval;
set => SetProperty(ref _autoSaveInterval, value);
}
private int _backupSaveMaxNum;
/// <summary>
/// 备份保存最大数量
/// </summary>
public int BackupSaveMaxNum
{
get => _backupSaveMaxNum;
set => SetProperty(ref _backupSaveMaxNum, value);
}
}

View File

@ -292,7 +292,7 @@ public static class Extensions
/// </summary> /// </summary>
/// <typeparam name="T">视图模型类型</typeparam> /// <typeparam name="T">视图模型类型</typeparam>
/// <param name="window">窗口</param> /// <param name="window">窗口</param>
public static Lazy<T> SetViewModel<T>(this Window window, EventHandler? closedEvent = null) public static T SetViewModel<T>(this Window window, EventHandler? closedEvent = null)
where T : new() where T : new()
{ {
if (window.DataContext is null) if (window.DataContext is null)
@ -308,7 +308,7 @@ public static class Extensions
}; };
window.Closed += closedEvent; window.Closed += closedEvent;
} }
return new(() => (T)window.DataContext); return (T)window.DataContext;
} }
/// <summary> /// <summary>
@ -316,10 +316,10 @@ public static class Extensions
/// </summary> /// </summary>
/// <typeparam name="T">视图模型类型</typeparam> /// <typeparam name="T">视图模型类型</typeparam>
/// <param name="page">页面</param> /// <param name="page">页面</param>
public static Lazy<T> SetViewModel<T>(this Page page) public static T SetViewModel<T>(this Page page)
where T : new() where T : new()
{ {
return new(() => (T)(page.DataContext ??= new T())); return (T)(page.DataContext ??= new T());
} }
} }

View File

@ -1,22 +1,23 @@
namespace HKW.HKWUtils; using System.Diagnostics;
using System.Windows;
namespace HKW.HKWUtils;
/// <summary> /// <summary>
/// 可观察地点 /// 可观察地点
/// </summary> /// </summary>
/// <typeparam name="T">类型</typeparam> [DebuggerDisplay("X = {X}, Y = {Y}")]
public class ObservablePoint<T> public class ObservablePoint : ObservableClass<ObservablePoint>, IEquatable<ObservablePoint>
: ObservableClass<ObservablePoint<T>>,
IEquatable<ObservablePoint<T>>
{ {
private T _x; private double _x;
public T X public double X
{ {
get => _x; get => _x;
set => SetProperty(ref _x, value); set => SetProperty(ref _x, value);
} }
private T _y; private double _y;
public T Y public double Y
{ {
get => _y; get => _y;
set => SetProperty(ref _y, value); set => SetProperty(ref _y, value);
@ -24,17 +25,23 @@ public class ObservablePoint<T>
public ObservablePoint() { } public ObservablePoint() { }
public ObservablePoint(T x, T y) public ObservablePoint(double x, double y)
{ {
X = x; X = x;
Y = y; Y = y;
} }
public ObservablePoint(Point point)
{
X = point.X;
Y = point.Y;
}
/// <summary> /// <summary>
/// 复制一个新的对象 /// 复制一个新的对象
/// </summary> /// </summary>
/// <returns>新对象</returns> /// <returns>新对象</returns>
public ObservablePoint<T> Copy() public ObservablePoint Copy()
{ {
return new(X, Y); return new(X, Y);
} }
@ -50,28 +57,113 @@ public class ObservablePoint<T>
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object? obj) public override bool Equals(object? obj)
{ {
return obj is ObservablePoint<T> temp return obj is ObservablePoint temp
&& EqualityComparer<T>.Default.Equals(X, temp.X) && EqualityComparer<double>.Default.Equals(X, temp.X)
&& EqualityComparer<T>.Default.Equals(Y, temp.Y); && EqualityComparer<double>.Default.Equals(Y, temp.Y);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(ObservablePoint<T>? other) public bool Equals(ObservablePoint? other)
{ {
return Equals(obj: other); return Equals(obj: other);
} }
/// <inheritdoc/> /// <inheritdoc/>
public static bool operator ==(ObservablePoint<T> a, ObservablePoint<T> b) public static bool operator ==(ObservablePoint a, ObservablePoint b)
{ {
return Equals(a, b); return Equals(a, b);
} }
/// <inheritdoc/> /// <inheritdoc/>
public static bool operator !=(ObservablePoint<T> a, ObservablePoint<T> b) public static bool operator !=(ObservablePoint a, ObservablePoint b)
{ {
return Equals(a, b) is not true; return Equals(a, b) is not true;
} }
#endregion #endregion
} }
///// <summary>
///// 可观察地点
///// </summary>
///// <typeparam name="T">类型</typeparam>
//public class ObservablePoint<T>
// : ObservableClass<ObservablePoint<T>>,
// IEquatable<ObservablePoint<T>>
//{
// 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;
// }
// /// <summary>
// /// 复制一个新的对象
// /// </summary>
// /// <returns>新对象</returns>
// public ObservablePoint<T> Copy()
// {
// return new(X, Y);
// }
// #region Create
// public static ObservablePoint<double> Create(Point point)
// {
// return new(point.X, point.Y);
// }
// #endregion
// #region Other
// /// <inheritdoc/>
// public override int GetHashCode()
// {
// return HashCode.Combine(X, Y);
// }
// /// <inheritdoc/>
// public override bool Equals(object? obj)
// {
// return obj is ObservablePoint<T> temp
// && EqualityComparer<T>.Default.Equals(X, temp.X)
// && EqualityComparer<T>.Default.Equals(Y, temp.Y);
// }
// /// <inheritdoc/>
// public bool Equals(ObservablePoint<T>? other)
// {
// return Equals(obj: other);
// }
// /// <inheritdoc/>
// public static bool operator ==(ObservablePoint<T> a, ObservablePoint<T> b)
// {
// return Equals(a, b);
// }
// /// <inheritdoc/>
// public static bool operator !=(ObservablePoint<T> a, ObservablePoint<T> b)
// {
// return Equals(a, b) is not true;
// }
// #endregion
//}

View File

@ -1,30 +1,30 @@
namespace HKW.HKWUtils; namespace HKW.HKWUtils;
public class ObservableRect<T> : ObservableClass<ObservableRect<T>>, IEquatable<ObservableRect<T>> public class ObservableRect : ObservableClass<ObservableRect>, IEquatable<ObservableRect>
{ {
private T _x; private double _x;
public T X public double X
{ {
get => _x; get => _x;
set => SetProperty(ref _x, value); set => SetProperty(ref _x, value);
} }
private T _y; private double _y;
public T Y public double Y
{ {
get => _y; get => _y;
set => SetProperty(ref _y, value); set => SetProperty(ref _y, value);
} }
private T _width; private double _width;
public T Width public double Width
{ {
get => _width; get => _width;
set => SetProperty(ref _width, value); set => SetProperty(ref _width, value);
} }
private T _heigth; private double _heigth;
public T Height public double Height
{ {
get => _heigth; get => _heigth;
set => SetProperty(ref _heigth, value); set => SetProperty(ref _heigth, value);
@ -32,7 +32,7 @@ public class ObservableRect<T> : ObservableClass<ObservableRect<T>>, IEquatable<
public ObservableRect() { } public ObservableRect() { }
public ObservableRect(T x, T y, T width, T hetght) public ObservableRect(double x, double y, double width, double hetght)
{ {
X = x; X = x;
Y = y; Y = y;
@ -44,7 +44,7 @@ public class ObservableRect<T> : ObservableClass<ObservableRect<T>>, IEquatable<
/// 复制一个新的对象 /// 复制一个新的对象
/// </summary> /// </summary>
/// <returns>新对象</returns> /// <returns>新对象</returns>
public ObservableRect<T> Copy() public ObservableRect Copy()
{ {
return new(X, Y, Width, Height); return new(X, Y, Width, Height);
} }
@ -60,27 +60,27 @@ public class ObservableRect<T> : ObservableClass<ObservableRect<T>>, IEquatable<
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object? obj) public override bool Equals(object? obj)
{ {
return obj is ObservableRect<T> temp return obj is ObservableRect temp
&& EqualityComparer<T>.Default.Equals(X, temp.X) && EqualityComparer<double>.Default.Equals(X, temp.X)
&& EqualityComparer<T>.Default.Equals(Y, temp.Y) && EqualityComparer<double>.Default.Equals(Y, temp.Y)
&& EqualityComparer<T>.Default.Equals(Width, temp.Width) && EqualityComparer<double>.Default.Equals(Width, temp.Width)
&& EqualityComparer<T>.Default.Equals(Height, temp.Height); && EqualityComparer<double>.Default.Equals(Height, temp.Height);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(ObservableRect<T>? other) public bool Equals(ObservableRect? other)
{ {
return Equals(obj: other); return Equals(obj: other);
} }
/// <inheritdoc/> /// <inheritdoc/>
public static bool operator ==(ObservableRect<T> a, ObservableRect<T> b) public static bool operator ==(ObservableRect a, ObservableRect b)
{ {
return Equals(a, b); return Equals(a, b);
} }
/// <inheritdoc/> /// <inheritdoc/>
public static bool operator !=(ObservableRect<T> a, ObservableRect<T> b) public static bool operator !=(ObservableRect a, ObservableRect b)
{ {
return Equals(a, b) is not true; return Equals(a, b) is not true;
} }

View File

@ -75,26 +75,28 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="Converters\BoolInverter.cs" /> <Compile Include="Converters\BoolInverter.cs" />
<Compile Include="Models\GraphicsSettingsModel.cs" /> <Compile Include="Models\GraphicsSettingModel.cs" />
<Compile Include="Models\InteractiveSettingModel.cs" />
<Compile Include="Models\SystemSettingModel.cs" />
<Compile Include="Utils\ClearFocus.cs" /> <Compile Include="Utils\ClearFocus.cs" />
<Compile Include="Utils\ElementHelper.cs" /> <Compile Include="Utils\ElementHelper.cs" />
<Compile Include="Utils\FindTopParent.cs" /> <Compile Include="Utils\FindTopParent.cs" />
<Compile Include="ViewModels\CustomizedSettingsPageVM.cs" /> <Compile Include="ViewModels\CustomizedSettingPageVM.cs" />
<Compile Include="ViewModels\DiagnosticSettingsPageVM.cs" /> <Compile Include="ViewModels\DiagnosticSettingPageVM.cs" />
<Compile Include="ViewModels\ModSettingsPageVM.cs" /> <Compile Include="ViewModels\ModSettingPageVM.cs" />
<Compile Include="Models\SettingsModel.cs" /> <Compile Include="Models\SettingModel.cs" />
<Compile Include="ViewModels\SystemSettingsPageVM.cs" /> <Compile Include="ViewModels\SystemSettingPageVM.cs" />
<Compile Include="Views\CustomizedSettingsPage.xaml.cs"> <Compile Include="Views\CustomizedSettingPage.xaml.cs">
<DependentUpon>CustomizedSettingsPage.xaml</DependentUpon> <DependentUpon>CustomizedSettingPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\DiagnosticSettingsPage.xaml.cs"> <Compile Include="Views\DiagnosticSettingPage.xaml.cs">
<DependentUpon>DiagnosticSettingsPage.xaml</DependentUpon> <DependentUpon>DiagnosticSettingPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\ModSettingsPage.xaml.cs"> <Compile Include="Views\ModSettingPage.xaml.cs">
<DependentUpon>ModSettingsPage.xaml</DependentUpon> <DependentUpon>ModSettingPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\SystemSettingsPage.xaml.cs"> <Compile Include="Views\SystemSettingPage.xaml.cs">
<DependentUpon>SystemSettingsPage.xaml</DependentUpon> <DependentUpon>SystemSettingPage.xaml</DependentUpon>
</Compile> </Compile>
<Page Include="Converters.xaml"> <Page Include="Converters.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@ -108,19 +110,19 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="Views\CustomizedSettingsPage.xaml"> <Page Include="Views\CustomizedSettingPage.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\DiagnosticSettingsPage.xaml"> <Page Include="Views\DiagnosticSettingPage.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\GraphicsSettingsPage.xaml"> <Page Include="Views\GraphicsSettingPage.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\InteractiveSettingsPage.xaml"> <Page Include="Views\InteractiveSettingPage.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
@ -132,14 +134,14 @@
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="ViewModels\GraphicsSettingsPageVM.cs" /> <Compile Include="ViewModels\GraphicsSettingPageVM.cs" />
<Compile Include="ViewModels\InteractiveSettingsPageVM.cs" /> <Compile Include="ViewModels\InteractiveSettingPageVM.cs" />
<Compile Include="ViewModels\MainWindowVM.cs" /> <Compile Include="ViewModels\MainWindowVM.cs" />
<Compile Include="Views\GraphicsSettingsPage.xaml.cs"> <Compile Include="Views\GraphicsSettingPage.xaml.cs">
<DependentUpon>GraphicsSettingsPage.xaml</DependentUpon> <DependentUpon>GraphicsSettingPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\InteractiveSettingsPage.xaml.cs"> <Compile Include="Views\InteractiveSettingPage.xaml.cs">
<DependentUpon>InteractiveSettingsPage.xaml</DependentUpon> <DependentUpon>InteractiveSettingPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\MainWindow.xaml.cs"> <Compile Include="Views\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>MainWindow.xaml</DependentUpon>
@ -185,11 +187,11 @@
<Compile Include="NativeStyles.xaml.cs"> <Compile Include="NativeStyles.xaml.cs">
<DependentUpon>NativeStyles.xaml</DependentUpon> <DependentUpon>NativeStyles.xaml</DependentUpon>
</Compile> </Compile>
<Page Include="Views\ModSettingsPage.xaml"> <Page Include="Views\ModSettingPage.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\SystemSettingsPage.xaml"> <Page Include="Views\SystemSettingPage.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>

View File

@ -6,4 +6,4 @@ using System.Threading.Tasks;
namespace VPet.Solution.ViewModels; namespace VPet.Solution.ViewModels;
public class SystemSettingsPageVM { } public class CustomizedSettingPageVM { }

View File

@ -6,4 +6,4 @@ using System.Threading.Tasks;
namespace VPet.Solution.ViewModels; namespace VPet.Solution.ViewModels;
public class CustomizedSettingsPageVM { } public class DiagnosticSettingPageVM { }

View File

@ -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 { }

View File

@ -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<GraphicsSettingPageVM>
{
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;
}
}
}

View File

@ -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<GraphicsSettingsPageVM>
{
private GraphicsSettingsModel _graphicsSettings;
public GraphicsSettingsModel GraphicsSettings
{
get => _graphicsSettings;
set => SetProperty(ref _graphicsSettings, value);
}
}

View File

@ -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<InteractiveSettingPageVM>
{
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;
}
}
}

View File

@ -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 { }

View File

@ -1,22 +1,89 @@
using HKW.HKWUtils.Observable; using HKW.HKWUtils.Observable;
using LinePutScript;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using VPet.Solution.Models;
using VPet_Simulator.Windows.Interface; using VPet_Simulator.Windows.Interface;
namespace VPet.Solution.ViewModels; namespace VPet.Solution.ViewModels;
public class MainWindowVM : ObservableClass<MainWindowVM> public class MainWindowVM : ObservableClass<MainWindowVM>
{ {
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<SettingModel> _settings = new();
private IEnumerable<SettingModel> _showSettings;
public IEnumerable<SettingModel> ShowSettings
{ {
var setting = new Setting(path); 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))
{
if (string.IsNullOrWhiteSpace(SearchSetting))
ShowSettings = _settings;
else
ShowSettings = _settings.Where(
s => s.Name.Contains(SearchSetting, StringComparison.OrdinalIgnoreCase)
);
}
}
public static IEnumerable<SettingModel> 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
};
} }
} }
} }

View File

@ -6,4 +6,4 @@ using System.Threading.Tasks;
namespace VPet.Solution.ViewModels; namespace VPet.Solution.ViewModels;
public class ModSettingsPageVM { } public class ModSettingPageVM { }

View File

@ -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<SystemSettingPageVM>
{
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;
}
}
}

View File

@ -1,5 +1,5 @@
<Page <Page
x:Class="VPet.Solution.Views.CustomizedSettingsPage" x:Class="VPet.Solution.Views.CustomizedSettingPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@ -9,7 +9,7 @@
xmlns:pu="https://opensource.panuon.com/wpf-ui" xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels" xmlns:vm="clr-namespace:VPet.Solution.ViewModels"
Title="CustomizedSettingsPage" Title="CustomizedSettingsPage"
d:DataContext="{d:DesignInstance Type=vm:CustomizedSettingsPageVM}" d:DataContext="{d:DesignInstance Type=vm:CustomizedSettingPageVM}"
d:DesignHeight="450" d:DesignHeight="450"
d:DesignWidth="800" d:DesignWidth="800"
mc:Ignorable="d"> mc:Ignorable="d">

View File

@ -14,12 +14,13 @@ using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
namespace VPet.Solution.Views; namespace VPet.Solution.Views;
/// <summary> /// <summary>
/// CustomizedSettingsPage.xaml 的交互逻辑 /// CustomizedSettingsPage.xaml 的交互逻辑
/// </summary> /// </summary>
public partial class CustomizedSettingsPage : Page public partial class CustomizedSettingPage : Page
{ {
public CustomizedSettingsPage() public CustomizedSettingPage()
{ {
InitializeComponent(); InitializeComponent();
} }

View File

@ -1,5 +1,5 @@
<Page <Page
x:Class="VPet.Solution.Views.DiagnosticSettingsPage" x:Class="VPet.Solution.Views.DiagnosticSettingPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@ -9,7 +9,7 @@
xmlns:pu="https://opensource.panuon.com/wpf-ui" xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels" xmlns:vm="clr-namespace:VPet.Solution.ViewModels"
Title="DiagnosticSettingsPage" Title="DiagnosticSettingsPage"
d:DataContext="{d:DesignInstance Type=vm:DiagnosticSettingsPageVM}" d:DataContext="{d:DesignInstance Type=vm:DiagnosticSettingPageVM}"
d:DesignHeight="450" d:DesignHeight="450"
d:DesignWidth="800" d:DesignWidth="800"
mc:Ignorable="d"> mc:Ignorable="d">

View File

@ -14,12 +14,13 @@ using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
namespace VPet.Solution.Views; namespace VPet.Solution.Views;
/// <summary> /// <summary>
/// DiagnosticSettingsPage.xaml 的交互逻辑 /// DiagnosticSettingsPage.xaml 的交互逻辑
/// </summary> /// </summary>
public partial class DiagnosticSettingsPage : Page public partial class DiagnosticSettingPage : Page
{ {
public DiagnosticSettingsPage() public DiagnosticSettingPage()
{ {
InitializeComponent(); InitializeComponent();
} }

View File

@ -1,5 +1,5 @@
<Page <Page
x:Class="VPet.Solution.Views.GraphicsSettingsPage" x:Class="VPet.Solution.Views.GraphicsSettingPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@ -10,7 +10,7 @@
xmlns:pu="https://opensource.panuon.com/wpf-ui" xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels" xmlns:vm="clr-namespace:VPet.Solution.ViewModels"
Title="GraphicsSettingsPage" Title="GraphicsSettingsPage"
d:DataContext="{d:DesignInstance Type=vm:GraphicsSettingsPageVM}" d:DataContext="{d:DesignInstance Type=vm:GraphicsSettingPageVM}"
d:DesignHeight="450" d:DesignHeight="450"
d:DesignWidth="800" d:DesignWidth="800"
mc:Ignorable="d"> mc:Ignorable="d">
@ -39,14 +39,14 @@
x:Name="TopMostBox" x:Name="TopMostBox"
Grid.Column="1" Grid.Column="1"
Content="{ll:Str '将桌宠置于顶层'}" Content="{ll:Str '将桌宠置于顶层'}"
IsChecked="{Binding GraphicsSettings.TopMost}" IsChecked="{Binding GraphicsSetting.TopMost}"
Style="{DynamicResource Switch_BaseStyle}" Style="{DynamicResource Switch_BaseStyle}"
ToolTip="{ll:Str '将桌宠置于顶层'}" /> ToolTip="{ll:Str '将桌宠置于顶层'}" />
<pu:Switch <pu:Switch
x:Name="HitThroughBox" x:Name="HitThroughBox"
Grid.Column="2" Grid.Column="2"
Content="{ll:Str '鼠标穿透'}" Content="{ll:Str '鼠标穿透'}"
IsChecked="{Binding GraphicsSettings.HitThrough}" IsChecked="{Binding GraphicsSetting.HitThrough}"
Style="{DynamicResource Switch_BaseStyle}" Style="{DynamicResource Switch_BaseStyle}"
ToolTip="{ll:Str '鼠标将会穿过桌宠到下方内容,不打扰操作\&#13;该选项'}" /> ToolTip="{ll:Str '鼠标将会穿过桌宠到下方内容,不打扰操作\&#13;该选项'}" />
<pu:Switch <pu:Switch
@ -71,7 +71,7 @@
<ComboBox <ComboBox
x:Name="LanguageBox" x:Name="LanguageBox"
Grid.Column="1" Grid.Column="1"
SelectedItem="{Binding GraphicsSettings.Language}" SelectedItem="{Binding GraphicsSetting.Language}"
Style="{DynamicResource ComboBox_BaseStyle}" /> Style="{DynamicResource ComboBox_BaseStyle}" />
</Grid> </Grid>
<Grid MinHeight="40"> <Grid MinHeight="40">
@ -88,7 +88,7 @@
x:Name="FullScreenBox" x:Name="FullScreenBox"
Grid.Column="1" Grid.Column="1"
Content="{ll:Str 支持更大缩放倍率}" Content="{ll:Str 支持更大缩放倍率}"
IsChecked="{Binding GraphicsSettings.IsBiggerScreen}" IsChecked="{Binding GraphicsSetting.IsBiggerScreen}"
Style="{DynamicResource Switch_BaseStyle}" Style="{DynamicResource Switch_BaseStyle}"
ToolTip="{ll:Str 解锁缩放限制}" /> ToolTip="{ll:Str 解锁缩放限制}" />
</Grid> </Grid>
@ -112,7 +112,7 @@
SmallChange="0.05" SmallChange="0.05"
Style="{DynamicResource Slider_BaseStyle}" Style="{DynamicResource Slider_BaseStyle}"
TickFrequency="0.05" TickFrequency="0.05"
Value="{Binding GraphicsSettings.ZoomLevel}" /> Value="{Binding GraphicsSetting.ZoomLevel}" />
<pu:NumberInput <pu:NumberInput
Grid.Column="2" Grid.Column="2"
Foreground="{DynamicResource DARKPrimaryDarker}" Foreground="{DynamicResource DARKPrimaryDarker}"
@ -143,7 +143,7 @@
Style="{DynamicResource Slider_BaseStyle}" Style="{DynamicResource Slider_BaseStyle}"
TickFrequency="10" TickFrequency="10"
ToolTip="{ll:Str '桌宠图形渲染的分辨率,越高图形越清晰\&#13;但是高分辨率会占用更多内存\&#13;重启后生效'}" ToolTip="{ll:Str '桌宠图形渲染的分辨率,越高图形越清晰\&#13;但是高分辨率会占用更多内存\&#13;重启后生效'}"
Value="{Binding GraphicsSettings.Resolution}" /> Value="{Binding GraphicsSetting.Resolution}" />
<pu:NumberInput <pu:NumberInput
Grid.Column="2" Grid.Column="2"
Interval="10" Interval="10"
@ -167,7 +167,7 @@
x:Name="ThemeBox" x:Name="ThemeBox"
Grid.Column="1" Grid.Column="1"
IsEnabled="False" IsEnabled="False"
SelectedItem="{Binding GraphicsSettings.Theme}" SelectedItem="{Binding GraphicsSetting.Theme}"
Style="{DynamicResource ComboBox_BaseStyle}" /> Style="{DynamicResource ComboBox_BaseStyle}" />
</Grid> </Grid>
<Grid MinHeight="40"> <Grid MinHeight="40">
@ -184,7 +184,7 @@
x:Name="FontBox" x:Name="FontBox"
Grid.Column="1" Grid.Column="1"
IsEnabled="False" IsEnabled="False"
SelectedItem="{Binding GraphicsSettings.Font}" SelectedItem="{Binding GraphicsSetting.Font}"
Style="{DynamicResource ComboBox_BaseStyle}" /> Style="{DynamicResource ComboBox_BaseStyle}" />
</Grid> </Grid>
<Grid MinHeight="40"> <Grid MinHeight="40">
@ -205,7 +205,7 @@
x:Name="StartPlace" x:Name="StartPlace"
Grid.Column="1" Grid.Column="1"
Content="{ll:Str 保存为退出位置}" Content="{ll:Str 保存为退出位置}"
IsChecked="{Binding GraphicsSettings.StartRecordLast}" IsChecked="{Binding GraphicsSetting.StartRecordLast}"
Style="{DynamicResource Switch_BaseStyle}" Style="{DynamicResource Switch_BaseStyle}"
ToolTip="{ll:Str 游戏退出位置为下次桌宠启动出现的位置}" /> ToolTip="{ll:Str 游戏退出位置为下次桌宠启动出现的位置}" />
<DockPanel Grid.Column="2"> <DockPanel Grid.Column="2">
@ -213,14 +213,14 @@
<pu:NumberInput <pu:NumberInput
x:Name="TextBoxStartUpX" x:Name="TextBoxStartUpX"
Style="{DynamicResource NumberInput_BaseStyle}" Style="{DynamicResource NumberInput_BaseStyle}"
Value="{Binding GraphicsSettings.StartRecordPoint.X}" /> Value="{Binding GraphicsSetting.StartRecordPoint.X}" />
</DockPanel> </DockPanel>
<DockPanel Grid.Column="3"> <DockPanel Grid.Column="3">
<Label Content="{ll:Str Y轴}" Style="{DynamicResource Label_BaseStyle}" /> <Label Content="{ll:Str Y轴}" Style="{DynamicResource Label_BaseStyle}" />
<pu:NumberInput <pu:NumberInput
x:Name="TextBoxStartUpY" x:Name="TextBoxStartUpY"
Style="{DynamicResource NumberInput_BaseStyle}" Style="{DynamicResource NumberInput_BaseStyle}"
Value="{Binding GraphicsSettings.StartRecordPoint.Y}" /> Value="{Binding GraphicsSetting.StartRecordPoint.Y}" />
</DockPanel> </DockPanel>
<Button <Button
x:Name="BtnStartUpGet" x:Name="BtnStartUpGet"
@ -263,14 +263,14 @@
x:Name="StartUpBox" x:Name="StartUpBox"
Grid.Column="1" Grid.Column="1"
Content="{ll:Str 开机启动}" Content="{ll:Str 开机启动}"
IsChecked="{Binding GraphicsSettings.StartUPBoot}" IsChecked="{Binding GraphicsSetting.StartUPBoot}"
Style="{DynamicResource Switch_BaseStyle}" Style="{DynamicResource Switch_BaseStyle}"
ToolTip="{ll:Str '该游戏随着开机启动该程序\&#13;如需卸载游戏\&#13;请关闭该选项'}" /> ToolTip="{ll:Str '该游戏随着开机启动该程序\&#13;如需卸载游戏\&#13;请关闭该选项'}" />
<pu:Switch <pu:Switch
x:Name="StartUpSteamBox" x:Name="StartUpSteamBox"
Grid.Column="2" Grid.Column="2"
Content="{ll:Str 从Steam启动}" Content="{ll:Str 从Steam启动}"
IsChecked="{Binding GraphicsSettings.StartUPBootSteam}" IsChecked="{Binding GraphicsSetting.StartUPBootSteam}"
Style="{DynamicResource Switch_BaseStyle}" Style="{DynamicResource Switch_BaseStyle}"
ToolTip="{ll:Str '从Steam启动该游戏, 统计时长不能停'}" /> ToolTip="{ll:Str '从Steam启动该游戏, 统计时长不能停'}" />
</Grid> </Grid>
@ -317,7 +317,7 @@
x:Name="SwitchHideFromTaskControl" x:Name="SwitchHideFromTaskControl"
Grid.Column="1" Grid.Column="1"
Content="{ll:Str '在任务切换器中隐藏窗口'}" Content="{ll:Str '在任务切换器中隐藏窗口'}"
IsChecked="{Binding GraphicsSettings.HideFromTaskControl}" IsChecked="{Binding GraphicsSetting.HideFromTaskControl}"
Style="{DynamicResource Switch_BaseStyle}" Style="{DynamicResource Switch_BaseStyle}"
ToolTip="{ll:Str '在Alt+Tab中隐藏'}" /> ToolTip="{ll:Str '在Alt+Tab中隐藏'}" />
</Grid> </Grid>

View File

@ -20,12 +20,13 @@ namespace VPet.Solution.Views;
/// <summary> /// <summary>
/// GraphicsSettingsPage.xaml 的交互逻辑 /// GraphicsSettingsPage.xaml 的交互逻辑
/// </summary> /// </summary>
public partial class GraphicsSettingsPage : Page public partial class GraphicsSettingPage : Page
{ {
public GraphicsSettingsPageVM ViewModel => this.SetViewModel<GraphicsSettingsPageVM>().Value; public GraphicsSettingPageVM ViewModel => (GraphicsSettingPageVM)DataContext;
public GraphicsSettingsPage() public GraphicsSettingPage()
{ {
InitializeComponent(); InitializeComponent();
this.SetViewModel<GraphicsSettingPageVM>();
} }
} }

View File

@ -1,5 +1,5 @@
<Page <Page
x:Class="VPet.Solution.Views.InteractiveSettingsPage" x:Class="VPet.Solution.Views.InteractiveSettingPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@ -10,7 +10,7 @@
xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels" xmlns:vm="clr-namespace:VPet.Solution.ViewModels"
Title="InteractiveSettingsPage" Title="InteractiveSettingsPage"
d:DataContext="{d:DesignInstance Type=vm:InteractiveSettingsPageVM}" d:DataContext="{d:DesignInstance Type=vm:InteractiveSettingPageVM}"
d:DesignHeight="450" d:DesignHeight="450"
d:DesignWidth="800" d:DesignWidth="800"
mc:Ignorable="d"> mc:Ignorable="d">
@ -33,8 +33,8 @@
<TextBox <TextBox
x:Name="TextBoxPetName" x:Name="TextBoxPetName"
Grid.Column="1" Grid.Column="1"
d:TextChanged="TextBoxPetName_TextChanged" Style="{DynamicResource StandardTextBoxStyle}"
Style="{DynamicResource StandardTextBoxStyle}" /> Text="{Binding InteractiveSetting.PetName}" />
</Grid> </Grid>
<Grid MinHeight="40"> <Grid MinHeight="40">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@ -46,18 +46,17 @@
<pu:Switch <pu:Switch
x:Name="Switch_EnablePetState" x:Name="Switch_EnablePetState"
Grid.Column="1" Grid.Column="1"
d:Checked="CalFunctionBox_Checked"
d:Unchecked="CalFunctionBox_Checked"
Content="{ll:Str '启用桌宠状态'}" Content="{ll:Str '启用桌宠状态'}"
IsChecked="{Binding InteractiveSetting.CalFunState}"
Style="{DynamicResource Switch_BaseStyle}" Style="{DynamicResource Switch_BaseStyle}"
ToolTip="{ll:Str '启用数据计算,桌宠会有状态变化,需要按时投喂等.\&#13;如果嫌麻烦可以关掉'}" /> ToolTip="{ll:Str '启用数据计算,桌宠会有状态变化,需要按时投喂等.\&#13;如果嫌麻烦可以关掉'}" />
<!-- TODO: ComboBox使用内部数据 --> <!-- TODO: ComboBox使用内部数据 -->
<ComboBox <ComboBox
Grid.Column="2" Grid.Column="2"
d:SelectionChanged="combCalFunState_SelectionChanged"
pu:ComboBoxHelper.Watermark="{ll:Str '当关闭数据计算时\&#13;桌宠显示的状态'}" pu:ComboBoxHelper.Watermark="{ll:Str '当关闭数据计算时\&#13;桌宠显示的状态'}"
IsEnabled="{Binding IsChecked, ElementName=Switch_EnablePetState, Converter={StaticResource BoolInverter}}" IsEnabled="{Binding IsChecked, ElementName=Switch_EnablePetState, Converter={StaticResource BoolInverter}}"
SelectedIndex="0" SelectedIndex="0"
SelectedItem="{Binding InteractiveSetting.CalFunState}"
Style="{DynamicResource ComboBox_BaseStyle}" Style="{DynamicResource ComboBox_BaseStyle}"
ToolTip="{ll:Str '当关闭数据计算时\&#13;桌宠显示的状态'}"> ToolTip="{ll:Str '当关闭数据计算时\&#13;桌宠显示的状态'}">
<ComboBoxItem Content="Happy" /> <ComboBoxItem Content="Happy" />

View File

@ -14,12 +14,13 @@ using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
namespace VPet.Solution.Views; namespace VPet.Solution.Views;
/// <summary> /// <summary>
/// InteractiveSettingsPage.xaml 的交互逻辑 /// InteractiveSettingsPage.xaml 的交互逻辑
/// </summary> /// </summary>
public partial class InteractiveSettingsPage : Page public partial class InteractiveSettingPage : Page
{ {
public InteractiveSettingsPage() public InteractiveSettingPage()
{ {
InitializeComponent(); InitializeComponent();
} }

View File

@ -18,11 +18,29 @@
mc:Ignorable="d"> mc:Ignorable="d">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" MinWidth="100" />
<ColumnDefinition /> <ColumnDefinition MinWidth="300" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid> <Grid>
<ListBox x:Name="ListBox_Saves" /> <Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBox Style="{DynamicResource StandardTextBoxStyle}" Text="{Binding SearchSetting, UpdateSourceTrigger=PropertyChanged}" />
<ListBox
x:Name="ListBox_Saves"
Grid.Row="1"
d:ItemsSource="{d:SampleData ItemCount=5}"
ItemsSource="{Binding ShowSettings}"
SelectedItem="{Binding CurrentSetting}"
Style="{DynamicResource SideMenuListBoxStyle}">
<ListBox.ItemContainerStyle>
<Style BasedOn="{StaticResource {x:Type ListBoxItem}}" TargetType="ListBoxItem">
<Setter Property="Content" Value="{Binding Name}" />
<Setter Property="ToolTip" Value="{Binding Path}" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</Grid> </Grid>
<Grid Grid.Column="1"> <Grid Grid.Column="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>

View File

@ -1,5 +1,7 @@
using HKW.HKWUtils; using HKW.HKWUtils;
using Panuon.WPF.UI; using Panuon.WPF.UI;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using VPet.Solution.ViewModels; using VPet.Solution.ViewModels;
@ -10,7 +12,7 @@ namespace VPet.Solution.Views;
/// </summary> /// </summary>
public partial class MainWindow : WindowX public partial class MainWindow : WindowX
{ {
public MainWindowVM ViewModel => this.SetViewModel<MainWindowVM>().Value; public MainWindowVM ViewModel => (MainWindowVM)DataContext;
public MainWindow() public MainWindow()
{ {
@ -20,12 +22,14 @@ public partial class MainWindow : WindowX
return; return;
} }
InitializeComponent(); InitializeComponent();
ListBoxItem_GraphicsSettings.Tag = new GraphicsSettingsPage(); this.SetViewModel<MainWindowVM>();
ListBoxItem_SystemSettings.Tag = new SystemSettingsPage();
ListBoxItem_InteractiveSettings.Tag = new InteractiveSettingsPage(); ListBoxItem_GraphicsSettings.Tag = new GraphicsSettingPage();
ListBoxItem_CustomizedSettings.Tag = new CustomizedSettingsPage(); ListBoxItem_SystemSettings.Tag = new SystemSettingPage();
ListBoxItem_DiagnosticSettings.Tag = new DiagnosticSettingsPage(); ListBoxItem_InteractiveSettings.Tag = new InteractiveSettingPage();
ListBoxItem_ModSettings.Tag = new ModSettingsPage(); ListBoxItem_CustomizedSettings.Tag = new CustomizedSettingPage();
ListBoxItem_DiagnosticSettings.Tag = new DiagnosticSettingPage();
ListBoxItem_ModSettings.Tag = new ModSettingPage();
} }
private void Frame_Main_ContentRendered(object sender, EventArgs e) private void Frame_Main_ContentRendered(object sender, EventArgs e)

View File

@ -1,5 +1,5 @@
<Page <Page
x:Class="VPet.Solution.Views.ModSettingsPage" x:Class="VPet.Solution.Views.ModSettingPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@ -9,7 +9,7 @@
xmlns:pu="https://opensource.panuon.com/wpf-ui" xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels" xmlns:vm="clr-namespace:VPet.Solution.ViewModels"
Title="ModSettingsPage" Title="ModSettingsPage"
d:DataContext="{d:DesignInstance Type=vm:GraphicsSettingsPageVM}" d:DataContext="{d:DesignInstance Type=vm:GraphicsSettingPageVM}"
d:DesignHeight="450" d:DesignHeight="450"
d:DesignWidth="800" d:DesignWidth="800"
mc:Ignorable="d"> mc:Ignorable="d">

View File

@ -14,12 +14,13 @@ using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
namespace VPet.Solution.Views; namespace VPet.Solution.Views;
/// <summary> /// <summary>
/// ModSettingsPage.xaml 的交互逻辑 /// ModSettingsPage.xaml 的交互逻辑
/// </summary> /// </summary>
public partial class ModSettingsPage : Page public partial class ModSettingPage : Page
{ {
public ModSettingsPage() public ModSettingPage()
{ {
InitializeComponent(); InitializeComponent();
} }

View File

@ -1,5 +1,5 @@
<Page <Page
x:Class="VPet.Solution.Views.SystemSettingsPage" x:Class="VPet.Solution.Views.SystemSettingPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@ -11,7 +11,7 @@
xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels" xmlns:vm="clr-namespace:VPet.Solution.ViewModels"
Title="SystemSettingsPage" Title="SystemSettingsPage"
d:DataContext="{d:DesignInstance Type=vm:SystemSettingsPageVM}" d:DataContext="{d:DesignInstance Type=vm:SystemSettingPageVM}"
d:DesignHeight="450" d:DesignHeight="450"
d:DesignWidth="800" d:DesignWidth="800"
mc:Ignorable="d"> mc:Ignorable="d">
@ -100,10 +100,9 @@
<pu:NumberInput <pu:NumberInput
x:Name="numBackupSaveMaxNum" x:Name="numBackupSaveMaxNum"
Grid.Column="2" Grid.Column="2"
d:ValueChanged="numBackupSaveMaxNum_ValueChanged"
Minimum="1" Minimum="1"
Style="{DynamicResource NumberInput_BaseStyle}" Style="{DynamicResource NumberInput_BaseStyle}"
Value="20" /> Value="{Binding SystemSetting.BackupSaveMaxNum}" />
</Grid> </Grid>
<!--<Grid Margin="0,5,0,0"> <!--<Grid Margin="0,5,0,0">
<Grid.RowDefinitions> <Grid.RowDefinitions>

View File

@ -14,12 +14,13 @@ using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
namespace VPet.Solution.Views; namespace VPet.Solution.Views;
/// <summary> /// <summary>
/// SystemSettingsPage.xaml 的交互逻辑 /// SystemSettingsPage.xaml 的交互逻辑
/// </summary> /// </summary>
public partial class SystemSettingsPage : Page public partial class SystemSettingPage : Page
{ {
public SystemSettingsPage() public SystemSettingPage()
{ {
InitializeComponent(); InitializeComponent();
} }