Пример #1
0
        private void sign_Click(object sender, EventArgs e)
        {
            // Do username validation
            String username = name.Text.Trim();
            String passwordText = password.Text;

            bool login = false;
            bool isValidUser = false;

            foreach (Player player in players)
            {
                if (player.Name == username)
                {
                    isValidUser = true;
                }
                if (player.Name == username && player.Password == passwordText)
                {
                    login = true;
                    break;
                }
            }

            if (login)
            {
                Hide();
               /* foreach (Player player in players)
                {
                    sendMailMessage(player.Email, "Someone logged in.", "Someone logged in to minecraft pong. Thank you for playing!");
                }*/
                ParameterizedThreadStart starta = new ParameterizedThreadStart(StartGame);
                Thread theThread = new Thread(starta);
                theThread.Start(new object[] { username, icon });
                Application.Exit();
            }
            else if (!login && !isValidUser)
            {
                // Register new user
                RegisterForm register = new RegisterForm(username, passwordText, players, xml);
                if (register.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    MessageBox.Show("Registration canceled.");
                }
                else
                {
                    Guid regKey = Guid.NewGuid();
                    sendMailMessage(register.emailtxtBox.Text, "Confirm Minecraft Pong Registration", "Please confirm your minecraft pong registration as the user '"+register.usernameTextBox.Text+"' by entering this code:<br/><br/>" + regKey.ToString()+"<br/><br/>Thank you for registering!");
                    string inputString = null;
                    ConfirmRegForm confirm = new ConfirmRegForm(regKey);
                    confirm.ShowDialog();
                    Hide();
                    ParameterizedThreadStart starta = new ParameterizedThreadStart(StartGame);
                    Thread theThread = new Thread(starta);
                    theThread.Start(new object[] { username, icon });
                    Application.Exit();
                }
            }
            else
            {
                MessageBox.Show("Invalid Login");
            }
        }
Пример #2
0
        private void sign_Click(object sender, EventArgs e)
        {
            // Do username validation
            String username     = name.Text.Trim();
            String passwordText = password.Text;

            bool login       = false;
            bool isValidUser = false;

            foreach (Player player in players)
            {
                if (player.Name == username)
                {
                    isValidUser = true;
                }
                if (player.Name == username && player.Password == passwordText)
                {
                    login = true;
                    break;
                }
            }

            if (login)
            {
                Hide();

                /* foreach (Player player in players)
                 * {
                 *   sendMailMessage(player.Email, "Someone logged in.", "Someone logged in to minecraft pong. Thank you for playing!");
                 * }*/
                ParameterizedThreadStart starta = new ParameterizedThreadStart(StartGame);
                Thread theThread = new Thread(starta);
                theThread.Start(new object[] { username, icon });
                Application.Exit();
            }
            else if (!login && !isValidUser)
            {
                // Register new user
                RegisterForm register = new RegisterForm(username, passwordText, players, xml);
                if (register.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    MessageBox.Show("Registration canceled.");
                }
                else
                {
                    Guid regKey = Guid.NewGuid();
                    sendMailMessage(register.emailtxtBox.Text, "Confirm Minecraft Pong Registration", "Please confirm your minecraft pong registration as the user '" + register.usernameTextBox.Text + "' by entering this code:<br/><br/>" + regKey.ToString() + "<br/><br/>Thank you for registering!");
                    string         inputString = null;
                    ConfirmRegForm confirm     = new ConfirmRegForm(regKey);
                    confirm.ShowDialog();
                    Hide();
                    ParameterizedThreadStart starta = new ParameterizedThreadStart(StartGame);
                    Thread theThread = new Thread(starta);
                    theThread.Start(new object[] { username, icon });
                    Application.Exit();
                }
            }
            else
            {
                MessageBox.Show("Invalid Login");
            }
        }