Files
Shrlalgo.RvKits/ShrlAlgoToolkit.RevitAddins/RvCommon/AutoSaveViewModel.cs

41 lines
1.1 KiB
C#
Raw Normal View History


2024-09-22 11:05:41 +08:00
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace ShrlAlgo.RvKits.RvCommon;
2024-09-22 11:05:41 +08:00
public partial class AutoSaveViewModel : ObservableValidator
{
public AutoSaveViewModel()
{
IsActiveAutoSave = Properties.Settings.Default.IsActiveAutoSave;
IntervalTime = Properties.Settings.Default.AutoSaveIntervalTime;
}
2024-09-22 11:05:41 +08:00
[ObservableProperty]
private bool isActiveAutoSave;
//partial void OnIsActiveAutoSaveChanged(bool value)
//{
// throw new NotImplementedException();
//}
2024-09-22 11:05:41 +08:00
[Required(ErrorMessage = "不可为空")]
[DefaultValue(10)]
2024-09-22 11:05:41 +08:00
[NotifyDataErrorInfo]
[Range(1, 30, ErrorMessage = "输入值应在1~30分钟之间")]
2024-09-22 11:05:41 +08:00
[ObservableProperty]
private int intervalTime;
[RelayCommand]
private void Closing()
{
Properties.Settings.Default.IsActiveAutoSave = IsActiveAutoSave;
Properties.Settings.Default.AutoSaveIntervalTime = IntervalTime;
Properties.Settings.Default.Save();
Variables.AutoSaveTimer.Interval = IntervalTime * 60 * 1000;
}
2024-09-22 11:05:41 +08:00
}