-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainUI.cs
205 lines (181 loc) · 5.72 KB
/
MainUI.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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*
* Creado por SharpDevelop.
* Usuario: GNR092
* Fecha: 06/02/2017
* Hora: 08:04 p.m.
*
* Para cambiar esta plantilla use Herramientas | Opciones | Codificación | Editar Encabezados Estándar
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Windows.Forms;
using System.Reflection;
using System.Threading;
namespace SecureGameGuard
{
/// <summary>
/// SecureGameGuard.
///
/// Copyright (C) GNR092, 2016-2017.
/// </summary>
public partial class MainUI : Form
{
private Configs cnf = new Configs();
private string DownloadString = null;
private List<string> lst0 = null, lst1 = null;
private bool error = false;
private bool Down = false;
private string ver = Assembly.GetExecutingAssembly().GetName().Version.ToString();
public MainUI()
{
AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs args)
{
string dllName = args.Name.Contains(",") ? args.Name.Substring(0, args.Name.IndexOf(',')) : args.Name.Replace(".dll", "");
dllName = dllName.Replace(".", "_");
if (dllName.EndsWith("_resources")) return null;
System.Resources.ResourceManager rm = new System.Resources.ResourceManager(GetType().Namespace + ".Properties.Resources", Assembly.GetExecutingAssembly());
byte[] bytes = (byte[])rm.GetObject(dllName);
return Assembly.Load(bytes);
};
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
SecureGame.notify = bf_gmg;
bf_gmg.ShowBalloonTip(2000, "Notificacion", "Iniciando SecureGameGuard V" + ver, ToolTipIcon.Info);
this.Show();
new Thread(() =>
{
Invoke(new Action(() => this.Show()));
Invoke(new Action(() => lb_version.Text = "Version:" + ver));
var url = new Uri("https://raw.githubusercontent.com/GNR092/LauncherUpdaterPlugin/master/AutoUpdater/GameText.txt");
var url2 = new Uri("http://192.168.20.197/GameText.txt");
using (WebClient cli = new WebClient())
{
cli.DownloadProgressChanged += cli_DownloadProgressChanged;
cli.DownloadStringCompleted += cli_DownloadStringCompleted;
cnf.load();
try
{
cli.DownloadStringAsync(url);
while (!Down)
{
Invoke(new Action(() => Thread.Sleep(500)));
}
}
catch (Exception)
{
error = true;
}
Thread.Sleep(1000);
check();
Invoke(new Action(() => this.Hide()));
}
})
{ IsBackground = false }.Start();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void cli_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
Invoke(new Action(() => progressBarUI1.Value = 0));
Invoke(new Action(() => progressBarUI1.BackColor = Color.DarkBlue));
Invoke(new Action(() => progressBarUI1.ForeColor = Color.Blue));
try
{
if (e.Result != null)
{
DownloadString = e.Result;
Down = true;
}
else
{
Down = true;
error = true;
}
}
catch
{
Down = true;
error = true;
}
}
void cli_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
Invoke(new Action(() => progressBarUI1.Value = e.ProgressPercentage));
}
void check()
{
bf_gmg.ShowBalloonTip(1000, "Notificacion", "Preparando componentes", ToolTipIcon.Info);
Invoke(new Action(() => progressBarUI1.Value = 25));
if (!error)
{
if (cnf.List == null)
{
DownloadString = DownloadString.Replace("\r\n", "");
cnf.List = GameGuard.Encrypt(DownloadString);
cnf.save();
}
else
DownloadString = DownloadString.Replace("\r\n", "");
Invoke(new Action(() => progressBarUI1.Value = 50));
lst0 = DownloadString.Split(char.Parse(",")).ToList();//lista
lst1 = GameGuard.Decrypt(cnf.List).Split(char.Parse(",")).ToList();//lista desencriptada
Invoke(new Action(() => progressBarUI1.Value = 75));
if (lst0[0] != lst1[0])
{
cnf.List = GameGuard.Encrypt(DownloadString);
cnf.save();
}
}
Invoke(new Action(() => progressBarUI1.Value = 100));
if (!error)
{
GameGuard.StartSecureGame(lst0);
}
else if (error && cnf.List == null)
{
DList Defaultlist = new DList();
GameGuard.StartSecureGame(Defaultlist.Default, error);
}
else if (error && cnf.List != null)
{
DList Defaultlist = new DList();
GameGuard.StartSecureGame(Defaultlist.Default, error);
}
Thread.Sleep(1000);
}
private void MainUI_KeyDown(object sender, KeyEventArgs e)
{
if (e.Alt && e.KeyCode == Keys.F4)
{
e.Handled = true;
}
}
private void bf_gmg_Click(object sender, EventArgs e)
{
var SuperMsgBox = new SS();
SuperMsgBox.AgregarTitulo("About");
SuperMsgBox.AgregarMensaje("''"+Assembly.GetExecutingAssembly().GetName().Name+"''" +"\nVersion: "+ver+" by GNR092");
SuperMsgBox.AgregarBoton("Donar");
SuperMsgBox.AgregarBoton("Facebook");
SuperMsgBox.AgregarBoton("Salir");
string cmd = SuperMsgBox.Mostrar();
switch (cmd)
{
case "Donar":
System.Diagnostics.Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8MJZJBPQHZJG6");
break;
case "Facebook":
System.Diagnostics.Process.Start("http://fb.me/GNR092");
break;
default:
break;
}
}
}
}