添加项目文件。
This commit is contained in:
33
Sai.RvKits/RvCommon/AutoSaveViewModel.cs
Normal file
33
Sai.RvKits/RvCommon/AutoSaveViewModel.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace Sai.RvKits.RvCommon;
|
||||
|
||||
public partial class AutoSaveViewModel : ObservableValidator
|
||||
{
|
||||
public AutoSaveViewModel()
|
||||
{
|
||||
IsActiveAutoSave = Properties.Settings.Default.IsActiveAutoSave;
|
||||
IntervalTime = Properties.Settings.Default.AutoSaveIntervalTime;
|
||||
}
|
||||
[ObservableProperty]
|
||||
private bool isActiveAutoSave;
|
||||
|
||||
[Required(ErrorMessage = "不可为空")]
|
||||
[DefaultValue(15)]
|
||||
[NotifyDataErrorInfo]
|
||||
[Range(5, 30, ErrorMessage = "输入值应在5~30分钟之间")]
|
||||
[ObservableProperty]
|
||||
private int intervalTime;
|
||||
|
||||
|
||||
[RelayCommand]
|
||||
private void Closing()
|
||||
{
|
||||
Properties.Settings.Default.IsActiveAutoSave = IsActiveAutoSave;
|
||||
Properties.Settings.Default.AutoSaveIntervalTime = IntervalTime;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user