整理代码
This commit is contained in:
41
ShrlAlgoToolkit.RevitAddins/RvCommon/AutoSaveViewModel.cs
Normal file
41
ShrlAlgoToolkit.RevitAddins/RvCommon/AutoSaveViewModel.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ShrlAlgo.RvKits.RvCommon;
|
||||
|
||||
public partial class AutoSaveViewModel : ObservableValidator
|
||||
{
|
||||
public AutoSaveViewModel()
|
||||
{
|
||||
IsActiveAutoSave = Properties.Settings.Default.IsActiveAutoSave;
|
||||
IntervalTime = Properties.Settings.Default.AutoSaveIntervalTime;
|
||||
}
|
||||
[ObservableProperty]
|
||||
private bool isActiveAutoSave;
|
||||
|
||||
//partial void OnIsActiveAutoSaveChanged(bool value)
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
//}
|
||||
|
||||
[Required(ErrorMessage = "不可为空")]
|
||||
[DefaultValue(10)]
|
||||
[NotifyDataErrorInfo]
|
||||
[Range(1, 30, ErrorMessage = "输入值应在1~30分钟之间")]
|
||||
[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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user