using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Diagnostics; namespace GamerServices { public partial class FormLogin : Form { public FormMain Main; public FormLogin() { InitializeComponent(); bool hasXNA = true; try { MrAG.Gamerservices.GetUser(); } catch { hasXNA = false; } if (!hasXNA) { if (MessageBox.Show("Missing XNA Framework redistributables shal we download it for you?", "Missing XNA", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { FormFileDownloader ffd = new FormFileDownloader(); ffd.URL = "http://" + "gs.mrag.nl/download.php?gid=-1&file=XNA_4.0_redist.msi"; ffd.FilePath = "XNA_4.0_redist.msi"; ffd.AutoExec = true; ffd.Show(); ffd.StartDownload(); timer1.Tag = ffd; } timer1.Enabled = true; return; } this.Main = new FormMain(this); this.textUsername.Focus(); if (Main.Settings_Username.Length > 0) { this.textUsername.Text = Main.Settings_Username; } if (Main.Settings_Password.Length > 0) { checkRememberMe.Checked = true; this.textPassword.Text = Main.Settings_Password; } if (this.textPassword.Text.Length > 0){ this.Enabled = false; conn(); if (Main.Connected) { this.Main.Networker.Login(this.textUsername.Text, this.textPassword.Text); } else { this.textPassword.Text = ""; } } } public FormLogin(FormMain MainForm) { this.Main = MainForm; InitializeComponent(); this.textUsername.Focus(); if (Main.Settings_Username.Length > 0) { this.textUsername.Text = Main.Settings_Username; } if (Main.Settings_Password.Length > 0) { checkRememberMe.Checked = true; this.textPassword.Text = Main.Settings_Password; } if (this.textPassword.Text.Length > 0){ this.Enabled = false; conn(); if (Main.Connected) { this.Main.Networker.Login(this.textUsername.Text, this.textPassword.Text); } else { this.textPassword.Text = ""; } } } private void button2_Click(object sender, EventArgs e) { System.Diagnostics.Process.GetCurrentProcess().Kill(); } private void button3_Click(object sender, EventArgs e) { Process.Start("http://" + "gs.mrag.nl/signup"); } private void button1_Click(object sender, EventArgs e) { this.Enabled = false; conn(); if (Main.Connected) { this.textPassword.Text = this.Main.Networker.MD5(this.textPassword.Text + "MrAG.Gameservices" + "http://" + "gs.mrag.nl/"); this.Main.Networker.Login(this.textUsername.Text, this.textPassword.Text); } else { Enabled = true; } } public bool connected = false; private void conn() { if (connected) return; connected = true; if (!this.Main.Networker.Initialize()) { Main.Error("Can't connect to the GamerServices server! The server might be offline. Check http://" + "gs.mrag.nl/status for the server status. Otherwise, check your internet connection."); Enabled = true; connected = false; } } private void textUsername_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { textPassword.Focus(); } } private void textPassword_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { button1_Click(null, null); } } private void timer1_Tick(object sender, EventArgs e) { if (timer1.Tag == null){ this.Close(); Application.Exit(); return; } this.Hide(); if ((timer1.Tag as FormFileDownloader).Completed) { this.Close(); Application.Exit(); } } } }