forked from bittiez/SimpleFileUpdater
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainViewModel.cs
More file actions
71 lines (60 loc) · 1.81 KB
/
MainViewModel.cs
File metadata and controls
71 lines (60 loc) · 1.81 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
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace FileUpdaterClient;
public class MainViewModel : INotifyPropertyChanged
{
private string _title = Settings.Title;
private string _subTitle = Settings.Subtitle;
private string _titleColor = Settings.TitleColor;
private string _errorMessage = string.Empty;
private string _subtitleColor = Settings.SubtitleColor;
private double _progress;
private string _progressText = "Checking for updates..";
public event PropertyChangedEventHandler? PropertyChanged;
public string TitleColor
{
get => _titleColor;
set => SetField(ref _titleColor, value);
}
public string Title
{
get => _title;
set => SetField(ref _title, value);
}
public string SubtitleColor
{
get => _subtitleColor;
set => SetField(ref _subtitleColor, value);
}
public string Subtitle
{
get => _subTitle;
set => SetField(ref _subTitle, value);
}
public string ErrorMessage
{
get => _errorMessage;
set => SetField(ref _errorMessage, value);
}
public double Progress
{
get => _progress;
set => SetField(ref _progress, value);
}
public string ProgressText
{
get => _progressText;
set => SetField(ref _progressText, value);
}
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
field = value;
OnPropertyChanged(propertyName);
return true;
}
}