调整代码
This commit is contained in:
38
ShrlAlgoToolkit.RevitAddins/General/AutoSaveViewModel.cs
Normal file
38
ShrlAlgoToolkit.RevitAddins/General/AutoSaveViewModel.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace ShrlAlgoToolkit.RevitAddins.RvCommon;
|
||||
|
||||
public partial class AutoSaveViewModel : ObservableValidator
|
||||
{
|
||||
public AutoSaveViewModel()
|
||||
{
|
||||
IsActiveAutoSave = RevitAddins.Properties.Settings.Default.IsActiveAutoSave;
|
||||
IntervalTime = RevitAddins.Properties.Settings.Default.AutoSaveIntervalTime;
|
||||
}
|
||||
[ObservableProperty]
|
||||
public partial bool IsActiveAutoSave { get; set; }
|
||||
|
||||
//partial void OnIsActiveAutoSaveChanged(bool value)
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
//}
|
||||
|
||||
[Required(ErrorMessage = "不可为空")]
|
||||
[field: DefaultValue(10)]
|
||||
[NotifyDataErrorInfo]
|
||||
[Range(1, 30, ErrorMessage = "输入值应在1~30分钟之间")]
|
||||
[ObservableProperty]
|
||||
public partial int IntervalTime { get; set; }
|
||||
|
||||
[RelayCommand]
|
||||
private void Closing()
|
||||
{
|
||||
RevitAddins.Properties.Settings.Default.IsActiveAutoSave = IsActiveAutoSave;
|
||||
RevitAddins.Properties.Settings.Default.AutoSaveIntervalTime = IntervalTime;
|
||||
RevitAddins.Properties.Settings.Default.Save();
|
||||
Variables.AutoSaveTimer.Interval = IntervalTime * 60 * 1000;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user