forked from jeremybytes/SlideShow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettingsViewModel.cs
54 lines (41 loc) · 1.2 KB
/
SettingsViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Windows;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
namespace SlideShow;
public partial class SettingsViewModel : ObservableObject
{
public event EventHandler? SettingsClosed;
public void Load()
{
AppSettings.Load();
Interval = AppSettings.Instance.Interval;
Sort = AppSettings.Instance.Sort;
Shuffle = AppSettings.Instance.Shuffle;
ShowInfo = AppSettings.Instance.ShowInfo;
}
public void Save()
{
AppSettings.Instance.Interval = Interval;
AppSettings.Instance.Sort = Sort;
AppSettings.Instance.Shuffle = Shuffle;
AppSettings.Instance.ShowInfo = ShowInfo;
AppSettings.Save();
}
[ObservableProperty]
private double interval = 6;
[ObservableProperty]
private Visibility visible = Visibility.Collapsed;
[ObservableProperty]
private bool sort = true;
[ObservableProperty]
private bool shuffle = false;
[ObservableProperty]
private bool showInfo = true;
[RelayCommand]
private void OK()
{
Save();
Visible = Visibility.Collapsed;
SettingsClosed?.Invoke(this, EventArgs.Empty);
}
}