mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
VPet.Solution 设置保存更新
This commit is contained in:
parent
6aff72bf91
commit
7d9d4a9764
@ -1,4 +1,6 @@
|
|||||||
using HKW.HKWUtils.Observable;
|
using HKW.HKWUtils.Observable;
|
||||||
|
using LinePutScript.Localization.WPF;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
@ -6,13 +8,14 @@ namespace VPet.Solution.Models.SettingEditor;
|
|||||||
|
|
||||||
public class GraphicsSettingModel : ObservableClass<GraphicsSettingModel>
|
public class GraphicsSettingModel : ObservableClass<GraphicsSettingModel>
|
||||||
{
|
{
|
||||||
#region
|
#region ZoomLevel
|
||||||
private double _zoomLevel = 1;
|
private double _zoomLevel = 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 缩放倍率
|
/// 缩放倍率
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(1)]
|
[DefaultValue(1)]
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.ZoomLevel))]
|
||||||
public double ZoomLevel
|
public double ZoomLevel
|
||||||
{
|
{
|
||||||
get => _zoomLevel;
|
get => _zoomLevel;
|
||||||
@ -37,23 +40,29 @@ public class GraphicsSettingModel : ObservableClass<GraphicsSettingModel>
|
|||||||
set => SetProperty(ref _zoomLevelMaximum, value);
|
set => SetProperty(ref _zoomLevelMaximum, value);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Resolution
|
||||||
private int _resolution = 1000;
|
private int _resolution = 1000;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 桌宠图形渲染的分辨率,越高图形越清晰
|
/// 桌宠图形渲染的分辨率,越高图形越清晰
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(1000)]
|
[DefaultValue(1000)]
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.Resolution))]
|
||||||
public int Resolution
|
public int Resolution
|
||||||
{
|
{
|
||||||
get => _resolution;
|
get => _resolution;
|
||||||
set => SetProperty(ref _resolution, value);
|
set => SetProperty(ref _resolution, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IsBiggerScreen
|
||||||
private bool _isBiggerScreen;
|
private bool _isBiggerScreen;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否为更大的屏幕
|
/// 是否为更大的屏幕
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.IsBiggerScreen))]
|
||||||
public bool IsBiggerScreen
|
public bool IsBiggerScreen
|
||||||
{
|
{
|
||||||
get => _isBiggerScreen;
|
get => _isBiggerScreen;
|
||||||
@ -66,94 +75,125 @@ public class GraphicsSettingModel : ObservableClass<GraphicsSettingModel>
|
|||||||
ZoomLevelMaximum = 3;
|
ZoomLevelMaximum = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region TopMost
|
||||||
private bool _topMost;
|
private bool _topMost;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否置于顶层
|
/// 是否置于顶层
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.TopMost))]
|
||||||
public bool TopMost
|
public bool TopMost
|
||||||
{
|
{
|
||||||
get => _topMost;
|
get => _topMost;
|
||||||
set => SetProperty(ref _topMost, value);
|
set => SetProperty(ref _topMost, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region HitThrough
|
||||||
private bool _hitThrough;
|
private bool _hitThrough;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否鼠标穿透
|
/// 是否鼠标穿透
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.HitThrough))]
|
||||||
public bool HitThrough
|
public bool HitThrough
|
||||||
{
|
{
|
||||||
get => _hitThrough;
|
get => _hitThrough;
|
||||||
set => SetProperty(ref _hitThrough, value);
|
set => SetProperty(ref _hitThrough, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
private string _language;
|
#region Language
|
||||||
|
private string _language = Languages.First();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 语言
|
/// 语言
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.Language))]
|
||||||
public string Language
|
public string Language
|
||||||
{
|
{
|
||||||
get => _language;
|
get => _language;
|
||||||
set => SetProperty(ref _language, value);
|
set => SetProperty(ref _language, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ObservableCollection<string> Languages { get; } =
|
||||||
|
new() { "zh-Hans", "zh-Hant", "en" };
|
||||||
|
// NOTE: 实际上这里面并没有文化 new(LocalizeCore.AvailableCultures);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Font
|
||||||
private string _font;
|
private string _font;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 字体
|
/// 字体
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.Font))]
|
||||||
public string Font
|
public string Font
|
||||||
{
|
{
|
||||||
get => _font;
|
get => _font;
|
||||||
set => SetProperty(ref _font, value);
|
set => SetProperty(ref _font, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Theme
|
||||||
private string _theme;
|
private string _theme;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 主题
|
/// 主题
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.Theme))]
|
||||||
public string Theme
|
public string Theme
|
||||||
{
|
{
|
||||||
get => _theme;
|
get => _theme;
|
||||||
set => SetProperty(ref _theme, value);
|
set => SetProperty(ref _theme, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region StartUPBoot
|
||||||
private bool _startUPBoot;
|
private bool _startUPBoot;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开机启动
|
/// 开机启动
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.StartUPBoot))]
|
||||||
public bool StartUPBoot
|
public bool StartUPBoot
|
||||||
{
|
{
|
||||||
get => _startUPBoot;
|
get => _startUPBoot;
|
||||||
set => SetProperty(ref _startUPBoot, value);
|
set => SetProperty(ref _startUPBoot, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region StartUPBootSteam
|
||||||
private bool _startUPBootSteam;
|
private bool _startUPBootSteam;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开机启动 Steam
|
/// 开机启动 Steam
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.StartUPBootSteam))]
|
||||||
public bool StartUPBootSteam
|
public bool StartUPBootSteam
|
||||||
{
|
{
|
||||||
get => _startUPBootSteam;
|
get => _startUPBootSteam;
|
||||||
set => SetProperty(ref _startUPBootSteam, value);
|
set => SetProperty(ref _startUPBootSteam, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region StartRecordLast
|
||||||
private bool _startRecordLast = true;
|
private bool _startRecordLast = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否记录游戏退出位置
|
/// 是否记录游戏退出位置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(true)]
|
[DefaultValue(true)]
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.StartRecordLast))]
|
||||||
public bool StartRecordLast
|
public bool StartRecordLast
|
||||||
{
|
{
|
||||||
get => _startRecordLast;
|
get => _startRecordLast;
|
||||||
set => SetProperty(ref _startRecordLast, value);
|
set => SetProperty(ref _startRecordLast, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
//private Point _startRecordLastPoint;
|
//private Point _startRecordLastPoint;
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
@ -165,26 +205,32 @@ public class GraphicsSettingModel : ObservableClass<GraphicsSettingModel>
|
|||||||
// set => SetProperty(ref _startRecordLastPoint, value);
|
// set => SetProperty(ref _startRecordLastPoint, value);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
#region StartRecordPoint
|
||||||
private ObservablePoint _startRecordPoint;
|
private ObservablePoint _startRecordPoint;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置中桌宠启动的位置
|
/// 设置中桌宠启动的位置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ReflectionPropertyInfo(typeof(ObservablePointToPointConverter))]
|
[ReflectionProperty]
|
||||||
|
[ReflectionPropertyConverter(typeof(ObservablePointToPointConverter))]
|
||||||
public ObservablePoint StartRecordPoint
|
public ObservablePoint StartRecordPoint
|
||||||
{
|
{
|
||||||
get => _startRecordPoint;
|
get => _startRecordPoint;
|
||||||
set => SetProperty(ref _startRecordPoint, value);
|
set => SetProperty(ref _startRecordPoint, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region HideFromTaskControl
|
||||||
private bool _hideFromTaskControl;
|
private bool _hideFromTaskControl;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 在任务切换器(Alt+Tab)中隐藏窗口
|
/// 在任务切换器(Alt+Tab)中隐藏窗口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.HideFromTaskControl))]
|
||||||
public bool HideFromTaskControl
|
public bool HideFromTaskControl
|
||||||
{
|
{
|
||||||
get => _hideFromTaskControl;
|
get => _hideFromTaskControl;
|
||||||
set => SetProperty(ref _hideFromTaskControl, value);
|
set => SetProperty(ref _hideFromTaskControl, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -1,251 +1,328 @@
|
|||||||
using HKW.HKWUtils.Observable;
|
using HKW.HKWUtils.Observable;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using VPet_Simulator.Core;
|
using VPet_Simulator.Core;
|
||||||
|
|
||||||
namespace VPet.Solution.Models.SettingEditor;
|
namespace VPet.Solution.Models.SettingEditor;
|
||||||
|
|
||||||
public class InteractiveSettingModel : ObservableClass<InteractiveSettingModel>
|
public class InteractiveSettingModel : ObservableClass<InteractiveSettingModel>
|
||||||
{
|
{
|
||||||
private string _petName;
|
// NOTE: 这玩意其实在存档里 而不是设置里
|
||||||
|
//#region PetName
|
||||||
|
//private string _petName;
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 宠物名称
|
///// 宠物名称
|
||||||
/// </summary>
|
///// </summary>
|
||||||
public string PetName
|
//[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.PetName))]
|
||||||
{
|
//public string PetName
|
||||||
get => _petName;
|
//{
|
||||||
set => SetProperty(ref _petName, value);
|
// get => _petName;
|
||||||
}
|
// set => SetProperty(ref _petName, value);
|
||||||
|
//}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
#region VoiceVolume
|
||||||
private double _voiceVolume;
|
private double _voiceVolume;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 播放声音大小
|
/// 播放声音大小
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.VoiceVolume))]
|
||||||
public double VoiceVolume
|
public double VoiceVolume
|
||||||
{
|
{
|
||||||
get => _voiceVolume;
|
get => _voiceVolume;
|
||||||
set => SetProperty(ref _voiceVolume, value);
|
set => SetProperty(ref _voiceVolume, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CalFunState
|
||||||
private GameSave.ModeType _calFunState;
|
private GameSave.ModeType _calFunState;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 非计算模式下默认模式
|
/// 非计算模式下默认模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.CalFunState))]
|
||||||
public GameSave.ModeType CalFunState
|
public GameSave.ModeType CalFunState
|
||||||
{
|
{
|
||||||
get => _calFunState;
|
get => _calFunState;
|
||||||
set => SetProperty(ref _calFunState, value);
|
set => SetProperty(ref _calFunState, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<GameSave.ModeType> ModeTypes { get; } =
|
||||||
|
new(Enum.GetValues(typeof(GameSave.ModeType)).Cast<GameSave.ModeType>());
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PetHelper
|
||||||
private bool _petHelper;
|
private bool _petHelper;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否显示宠物帮助窗口
|
/// 是否显示宠物帮助窗口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.PetHelper))]
|
||||||
public bool PetHelper
|
public bool PetHelper
|
||||||
{
|
{
|
||||||
get => _petHelper;
|
get => _petHelper;
|
||||||
set => SetProperty(ref _petHelper, value);
|
set => SetProperty(ref _petHelper, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region LastCacheDate
|
||||||
private DateTime _lastCacheDate;
|
private DateTime _lastCacheDate;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上次清理缓存日期
|
/// 上次清理缓存日期
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.LastCacheDate))]
|
||||||
public DateTime LastCacheDate
|
public DateTime LastCacheDate
|
||||||
{
|
{
|
||||||
get => _lastCacheDate;
|
get => _lastCacheDate;
|
||||||
set => SetProperty(ref _lastCacheDate, value);
|
set => SetProperty(ref _lastCacheDate, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SaveTimes
|
||||||
private int _saveTimes;
|
private int _saveTimes;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 储存顺序次数
|
/// 储存顺序次数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.SaveTimes))]
|
||||||
public int SaveTimes
|
public int SaveTimes
|
||||||
{
|
{
|
||||||
get => _saveTimes;
|
get => _saveTimes;
|
||||||
set => SetProperty(ref _saveTimes, value);
|
set => SetProperty(ref _saveTimes, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PressLength
|
||||||
private int _pressLength;
|
private int _pressLength;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 按多久视为长按 单位毫秒
|
/// 按多久视为长按 单位毫秒
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.PressLength))]
|
||||||
public int PressLength
|
public int PressLength
|
||||||
{
|
{
|
||||||
get => _pressLength;
|
get => _pressLength;
|
||||||
set => SetProperty(ref _pressLength, value);
|
set => SetProperty(ref _pressLength, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region InteractionCycle
|
||||||
private int _interactionCycle;
|
private int _interactionCycle;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 互动周期
|
/// 互动周期
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.InteractionCycle))]
|
||||||
public int InteractionCycle
|
public int InteractionCycle
|
||||||
{
|
{
|
||||||
get => _interactionCycle;
|
get => _interactionCycle;
|
||||||
set => SetProperty(ref _interactionCycle, value);
|
set => SetProperty(ref _interactionCycle, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region LogicInterval
|
||||||
private double _logicInterval;
|
private double _logicInterval;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 计算间隔 (秒)
|
/// 计算间隔 (秒)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.LogicInterval))]
|
||||||
public double LogicInterval
|
public double LogicInterval
|
||||||
{
|
{
|
||||||
get => _logicInterval;
|
get => _logicInterval;
|
||||||
set => SetProperty(ref _logicInterval, value);
|
set => SetProperty(ref _logicInterval, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PetHelpLeft
|
||||||
private double _petHelpLeft;
|
private double _petHelpLeft;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 计算间隔
|
/// 计算间隔
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.PetHelpLeft))]
|
||||||
public double PetHelpLeft
|
public double PetHelpLeft
|
||||||
{
|
{
|
||||||
get => _petHelpLeft;
|
get => _petHelpLeft;
|
||||||
set => SetProperty(ref _petHelpLeft, value);
|
set => SetProperty(ref _petHelpLeft, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PetHelpTop
|
||||||
private double _petHelpTop;
|
private double _petHelpTop;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 计算间隔
|
/// 计算间隔
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.PetHelpTop))]
|
||||||
public double PetHelpTop
|
public double PetHelpTop
|
||||||
{
|
{
|
||||||
get => _petHelpTop;
|
get => _petHelpTop;
|
||||||
set => SetProperty(ref _petHelpTop, value);
|
set => SetProperty(ref _petHelpTop, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region AllowMove
|
||||||
private bool _allowMove;
|
private bool _allowMove;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 允许移动事件
|
/// 允许移动事件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.AllowMove))]
|
||||||
public bool AllowMove
|
public bool AllowMove
|
||||||
{
|
{
|
||||||
get => _allowMove;
|
get => _allowMove;
|
||||||
set => SetProperty(ref _allowMove, value);
|
set => SetProperty(ref _allowMove, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SmartMove
|
||||||
private bool _smartMove;
|
private bool _smartMove;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 智能移动
|
/// 智能移动
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.SmartMove))]
|
||||||
public bool SmartMove
|
public bool SmartMove
|
||||||
{
|
{
|
||||||
get => _smartMove;
|
get => _smartMove;
|
||||||
set => SetProperty(ref _smartMove, value);
|
set => SetProperty(ref _smartMove, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region EnableFunction
|
||||||
private bool _enableFunction;
|
private bool _enableFunction;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用计算等数据功能
|
/// 启用计算等数据功能
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.EnableFunction))]
|
||||||
public bool EnableFunction
|
public bool EnableFunction
|
||||||
{
|
{
|
||||||
get => _enableFunction;
|
get => _enableFunction;
|
||||||
set => SetProperty(ref _enableFunction, value);
|
set => SetProperty(ref _enableFunction, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SmartMoveInterval
|
||||||
private int _smartMoveInterval;
|
private int _smartMoveInterval;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 智能移动周期 (秒)
|
/// 智能移动周期 (秒)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.SmartMoveInterval))]
|
||||||
public int SmartMoveInterval
|
public int SmartMoveInterval
|
||||||
{
|
{
|
||||||
get => _smartMoveInterval;
|
get => _smartMoveInterval;
|
||||||
set => SetProperty(ref _smartMoveInterval, value);
|
set => SetProperty(ref _smartMoveInterval, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region MessageBarOutside
|
||||||
private bool _messageBarOutside;
|
private bool _messageBarOutside;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 消息框外置
|
/// 消息框外置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.MessageBarOutside))]
|
||||||
public bool MessageBarOutside
|
public bool MessageBarOutside
|
||||||
{
|
{
|
||||||
get => _messageBarOutside;
|
get => _messageBarOutside;
|
||||||
set => SetProperty(ref _messageBarOutside, value);
|
set => SetProperty(ref _messageBarOutside, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PetGraph
|
||||||
private string _petGraph;
|
private string _petGraph;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 桌宠选择内容
|
/// 桌宠选择内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.PetGraph))]
|
||||||
public string PetGraph
|
public string PetGraph
|
||||||
{
|
{
|
||||||
get => _petGraph;
|
get => _petGraph;
|
||||||
set => SetProperty(ref _petGraph, value);
|
set => SetProperty(ref _petGraph, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region MusicCatch
|
||||||
private double _musicCatch;
|
private double _musicCatch;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当实时播放音量达到该值时运行音乐动作
|
/// 当实时播放音量达到该值时运行音乐动作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.MusicCatch))]
|
||||||
public double MusicCatch
|
public double MusicCatch
|
||||||
{
|
{
|
||||||
get => _musicCatch;
|
get => _musicCatch;
|
||||||
set => SetProperty(ref _musicCatch, value);
|
set => SetProperty(ref _musicCatch, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region MusicMax
|
||||||
private double _musicMax;
|
private double _musicMax;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当实时播放音量达到该值时运行特殊音乐动作
|
/// 当实时播放音量达到该值时运行特殊音乐动作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.MusicMax))]
|
||||||
public double MusicMax
|
public double MusicMax
|
||||||
{
|
{
|
||||||
get => _musicMax;
|
get => _musicMax;
|
||||||
set => SetProperty(ref _musicMax, value);
|
set => SetProperty(ref _musicMax, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region AutoBuy
|
||||||
private bool _autoBuy;
|
private bool _autoBuy;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 允许桌宠自动购买食品
|
/// 允许桌宠自动购买食品
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.AutoBuy))]
|
||||||
public bool AutoBuy
|
public bool AutoBuy
|
||||||
{
|
{
|
||||||
get => _autoBuy;
|
get => _autoBuy;
|
||||||
set => SetProperty(ref _autoBuy, value);
|
set => SetProperty(ref _autoBuy, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region AutoGift
|
||||||
private bool _autoGift;
|
private bool _autoGift;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 允许桌宠自动购买礼物
|
/// 允许桌宠自动购买礼物
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.AutoGift))]
|
||||||
public bool AutoGift
|
public bool AutoGift
|
||||||
{
|
{
|
||||||
get => _autoGift;
|
get => _autoGift;
|
||||||
set => SetProperty(ref _autoGift, value);
|
set => SetProperty(ref _autoGift, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region MoveAreaDefault
|
||||||
private bool _moveAreaDefault;
|
private bool _moveAreaDefault;
|
||||||
|
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.MoveAreaDefault))]
|
||||||
public bool MoveAreaDefault
|
public bool MoveAreaDefault
|
||||||
{
|
{
|
||||||
get => _moveAreaDefault;
|
get => _moveAreaDefault;
|
||||||
set => SetProperty(ref _moveAreaDefault, value);
|
set => SetProperty(ref _moveAreaDefault, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region MoveArea
|
||||||
private System.Drawing.Rectangle _moveArea;
|
private System.Drawing.Rectangle _moveArea;
|
||||||
|
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.MoveArea))]
|
||||||
public System.Drawing.Rectangle MoveArea
|
public System.Drawing.Rectangle MoveArea
|
||||||
{
|
{
|
||||||
get => _moveArea;
|
get => _moveArea;
|
||||||
set => SetProperty(ref _moveArea, value);
|
set => SetProperty(ref _moveArea, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -12,35 +12,26 @@ namespace VPet.Solution.Models.SettingEditor;
|
|||||||
|
|
||||||
public class SettingModel : ObservableClass<SettingModel>
|
public class SettingModel : ObservableClass<SettingModel>
|
||||||
{
|
{
|
||||||
private string _name;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 名称
|
/// 名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name
|
public string Name { get; set; }
|
||||||
{
|
|
||||||
get => _name;
|
|
||||||
set => SetProperty(ref _name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private string _filePath;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件路径
|
/// 文件路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FilePath
|
public string FilePath { get; set; }
|
||||||
{
|
|
||||||
get => _filePath;
|
|
||||||
set => SetProperty(ref _filePath, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#region GraphicsSetting
|
||||||
private GraphicsSettingModel _graphicsSetting;
|
private GraphicsSettingModel _graphicsSetting;
|
||||||
public GraphicsSettingModel GraphicsSetting
|
public GraphicsSettingModel GraphicsSetting
|
||||||
{
|
{
|
||||||
get => _graphicsSetting;
|
get => _graphicsSetting;
|
||||||
set => SetProperty(ref _graphicsSetting, value);
|
set => SetProperty(ref _graphicsSetting, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SystemSetting
|
||||||
private SystemSettingModel _systemSetting;
|
private SystemSettingModel _systemSetting;
|
||||||
|
|
||||||
public SystemSettingModel SystemSetting
|
public SystemSettingModel SystemSetting
|
||||||
@ -48,13 +39,16 @@ public class SettingModel : ObservableClass<SettingModel>
|
|||||||
get => _systemSetting;
|
get => _systemSetting;
|
||||||
set => SetProperty(ref _systemSetting, value);
|
set => SetProperty(ref _systemSetting, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region InteractiveSetting
|
||||||
private InteractiveSettingModel _interactiveSetting;
|
private InteractiveSettingModel _interactiveSetting;
|
||||||
public InteractiveSettingModel InteractiveSetting
|
public InteractiveSettingModel InteractiveSetting
|
||||||
{
|
{
|
||||||
get => _interactiveSetting;
|
get => _interactiveSetting;
|
||||||
set => SetProperty(ref _interactiveSetting, value);
|
set => SetProperty(ref _interactiveSetting, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
private static HashSet<string> _settingProperties =
|
private static HashSet<string> _settingProperties =
|
||||||
new(typeof(Setting).GetProperties().Select(p => p.Name));
|
new(typeof(Setting).GetProperties().Select(p => p.Name));
|
||||||
@ -63,27 +57,35 @@ public class SettingModel : ObservableClass<SettingModel>
|
|||||||
|
|
||||||
private ReflectionOptions _saveReflectionOptions = new() { CheckValueEquals = true };
|
private ReflectionOptions _saveReflectionOptions = new() { CheckValueEquals = true };
|
||||||
|
|
||||||
|
public SettingModel()
|
||||||
|
: this(new("")) { }
|
||||||
|
|
||||||
public SettingModel(Setting setting)
|
public SettingModel(Setting setting)
|
||||||
{
|
{
|
||||||
_setting = setting;
|
_setting = setting;
|
||||||
GraphicsSetting = LoadGraphicsSettings();
|
GraphicsSetting = LoadSetting<GraphicsSettingModel>();
|
||||||
|
InteractiveSetting = LoadSetting<InteractiveSettingModel>();
|
||||||
|
SystemSetting = LoadSetting<SystemSettingModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private GraphicsSettingModel LoadGraphicsSettings()
|
private T LoadSetting<T>()
|
||||||
|
where T : new()
|
||||||
{
|
{
|
||||||
var graphicsSetting = new GraphicsSettingModel();
|
var setting = new T();
|
||||||
ReflectionUtils.SetValue(_setting, graphicsSetting);
|
ReflectionUtils.SetValue(_setting, setting);
|
||||||
return graphicsSetting;
|
return setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
SaveGraphicsSettings();
|
SaveSetting(GraphicsSetting);
|
||||||
|
SaveSetting(InteractiveSetting);
|
||||||
|
SaveSetting(SystemSetting);
|
||||||
File.WriteAllText(FilePath, _setting.ToString());
|
File.WriteAllText(FilePath, _setting.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveGraphicsSettings()
|
private void SaveSetting(object setting)
|
||||||
{
|
{
|
||||||
ReflectionUtils.SetValue(GraphicsSetting, _setting, _saveReflectionOptions);
|
ReflectionUtils.SetValue(setting, _setting, _saveReflectionOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace VPet.Solution.Models.SettingEditor;
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
namespace VPet.Solution.Models.SettingEditor;
|
||||||
|
|
||||||
public class SystemSettingModel : ObservableClass<SystemSettingModel>
|
public class SystemSettingModel : ObservableClass<SystemSettingModel>
|
||||||
{
|
{
|
||||||
@ -7,47 +9,62 @@ public class SystemSettingModel : ObservableClass<SystemSettingModel>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool DiagnosisDayEnable { get; } = true;
|
public bool DiagnosisDayEnable { get; } = true;
|
||||||
|
|
||||||
|
#region Diagnosis
|
||||||
private bool _diagnosis;
|
private bool _diagnosis;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否启用数据收集
|
/// 是否启用数据收集
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.Diagnosis))]
|
||||||
public bool Diagnosis
|
public bool Diagnosis
|
||||||
{
|
{
|
||||||
get => _diagnosis;
|
get => _diagnosis;
|
||||||
set => SetProperty(ref _diagnosis, value);
|
set => SetProperty(ref _diagnosis, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region DiagnosisInterval
|
||||||
private int _diagnosisInterval;
|
private int _diagnosisInterval;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数据收集频率
|
/// 数据收集频率
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.DiagnosisInterval))]
|
||||||
public int DiagnosisInterval
|
public int DiagnosisInterval
|
||||||
{
|
{
|
||||||
get => _diagnosisInterval;
|
get => _diagnosisInterval;
|
||||||
set => SetProperty(ref _diagnosisInterval, value);
|
set => SetProperty(ref _diagnosisInterval, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region AutoSaveInterval
|
||||||
private int _autoSaveInterval;
|
private int _autoSaveInterval;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自动保存频率 (min)
|
/// 自动保存频率 (min)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.AutoSaveInterval))]
|
||||||
public int AutoSaveInterval
|
public int AutoSaveInterval
|
||||||
{
|
{
|
||||||
get => _autoSaveInterval;
|
get => _autoSaveInterval;
|
||||||
set => SetProperty(ref _autoSaveInterval, value);
|
set => SetProperty(ref _autoSaveInterval, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ObservableCollection<int> SaveIntervals { get; } =
|
||||||
|
new() { -1, 2, 5, 10, 20, 30, 60 };
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region BackupSaveMaxNum
|
||||||
private int _backupSaveMaxNum;
|
private int _backupSaveMaxNum;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 备份保存最大数量
|
/// 备份保存最大数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.BackupSaveMaxNum))]
|
||||||
public int BackupSaveMaxNum
|
public int BackupSaveMaxNum
|
||||||
{
|
{
|
||||||
get => _backupSaveMaxNum;
|
get => _backupSaveMaxNum;
|
||||||
set => SetProperty(ref _backupSaveMaxNum, value);
|
set => SetProperty(ref _backupSaveMaxNum, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,11 @@ namespace HKW.HKWUtils;
|
|||||||
|
|
||||||
public static class ReflectionUtils
|
public static class ReflectionUtils
|
||||||
{
|
{
|
||||||
|
private static readonly BindingFlags _propertyBindingFlags =
|
||||||
|
BindingFlags.Instance | BindingFlags.Public;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 目标名称
|
/// 类型信息
|
||||||
/// <para>
|
/// <para>
|
||||||
/// (TargetType, (PropertyName, TargetPropertyName))
|
/// (TargetType, (PropertyName, TargetPropertyName))
|
||||||
/// </para>
|
/// </para>
|
||||||
@ -20,15 +23,11 @@ public static class ReflectionUtils
|
|||||||
private static readonly Dictionary<Type, ReflectionObjectInfo> _typePropertyReflectionInfos =
|
private static readonly Dictionary<Type, ReflectionObjectInfo> _typePropertyReflectionInfos =
|
||||||
new();
|
new();
|
||||||
|
|
||||||
public static void SetValue<TSource, TTarget>(
|
public static void SetValue(object source, object target, ReflectionOptions options = null!)
|
||||||
TSource source,
|
|
||||||
TTarget target,
|
|
||||||
ReflectionOptions options = null!
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
options ??= new();
|
options ??= new();
|
||||||
var sourceType = typeof(TSource);
|
var sourceType = source.GetType();
|
||||||
var targetType = typeof(TTarget);
|
var targetType = target.GetType();
|
||||||
if (_typePropertyReflectionInfos.TryGetValue(sourceType, out var sourceInfo) is false)
|
if (_typePropertyReflectionInfos.TryGetValue(sourceType, out var sourceInfo) is false)
|
||||||
sourceInfo = _typePropertyReflectionInfos[sourceType] = GetReflectionObjectInfo(
|
sourceInfo = _typePropertyReflectionInfos[sourceType] = GetReflectionObjectInfo(
|
||||||
sourceType
|
sourceType
|
||||||
@ -41,24 +40,23 @@ public static class ReflectionUtils
|
|||||||
var sourceAccessor = ObjectAccessor.Create(source);
|
var sourceAccessor = ObjectAccessor.Create(source);
|
||||||
var targetAccessor = ObjectAccessor.Create(target);
|
var targetAccessor = ObjectAccessor.Create(target);
|
||||||
|
|
||||||
foreach (var property in sourceType.GetProperties())
|
foreach (var property in targetType.GetProperties(_propertyBindingFlags))
|
||||||
{
|
{
|
||||||
|
// 尝试获取目标属性信息
|
||||||
|
targetInfo.PropertyInfos.TryGetValue(property.Name, out var targetReflectionInfo);
|
||||||
// 获取源属性名
|
// 获取源属性名
|
||||||
var sourcePropertyName = sourceInfo.PropertyInfos.TryGetValue(
|
var sourcePropertyName = targetReflectionInfo is null
|
||||||
property.Name,
|
? property.Name
|
||||||
out var sourceReflectionInfo
|
: targetReflectionInfo.TargetName;
|
||||||
)
|
// 获取源属性信息
|
||||||
? sourceReflectionInfo.PropertyName
|
sourceInfo.PropertyInfos.TryGetValue(sourcePropertyName, out var sourceReflectionInfo);
|
||||||
: property.Name;
|
if (sourceInfo.PropertyNames.Contains(sourcePropertyName) is false)
|
||||||
if (targetInfo.PropertyNames.Contains(sourcePropertyName) is false)
|
{
|
||||||
|
if (targetReflectionInfo?.IsRequired is true)
|
||||||
|
options.UnassignedRequiredProperties.Add(property.Name);
|
||||||
continue;
|
continue;
|
||||||
// 获取目标属性名
|
}
|
||||||
var targetPropertyName = targetInfo.PropertyInfos.TryGetValue(
|
|
||||||
sourcePropertyName,
|
|
||||||
out var targetReflectionInfo
|
|
||||||
)
|
|
||||||
? targetReflectionInfo.PropertyName
|
|
||||||
: property.Name;
|
|
||||||
// 获取源值
|
// 获取源值
|
||||||
var sourceValue = sourceAccessor[sourcePropertyName];
|
var sourceValue = sourceAccessor[sourcePropertyName];
|
||||||
// 转换源值
|
// 转换源值
|
||||||
@ -69,26 +67,44 @@ public static class ReflectionUtils
|
|||||||
// 比较源值和目标值
|
// 比较源值和目标值
|
||||||
if (options.CheckValueEquals)
|
if (options.CheckValueEquals)
|
||||||
{
|
{
|
||||||
var targetValue = targetAccessor[targetPropertyName];
|
var targetValue = targetAccessor[property.Name];
|
||||||
if (sourceValue.Equals(targetValue))
|
if (sourceValue.Equals(targetValue))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
targetAccessor[targetPropertyName] = sourceValue;
|
targetAccessor[property.Name] = sourceValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReflectionObjectInfo GetReflectionObjectInfo(Type type)
|
private static ReflectionObjectInfo GetReflectionObjectInfo(Type type)
|
||||||
{
|
{
|
||||||
var objectInfo = new ReflectionObjectInfo(type);
|
var objectInfo = new ReflectionObjectInfo(type);
|
||||||
foreach (var property in type.GetProperties())
|
foreach (var property in type.GetProperties(_propertyBindingFlags))
|
||||||
{
|
{
|
||||||
if (property.IsDefined(typeof(ReflectionPropertyInfoAttribute)))
|
if (
|
||||||
|
property.IsDefined(typeof(ReflectionPropertyAttribute)) is false
|
||||||
|
&& property.IsDefined(typeof(ReflectionPropertyConverterAttribute)) is false
|
||||||
|
)
|
||||||
|
continue;
|
||||||
|
var propertyInfo = new ReflectionPropertyInfo(property.Name);
|
||||||
|
// 获取属性信息
|
||||||
|
if (
|
||||||
|
property.GetCustomAttribute<ReflectionPropertyAttribute>()
|
||||||
|
is ReflectionPropertyAttribute propertyInfoAttribute
|
||||||
|
)
|
||||||
{
|
{
|
||||||
var reflectionInfo = property.GetCustomAttribute<ReflectionPropertyInfoAttribute>();
|
if (string.IsNullOrWhiteSpace(propertyInfoAttribute.TargetName) is false)
|
||||||
if (string.IsNullOrWhiteSpace(reflectionInfo.PropertyName))
|
propertyInfo.TargetName = propertyInfoAttribute.TargetName;
|
||||||
reflectionInfo.PropertyName = property.Name;
|
propertyInfo.IsRequired = propertyInfoAttribute.IsRequired;
|
||||||
objectInfo.PropertyInfos[property.Name] = reflectionInfo;
|
|
||||||
}
|
}
|
||||||
|
// 获取属性转换器
|
||||||
|
if (
|
||||||
|
property.GetCustomAttribute<ReflectionPropertyConverterAttribute>()
|
||||||
|
is ReflectionPropertyConverterAttribute propertyConverterAttribute
|
||||||
|
)
|
||||||
|
{
|
||||||
|
propertyInfo.Converter = propertyConverterAttribute.Converter;
|
||||||
|
}
|
||||||
|
objectInfo.PropertyInfos[property.Name] = propertyInfo;
|
||||||
}
|
}
|
||||||
return objectInfo;
|
return objectInfo;
|
||||||
}
|
}
|
||||||
@ -101,7 +117,7 @@ public class ReflectionObjectInfo
|
|||||||
{
|
{
|
||||||
public HashSet<string> PropertyNames { get; }
|
public HashSet<string> PropertyNames { get; }
|
||||||
|
|
||||||
public Dictionary<string, ReflectionPropertyInfoAttribute> PropertyInfos { get; } = new();
|
public Dictionary<string, ReflectionPropertyInfo> PropertyInfos { get; } = new();
|
||||||
|
|
||||||
public ReflectionObjectInfo(Type type)
|
public ReflectionObjectInfo(Type type)
|
||||||
{
|
{
|
||||||
@ -109,29 +125,72 @@ public class ReflectionObjectInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public class ReflectionPropertyInfo
|
||||||
/// 反射属性信息
|
|
||||||
/// </summary>
|
|
||||||
public class ReflectionPropertyInfoAttribute : Attribute
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 目标属性名称
|
/// 目标属性名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PropertyName { get; set; }
|
public string TargetName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是必要的
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(true)]
|
||||||
|
public bool IsRequired { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 反射值转换器
|
||||||
|
/// </summary>
|
||||||
|
public IReflectionConverter? Converter { get; set; } = null;
|
||||||
|
|
||||||
|
public ReflectionPropertyInfo(string propertyName)
|
||||||
|
{
|
||||||
|
TargetName = propertyName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 反射属性信息
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
|
public class ReflectionPropertyAttribute : Attribute
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 属性名称
|
||||||
|
/// </summary>
|
||||||
|
public string TargetName { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是必要的
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(true)]
|
||||||
|
public bool IsRequired { get; } = true;
|
||||||
|
|
||||||
|
public ReflectionPropertyAttribute(bool isRequired = true)
|
||||||
|
{
|
||||||
|
IsRequired = isRequired;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReflectionPropertyAttribute(string name, bool isRequired = true)
|
||||||
|
{
|
||||||
|
TargetName = name;
|
||||||
|
IsRequired = isRequired;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 反射属性转换器
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
|
public class ReflectionPropertyConverterAttribute : Attribute
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 反射转换器
|
/// 反射转换器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IReflectionConverter? Converter { get; } = null;
|
public IReflectionConverter Converter { get; }
|
||||||
|
|
||||||
public ReflectionPropertyInfoAttribute(Type converterType)
|
public ReflectionPropertyConverterAttribute(Type converterType)
|
||||||
: this(string.Empty, converterType) { }
|
|
||||||
|
|
||||||
public ReflectionPropertyInfoAttribute(string name, Type? converterType = null)
|
|
||||||
{
|
{
|
||||||
PropertyName = name;
|
|
||||||
if (converterType is null)
|
|
||||||
return;
|
|
||||||
Converter = (IReflectionConverter)TypeAccessor.Create(converterType).CreateNew();
|
Converter = (IReflectionConverter)TypeAccessor.Create(converterType).CreateNew();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,6 +205,11 @@ public class ReflectionOptions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
public bool CheckValueEquals { get; set; } = false;
|
public bool CheckValueEquals { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 未赋值的必要属性
|
||||||
|
/// </summary>
|
||||||
|
public List<string> UnassignedRequiredProperties { get; set; } = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -77,6 +77,13 @@ public static class Utils
|
|||||||
return bitmapImage;
|
return bitmapImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取布尔值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">值</param>
|
||||||
|
/// <param name="boolValue">目标布尔值</param>
|
||||||
|
/// <param name="nullValue">为空时布尔值</param>
|
||||||
|
/// <returns></returns>
|
||||||
public static bool GetBool(object value, bool boolValue, bool nullValue)
|
public static bool GetBool(object value, bool boolValue, bool nullValue)
|
||||||
{
|
{
|
||||||
if (value is null)
|
if (value is null)
|
||||||
@ -88,4 +95,26 @@ public static class Utils
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 打开文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">文件路径</param>
|
||||||
|
public static void OpenFile(string filePath)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Process
|
||||||
|
.Start(new System.Diagnostics.ProcessStartInfo(filePath) { UseShellExecute = true })
|
||||||
|
?.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从资源管理器打开文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">文件路径</param>
|
||||||
|
public static void OpenFileInExplorer(string filePath)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Process
|
||||||
|
.Start("Explorer", $"/select,{Path.GetFullPath(filePath)}")
|
||||||
|
?.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,10 @@ public class InteractiveSettingPageVM : ObservableClass<InteractiveSettingPageVM
|
|||||||
|
|
||||||
private void Current_PropertyChangedX(SettingWindowVM sender, PropertyChangedXEventArgs e)
|
private void Current_PropertyChangedX(SettingWindowVM sender, PropertyChangedXEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.PropertyName == nameof(SettingWindowVM.CurrentSetting))
|
if (
|
||||||
|
e.PropertyName == nameof(SettingWindowVM.CurrentSetting)
|
||||||
|
&& sender.CurrentSetting is not null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
InteractiveSetting = sender.CurrentSetting.InteractiveSetting;
|
InteractiveSetting = sender.CurrentSetting.InteractiveSetting;
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,29 @@ public class SettingWindowVM : ObservableClass<SettingWindowVM>
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Command
|
#region Command
|
||||||
|
/// <summary>
|
||||||
|
/// 打开文件
|
||||||
|
/// </summary>
|
||||||
|
public ObservableCommand<SettingModel> OpenFileCommand { get; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从资源管理器打开
|
||||||
|
/// </summary>
|
||||||
|
public ObservableCommand<SettingModel> OpenFileInExplorerCommand { get; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重置
|
||||||
|
/// </summary>
|
||||||
public ObservableCommand<SettingModel> ResetSettingCommand { get; } = new();
|
public ObservableCommand<SettingModel> ResetSettingCommand { get; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存
|
||||||
|
/// </summary>
|
||||||
public ObservableCommand<SettingModel> SaveSettingCommand { get; } = new();
|
public ObservableCommand<SettingModel> SaveSettingCommand { get; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存全部
|
||||||
|
/// </summary>
|
||||||
public ObservableCommand SaveAllSettingCommand { get; } = new();
|
public ObservableCommand SaveAllSettingCommand { get; } = new();
|
||||||
#endregion
|
#endregion
|
||||||
public SettingWindowVM()
|
public SettingWindowVM()
|
||||||
@ -59,15 +80,37 @@ public class SettingWindowVM : ObservableClass<SettingWindowVM>
|
|||||||
|
|
||||||
foreach (var s in LoadSettings())
|
foreach (var s in LoadSettings())
|
||||||
_settings.Add(s);
|
_settings.Add(s);
|
||||||
|
|
||||||
PropertyChanged += MainWindowVM_PropertyChanged;
|
PropertyChanged += MainWindowVM_PropertyChanged;
|
||||||
|
OpenFileCommand.ExecuteCommand += OpenFileCommand_ExecuteCommand;
|
||||||
|
OpenFileInExplorerCommand.ExecuteCommand += OpenFileInExplorerCommand_ExecuteCommand;
|
||||||
ResetSettingCommand.ExecuteCommand += ResetSettingCommand_ExecuteCommand;
|
ResetSettingCommand.ExecuteCommand += ResetSettingCommand_ExecuteCommand;
|
||||||
SaveSettingCommand.ExecuteCommand += SaveSettingCommand_ExecuteCommand;
|
SaveSettingCommand.ExecuteCommand += SaveSettingCommand_ExecuteCommand;
|
||||||
SaveAllSettingCommand.ExecuteCommand += SaveAllSettingCommand_ExecuteCommand;
|
SaveAllSettingCommand.ExecuteCommand += SaveAllSettingCommand_ExecuteCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OpenFileInExplorerCommand_ExecuteCommand(SettingModel parameter)
|
||||||
|
{
|
||||||
|
Utils.OpenFileInExplorer(parameter.FilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenFileCommand_ExecuteCommand(SettingModel parameter)
|
||||||
|
{
|
||||||
|
Utils.OpenFile(parameter.FilePath);
|
||||||
|
}
|
||||||
|
|
||||||
private void SaveAllSettingCommand_ExecuteCommand()
|
private void SaveAllSettingCommand_ExecuteCommand()
|
||||||
{
|
{
|
||||||
|
if (
|
||||||
|
MessageBox.Show(
|
||||||
|
SettingWindow.Instance,
|
||||||
|
"确定全部保存吗".Translate(),
|
||||||
|
"",
|
||||||
|
MessageBoxButton.YesNo,
|
||||||
|
MessageBoxImage.Warning
|
||||||
|
)
|
||||||
|
is not MessageBoxResult.Yes
|
||||||
|
)
|
||||||
|
return;
|
||||||
foreach (var setting in _settings)
|
foreach (var setting in _settings)
|
||||||
setting.Save();
|
setting.Save();
|
||||||
}
|
}
|
||||||
@ -90,9 +133,7 @@ public class SettingWindowVM : ObservableClass<SettingWindowVM>
|
|||||||
is not MessageBoxResult.Yes
|
is not MessageBoxResult.Yes
|
||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
CurrentSetting = _settings[_settings.IndexOf(CurrentSetting)] = new SettingModel(
|
CurrentSetting = _settings[_settings.IndexOf(CurrentSetting)] = new SettingModel()
|
||||||
new Setting("")
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
Name = CurrentSetting.Name,
|
Name = CurrentSetting.Name,
|
||||||
FilePath = CurrentSetting.FilePath
|
FilePath = CurrentSetting.FilePath
|
||||||
|
@ -11,12 +11,15 @@ namespace VPet.Solution.ViewModels.SettingEditor;
|
|||||||
|
|
||||||
public class SystemSettingPageVM : ObservableClass<SystemSettingPageVM>
|
public class SystemSettingPageVM : ObservableClass<SystemSettingPageVM>
|
||||||
{
|
{
|
||||||
|
#region SystemSetting
|
||||||
|
|
||||||
private SystemSettingModel _systemSetting;
|
private SystemSettingModel _systemSetting;
|
||||||
public SystemSettingModel SystemSetting
|
public SystemSettingModel SystemSetting
|
||||||
{
|
{
|
||||||
get => _systemSetting;
|
get => _systemSetting;
|
||||||
set => SetProperty(ref _systemSetting, value);
|
set => SetProperty(ref _systemSetting, value);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public SystemSettingPageVM()
|
public SystemSettingPageVM()
|
||||||
{
|
{
|
||||||
@ -25,7 +28,10 @@ public class SystemSettingPageVM : ObservableClass<SystemSettingPageVM>
|
|||||||
|
|
||||||
private void Current_PropertyChangedX(SettingWindowVM sender, PropertyChangedXEventArgs e)
|
private void Current_PropertyChangedX(SettingWindowVM sender, PropertyChangedXEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.PropertyName == nameof(SettingWindowVM.CurrentSetting))
|
if (
|
||||||
|
e.PropertyName == nameof(SettingWindowVM.CurrentSetting)
|
||||||
|
&& sender.CurrentSetting is not null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
SystemSetting = sender.CurrentSetting.SystemSetting;
|
SystemSetting = sender.CurrentSetting.SystemSetting;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using VPet.Solution.ViewModels.SettingEditor;
|
||||||
|
|
||||||
namespace VPet.Solution.Views.SettingEditor;
|
namespace VPet.Solution.Views.SettingEditor;
|
||||||
|
|
||||||
@ -20,8 +21,11 @@ namespace VPet.Solution.Views.SettingEditor;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class CustomizedSettingPage : Page
|
public partial class CustomizedSettingPage : Page
|
||||||
{
|
{
|
||||||
|
public CustomizedSettingPageVM ViewModel => (CustomizedSettingPageVM)DataContext;
|
||||||
|
|
||||||
public CustomizedSettingPage()
|
public CustomizedSettingPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.SetViewModel<CustomizedSettingPageVM>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using VPet.Solution.ViewModels.SettingEditor;
|
||||||
|
|
||||||
namespace VPet.Solution.Views.SettingEditor;
|
namespace VPet.Solution.Views.SettingEditor;
|
||||||
|
|
||||||
@ -20,8 +21,11 @@ namespace VPet.Solution.Views.SettingEditor;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class DiagnosticSettingPage : Page
|
public partial class DiagnosticSettingPage : Page
|
||||||
{
|
{
|
||||||
|
public DiagnosticSettingPageVM ViewModel => (DiagnosticSettingPageVM)DataContext;
|
||||||
|
|
||||||
public DiagnosticSettingPage()
|
public DiagnosticSettingPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.SetViewModel<DiagnosticSettingPageVM>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,8 @@
|
|||||||
ToolTip="{ll:Str '桌宠图形渲染的分辨率,越高图形越清晰\ 但是高分辨率会占用更多内存\ 重启后生效'}"
|
ToolTip="{ll:Str '桌宠图形渲染的分辨率,越高图形越清晰\ 但是高分辨率会占用更多内存\ 重启后生效'}"
|
||||||
Value="{Binding Value, ElementName=Slider_Resolution}" />
|
Value="{Binding Value, ElementName=Slider_Resolution}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid MinHeight="40">
|
<!-- 实际上主题并没有实装 -->
|
||||||
|
<!--<Grid MinHeight="40">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition />
|
<ColumnDefinition />
|
||||||
@ -169,7 +170,7 @@
|
|||||||
IsEnabled="False"
|
IsEnabled="False"
|
||||||
SelectedItem="{Binding GraphicsSetting.Theme}"
|
SelectedItem="{Binding GraphicsSetting.Theme}"
|
||||||
Style="{DynamicResource ComboBox_BaseStyle}" />
|
Style="{DynamicResource ComboBox_BaseStyle}" />
|
||||||
</Grid>
|
</Grid>-->
|
||||||
<Grid MinHeight="40">
|
<Grid MinHeight="40">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
|
@ -24,7 +24,8 @@
|
|||||||
FontSize="16"
|
FontSize="16"
|
||||||
FontWeight="Bold"
|
FontWeight="Bold"
|
||||||
Style="{DynamicResource Label_BaseStyle}" />
|
Style="{DynamicResource Label_BaseStyle}" />
|
||||||
<Grid MinHeight="40">
|
<!-- 存档才有这个设置 -->
|
||||||
|
<!--<Grid MinHeight="40">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition />
|
<ColumnDefinition />
|
||||||
@ -35,7 +36,7 @@
|
|||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Style="{DynamicResource StandardTextBoxStyle}"
|
Style="{DynamicResource StandardTextBoxStyle}"
|
||||||
Text="{Binding InteractiveSetting.PetName}" />
|
Text="{Binding InteractiveSetting.PetName}" />
|
||||||
</Grid>
|
</Grid>-->
|
||||||
<Grid MinHeight="40">
|
<Grid MinHeight="40">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
@ -55,15 +56,10 @@
|
|||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
pu:ComboBoxHelper.Watermark="{ll:Str '当关闭数据计算时\ 桌宠显示的状态'}"
|
pu:ComboBoxHelper.Watermark="{ll:Str '当关闭数据计算时\ 桌宠显示的状态'}"
|
||||||
IsEnabled="{Binding IsChecked, ElementName=Switch_EnablePetState, Converter={StaticResource BoolInverter}}"
|
IsEnabled="{Binding IsChecked, ElementName=Switch_EnablePetState, Converter={StaticResource BoolInverter}}"
|
||||||
SelectedIndex="0"
|
ItemsSource="{Binding InteractiveSetting.ModeTypes}"
|
||||||
SelectedItem="{Binding InteractiveSetting.CalFunState}"
|
SelectedItem="{Binding InteractiveSetting.CalFunState}"
|
||||||
Style="{DynamicResource ComboBox_BaseStyle}"
|
Style="{DynamicResource ComboBox_BaseStyle}"
|
||||||
ToolTip="{ll:Str '当关闭数据计算时\ 桌宠显示的状态'}">
|
ToolTip="{ll:Str '当关闭数据计算时\ 桌宠显示的状态'}" />
|
||||||
<ComboBoxItem Content="Happy" />
|
|
||||||
<ComboBoxItem Content="Nomal" />
|
|
||||||
<ComboBoxItem Content="PoorCondition" />
|
|
||||||
<ComboBoxItem Content="Ill" />
|
|
||||||
</ComboBox>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid MinHeight="40">
|
<Grid MinHeight="40">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@ -376,7 +372,7 @@
|
|||||||
Maximum="100"
|
Maximum="100"
|
||||||
Minimum="{Binding ElementName=VoiceCatchSilder, Path=Value}"
|
Minimum="{Binding ElementName=VoiceCatchSilder, Path=Value}"
|
||||||
SmallChange="1"
|
SmallChange="1"
|
||||||
Style="{DynamicResource StandardSliderStyle}"
|
Style="{DynamicResource Slider_BaseStyle}"
|
||||||
TickFrequency="1"
|
TickFrequency="1"
|
||||||
ToolTip="{ll:Str 当实时播放音量达到该值时运行特殊音乐动作}"
|
ToolTip="{ll:Str 当实时播放音量达到该值时运行特殊音乐动作}"
|
||||||
Value="75" />
|
Value="75" />
|
||||||
|
@ -12,6 +12,7 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using VPet.Solution.ViewModels.SettingEditor;
|
||||||
|
|
||||||
namespace VPet.Solution.Views.SettingEditor;
|
namespace VPet.Solution.Views.SettingEditor;
|
||||||
|
|
||||||
@ -20,8 +21,11 @@ namespace VPet.Solution.Views.SettingEditor;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class InteractiveSettingPage : Page
|
public partial class InteractiveSettingPage : Page
|
||||||
{
|
{
|
||||||
|
public InteractiveSettingPageVM ViewModel => (InteractiveSettingPageVM)DataContext;
|
||||||
|
|
||||||
public InteractiveSettingPage()
|
public InteractiveSettingPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.SetViewModel<InteractiveSettingPageVM>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using VPet.Solution.ViewModels.SettingEditor;
|
||||||
|
|
||||||
namespace VPet.Solution.Views.SettingEditor;
|
namespace VPet.Solution.Views.SettingEditor;
|
||||||
|
|
||||||
@ -20,8 +21,11 @@ namespace VPet.Solution.Views.SettingEditor;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ModSettingPage : Page
|
public partial class ModSettingPage : Page
|
||||||
{
|
{
|
||||||
|
public ModSettingPageVM ViewModel => (ModSettingPageVM)DataContext;
|
||||||
|
|
||||||
public ModSettingPage()
|
public ModSettingPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.SetViewModel<ModSettingPageVM>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,14 +44,22 @@
|
|||||||
<Setter Property="ToolTip" Value="{Binding FilePath}" />
|
<Setter Property="ToolTip" Value="{Binding FilePath}" />
|
||||||
<Setter Property="ContextMenu">
|
<Setter Property="ContextMenu">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ContextMenu>
|
<ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Mode=Self}}">
|
||||||
|
<MenuItem
|
||||||
|
Command="{Binding PlacementTarget.Tag.OpenFileDommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||||
|
CommandParameter="{Binding}"
|
||||||
|
Header="{ll:Str 打开文件}" />
|
||||||
|
<MenuItem
|
||||||
|
Command="{Binding PlacementTarget.Tag.OpenFileInExplorerCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||||
|
CommandParameter="{Binding}"
|
||||||
|
Header="{ll:Str 从资源管理器打开文件}" />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Command="{Binding PlacementTarget.Tag.SaveSettingCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
Command="{Binding PlacementTarget.Tag.SaveSettingCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||||
CommandParameter="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
CommandParameter="{Binding}"
|
||||||
Header="{ll:Str 保存}" />
|
Header="{ll:Str 保存}" />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Command="{Binding PlacementTarget.Tag.ResetSettingCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
Command="{Binding PlacementTarget.Tag.ResetSettingCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||||
CommandParameter="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
CommandParameter="{Binding}"
|
||||||
Header="{ll:Str 重置}" />
|
Header="{ll:Str 重置}" />
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
|
@ -39,44 +39,9 @@
|
|||||||
x:Name="CBAutoSave"
|
x:Name="CBAutoSave"
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
d:SelectionChanged="CBAutoSave_SelectionChanged"
|
d:SelectionChanged="CBAutoSave_SelectionChanged"
|
||||||
SelectedIndex="3"
|
ItemsSource="{Binding SystemSetting.SaveIntervals}"
|
||||||
Style="{DynamicResource ComboBox_BaseStyle}">
|
SelectedItem="{Binding SystemSetting.AutoSaveInterval}"
|
||||||
<!--<ComboBoxItem Content="{ll:Str 关闭自动保存}">
|
Style="{DynamicResource ComboBox_BaseStyle}" />
|
||||||
<ComboBoxItem.Tag>
|
|
||||||
<sys:Int32>-1</sys:Int32>
|
|
||||||
</ComboBoxItem.Tag>
|
|
||||||
</ComboBoxItem>
|
|
||||||
<ComboBoxItem Content="{ll:Str 每2分钟一次}">
|
|
||||||
<ComboBoxItem.Tag>
|
|
||||||
<sys:Int32>2</sys:Int32>
|
|
||||||
</ComboBoxItem.Tag>
|
|
||||||
</ComboBoxItem>
|
|
||||||
<ComboBoxItem Content="{ll:Str 每5分钟一次}">
|
|
||||||
<ComboBoxItem.Tag>
|
|
||||||
<sys:Int32>5</sys:Int32>
|
|
||||||
</ComboBoxItem.Tag>
|
|
||||||
</ComboBoxItem>
|
|
||||||
<ComboBoxItem Content="{ll:Str 每10分钟一次}">
|
|
||||||
<ComboBoxItem.Tag>
|
|
||||||
<sys:Int32>10</sys:Int32>
|
|
||||||
</ComboBoxItem.Tag>
|
|
||||||
</ComboBoxItem>
|
|
||||||
<ComboBoxItem Content="{ll:Str 每20分钟一次}">
|
|
||||||
<ComboBoxItem.Tag>
|
|
||||||
<sys:Int32>20</sys:Int32>
|
|
||||||
</ComboBoxItem.Tag>
|
|
||||||
</ComboBoxItem>
|
|
||||||
<ComboBoxItem Content="{ll:Str 每半小时一次}">
|
|
||||||
<ComboBoxItem.Tag>
|
|
||||||
<sys:Int32>30</sys:Int32>
|
|
||||||
</ComboBoxItem.Tag>
|
|
||||||
</ComboBoxItem>
|
|
||||||
<ComboBoxItem Content="{ll:Str 每小时一次}">
|
|
||||||
<ComboBoxItem.Tag>
|
|
||||||
<sys:Int32>60</sys:Int32>
|
|
||||||
</ComboBoxItem.Tag>
|
|
||||||
</ComboBoxItem>-->
|
|
||||||
</ComboBox>
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Column="3"
|
Grid.Column="3"
|
||||||
Style="{DynamicResource TextBlock_BaseStyle}"
|
Style="{DynamicResource TextBlock_BaseStyle}"
|
||||||
|
@ -12,6 +12,7 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using VPet.Solution.ViewModels.SettingEditor;
|
||||||
|
|
||||||
namespace VPet.Solution.Views.SettingEditor;
|
namespace VPet.Solution.Views.SettingEditor;
|
||||||
|
|
||||||
@ -20,8 +21,11 @@ namespace VPet.Solution.Views.SettingEditor;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class SystemSettingPage : Page
|
public partial class SystemSettingPage : Page
|
||||||
{
|
{
|
||||||
|
public SystemSettingPageVM ViewModel => (SystemSettingPageVM)DataContext;
|
||||||
|
|
||||||
public SystemSettingPage()
|
public SystemSettingPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.SetViewModel<SystemSettingPageVM>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user