-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathModPresenter.cs
More file actions
138 lines (125 loc) · 4.79 KB
/
Copy pathModPresenter.cs
File metadata and controls
138 lines (125 loc) · 4.79 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System;
using System.ComponentModel;
using System.Globalization;
using System.Text;
namespace PSO2ModManager {
public class ModPresenter : INotifyPropertyChanged {
public string Id {
get {
return id;
}
private set {
id = value;
NotifyPropertyChanged ("Id");
NotifyPropertyChanged ("CanViewOnline");
}
}
public string Thumbnail {
get {
return thumbnail;
}
private set {
thumbnail = value;
NotifyPropertyChanged ("Thumbnail");
}
}
public string Description {
get {
return description;
}
private set {
description = value;
NotifyPropertyChanged ("Description");
}
}
public string Name {
get {
return name;
}
private set {
name = value;
NotifyPropertyChanged ("Name");
}
}
public bool CanDelete {
get {
return canDelete;
}
private set {
canDelete = value;
NotifyPropertyChanged ("CanDelete");
}
}
public bool CanUpdate {
get {
return canUpdate;
}
private set {
canUpdate = value;
NotifyPropertyChanged ("CanUpdate");
}
}
public bool CanInstallUninstall {
get {
return canInstallUninstall;
}
private set {
canInstallUninstall = value;
NotifyPropertyChanged ("CanInstallUninstall");
}
}
public String InstallUpdateBtnValue {
get {
return installUpdateBtnValue;
}
private set {
installUpdateBtnValue = value;
NotifyPropertyChanged ("InstallUpdateBtnValue");
}
}
public bool CanViewOnline {
get {
return String.IsNullOrEmpty(id);
}
}
private string id = string.Empty;
private string thumbnail = string.Empty;
private string description = string.Empty;
private string name = string.Empty;
private bool canDelete = false;
private bool canUpdate = false;
private bool canInstallUninstall = false;
private bool installed = false;
private string installUpdateBtnValue = "Install";
protected void NotifyPropertyChanged (String propertyName) {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public event PropertyChangedEventHandler PropertyChanged;
public void Setup (Mod m, bool mInstalled) {
if (m == null) {
installed = false;
Id = string.Empty;
Thumbnail = string.Empty;
Description = string.Empty;
InstallUpdateBtnValue = Helpers._ ("ModTab.Button.Install");
CanInstallUninstall = false;
CanUpdate = false;
CanDelete = false;
} else {
installed = mInstalled;
Id = m.Id;
Thumbnail = AppDomain.CurrentDomain.BaseDirectory + "\\thumbnails\\" + m.Thumbnail;
//Description = '<!DOCTYPE html><html><head><meta charset='UTF-8' /><link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.css\" /></head><style>.sharedaddy{display:none;}</style><body>" + String.Format("<p><strong>{0} by {1}</strong></p><p>{2}</p></body></html>", m.Name, m.Author, m.Description);
Description = "data:text/html;base64," + Convert.ToBase64String(Encoding.UTF8.GetBytes("<!DOCTYPE html><html><head><meta charset='UTF-8' /><style>html {color:#222; font-size:12px; line-height: 1.4;font-family: -apple-system, BlinkMacSystemFont, \"Helvetica Neue\", \"Segoe UI\", \"Yu Gothic\", YuGothic, sans-serif;}body{margin: 0;} h1{font-size:2em; margin:0;} .sharedaddy{display:none;}</style></head><body>" + String.Format(CultureInfo.InvariantCulture, "<h1>{0} <small>by {1}</small></h1><p>{2}</p></body></html>", m.Name, m.Author, m.Description)));
if (mInstalled) {
InstallUpdateBtnValue = Helpers._ ("ModTab.Button.Uninstall");
} else {
InstallUpdateBtnValue = Helpers._ ("ModTab.Button.Install");
}
CanInstallUninstall = true;
CanUpdate = m.UpdateAvailable;
CanDelete = true;
}
}
}
}