-
-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathGameViewViewModel.cs
More file actions
92 lines (87 loc) · 3.09 KB
/
GameViewViewModel.cs
File metadata and controls
92 lines (87 loc) · 3.09 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
using gamevault.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;
namespace gamevault.ViewModels
{
internal class GameViewViewModel : ViewModelBase
{
#region PrivateMembers
private Game? game { get; set; }
private Progress? currentUserProgress { get; set; }
private Progress[]? userProgresses { get; set; }
private Dictionary<string, string> gameStates { get; set; }
private bool isInstalled { get; set; }
private bool? isDownloaded { get; set; }
private string? descriptionMarkdown { get; set; }
private string? notesMarkdown { get; set; }
private string cloudSaveMatchTitle { get; set; }
#endregion
public Game? Game
{
get { return game; }
set { game = value; OnPropertyChanged(); }
}
public Progress? CurrentUserProgress
{
get { return currentUserProgress; }
set { currentUserProgress = value; OnPropertyChanged(); }
}
public Progress[]? UserProgresses
{
get { return userProgresses; }
set { userProgresses = value; OnPropertyChanged(); }
}
public Dictionary<string, string>? GameStates
{
get => gameStates ?? (gameStates = Enum.GetValues(typeof(State))
.Cast<State>()
.ToDictionary(state => GetEnumDescription(state), state => state.ToString()));
set { gameStates = value; OnPropertyChanged(); }
}
private static string GetEnumDescription(State value) =>
(Attribute.GetCustomAttribute(value.GetType().GetField(value.ToString()), typeof(DescriptionAttribute)) is DescriptionAttribute attribute) ? attribute.Description : value.ToString();
public bool IsInstalled
{
get { return isInstalled; }
set { isInstalled = value; OnPropertyChanged(); }
}
public bool? IsDownloaded
{
get { return isDownloaded; }
set { isDownloaded = value; OnPropertyChanged(); }
}
public string? DescriptionMarkdown
{
get { return descriptionMarkdown; }
set
{
descriptionMarkdown = value?
.Replace("\t", "\u00A0\u00A0\u00A0\u00A0")
.Replace(" ", "\u00A0\u00A0\u00A0\u00A0");
OnPropertyChanged();
}
}
public string? NotesMarkdown
{
get { return notesMarkdown; }
set
{
notesMarkdown = value?
.Replace("\t", "\u00A0\u00A0\u00A0\u00A0")
.Replace(" ", "\u00A0\u00A0\u00A0\u00A0");
OnPropertyChanged();
}
}
public string CloudSaveMatchTitle
{
get { return cloudSaveMatchTitle; }
set { cloudSaveMatchTitle = value; OnPropertyChanged(); }
}
}
}