This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
FrmRegister.cs
146 lines (128 loc) · 4.85 KB
/
FrmRegister.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
using Newtonsoft.Json.Linq;
using Salaros.Configuration;
using System;
using System.Drawing;
using System.IO;
using System.Net;
using System.Text;
using System.Windows.Forms;
namespace MythicalLauncher
{
public partial class FrmRegister : Form
{
public FrmRegister()
{
InitializeComponent();
}
private string appConfig = Application.StartupPath + @"\settings.ini";
void Alert(string msg, FrmAlert.enmType type)
{
FrmAlert frm = new FrmAlert();
frm.showAlert(msg, type);
}
public static JObject GetDataFromUrl(string url)
{
using (var client = new WebClient())
{
string jsonText = client.DownloadString(url);
JObject jsonObject = JObject.Parse(jsonText);
return jsonObject;
}
}
private void FrmRegister_Load(object sender, EventArgs e)
{
LoadSettings();
DisplayImage();
}
private void DisplayImage()
{
using (WebClient webClient = new WebClient())
{
byte[] imageBytes = webClient.DownloadData(FrmLoading.applogo);
using (MemoryStream memoryStream = new MemoryStream(imageBytes))
{
pictureBox1.Image = Image.FromStream(memoryStream);
}
}
using (WebClient webClient = new WebClient())
{
byte[] iconBytes = webClient.DownloadData(FrmLoading.applogo);
using (MemoryStream ms = new MemoryStream(iconBytes))
{
Bitmap bitmap = (Bitmap)Image.FromStream(ms);
this.Icon = Icon.FromHandle(bitmap.GetHicon());
}
}
using (WebClient backWebClient = new WebClient())
{
byte[] bgimageBytes = backWebClient.DownloadData(FrmLoading.appbg);
using (MemoryStream bgmemoryStream = new MemoryStream(bgimageBytes))
{
this.BackgroundImage = Image.FromStream(bgmemoryStream);
}
}
registerbutton.FillColor = ColorTranslator.FromHtml(FrmLoading.appcolour);
registerbutton.FillColor2 = ColorTranslator.FromHtml(FrmLoading.appcolour);
}
void LoadSettings()
{
lbllchname.Text = FrmLoading.appname;
}
private void pictureBox2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void registerbutton_Click_1(object sender, EventArgs e)
{
if (username.Text == "" || password.Text == "" || email.Text == "")
{
Alert("Please fill in your information", FrmAlert.enmType.Error);
}
else
{
var appcfg = new ConfigParser(appConfig);
var r_key = appcfg.GetValue("RemoteLauncher", "key");
string webURL = r_key + "/api/mythicallauncher/auth/register.php?email=" + email.Text + "&usrn=" + username.Text + "&pass=" + password.Text;
WebClient wc = new WebClient();
wc.Headers.Add("user-agent", "Only a Header!");
byte[] rawByteArray = wc.DownloadData(webURL);
string webContent = Encoding.UTF8.GetString(rawByteArray);
if (webContent.ToUpper().Contains("USERNAME_EXISTS"))
Alert("Username already exists", FrmAlert.enmType.Warning);
else if (webContent.ToUpper().Contains("EMAIL_EXISTS"))
Alert("Email already exists", FrmAlert.enmType.Warning);
else if (webContent.ToUpper().Contains("SUCCES_REGISTER"))
Alert("Registered", FrmAlert.enmType.Succes);
FrmLogin x = new FrmLogin();
x.Show();
this.Hide();
}
}
private void pictureBox3_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
private void label4_Click_1(object sender, EventArgs e)
{
FrmLogin x = new FrmLogin();
x.Show();
this.Hide();
}
private void lblweb_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(FrmLoading.appweb);
}
private void lbldiscord_Click_1(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(FrmLoading.appdiscord);
}
private void lblstore_Click_1(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(FrmLoading.appstore);
}
private void lblvote_Click_1(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(FrmLoading.appvote);
}
}
}