-
Notifications
You must be signed in to change notification settings - Fork 809
Expand file tree
/
Copy pathSettingsUpdateViewModel.cs
More file actions
94 lines (70 loc) · 2.41 KB
/
SettingsUpdateViewModel.cs
File metadata and controls
94 lines (70 loc) · 2.41 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using NETworkManager.Settings;
namespace NETworkManager.ViewModels;
public class SettingsUpdateViewModel : ViewModelBase
{
#region Variables
private readonly bool _isLoading;
private bool _checkForUpdatesAtStartup;
public bool CheckForUpdatesAtStartup
{
get => _checkForUpdatesAtStartup;
set
{
if (value == _checkForUpdatesAtStartup)
return;
if (!_isLoading)
SettingsManager.Current.Update_CheckForUpdatesAtStartup = value;
_checkForUpdatesAtStartup = value;
OnPropertyChanged();
}
}
/// <summary>
/// Gets whether the "Check for updates at startup" setting is managed by system-wide policy.
/// </summary>
public bool IsUpdateCheckManagedByPolicy => PolicyManager.Current?.Update_CheckForUpdatesAtStartup.HasValue == true;
private bool _checkForPreReleases;
public bool CheckForPreReleases
{
get => _checkForPreReleases;
set
{
if (value == _checkForPreReleases)
return;
if (!_isLoading)
SettingsManager.Current.Update_CheckForPreReleases = value;
_checkForPreReleases = value;
OnPropertyChanged();
}
}
private bool _enableExperimentalFeatures;
public bool EnableExperimentalFeatures
{
get => _enableExperimentalFeatures;
set
{
if (value == _enableExperimentalFeatures)
return;
if (!_isLoading)
SettingsManager.Current.Experimental_EnableExperimentalFeatures = value;
_enableExperimentalFeatures = value;
OnPropertyChanged();
}
}
#endregion
#region Constructor, LoadSettings
public SettingsUpdateViewModel()
{
_isLoading = true;
LoadSettings();
_isLoading = false;
}
private void LoadSettings()
{
// If policy is set, show the policy value; otherwise show the user's setting
CheckForUpdatesAtStartup = PolicyManager.Current?.Update_CheckForUpdatesAtStartup
?? SettingsManager.Current.Update_CheckForUpdatesAtStartup;
CheckForPreReleases = SettingsManager.Current.Update_CheckForPreReleases;
EnableExperimentalFeatures = SettingsManager.Current.Experimental_EnableExperimentalFeatures;
}
#endregion
}