예제 #1
0
        public void Initialize(GameForm gameForm)
        {
            context.Initialize(layout);
            referee.Initialize(context, pieceFactory);

            board.Initialize(gameForm.ClientSize.Height - gameForm.mainMenu.Height, pieceFactory, context, new Brush[2] {
                Brushes.SandyBrown, Brushes.SaddleBrown
            });

            board.Invalidate();
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            bool acceptedRequest = true;

            mail     = txtMail.Text;
            password = txtPassword.Tag.ToString();

            txtPassword.BackColor = Color.White;
            txtMail.BackColor     = Color.White;

            if (password == "")
            {
                lblError.Text         = "You must enter a password";
                txtPassword.BackColor = Color.Red;
                acceptedRequest       = false;
            }
            if (!IsValidEmail(mail))
            {
                lblError.Text     = "Your mail address is not valid";
                txtMail.BackColor = Color.Red;
                acceptedRequest   = false;
            }
            if (mail == "")
            {
                lblError.Text     = "You must enter a mail address";
                txtMail.BackColor = Color.Red;
                acceptedRequest   = false;
            }

            if (acceptedRequest)
            {
                if (Login.LoginUser(mail, password))
                {
                    GameForm newGameForm = new GameForm(mail);
                    newGameForm.ShowDialog();
                }
                else
                {
                    this.Hide();
                    LoginForm newLoginForm = new LoginForm();
                    newLoginForm.ShowDialog();
                }
            }
            else
            {
                lblError.Visible = true;
            }
        }
예제 #3
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            bool acceptedRequest = true;

            mail            = txtMail.Text;
            pseudo          = txtPseudo.Text;
            password        = txtPassword.Text;
            passwordComfirm = txtComfirmPassword.Text;

            if (password.Length < 6)
            {
                lblError.Text   = "You password is too weak";
                acceptedRequest = false;
            }
            if (password != passwordComfirm)
            {
                lblError.Text   = "You passwords does not match";
                acceptedRequest = false;
            }
            if (password == "")
            {
                lblError.Text   = "You must enter a password";
                acceptedRequest = false;
            }
            if (passwordComfirm == "")
            {
                lblError.Text   = "You must a password AND a comfirm password";
                acceptedRequest = false;
            }
            if (pseudo == "")
            {
                lblError.Text   = "You must enter a pseudo";
                acceptedRequest = false;
            }
            if (!IsValidEmail(mail))
            {
                lblError.Text   = "Your mail address is not valid";
                acceptedRequest = false;
            }
            if (mail == "")
            {
                lblError.Text   = "You must enter a mail address";
                acceptedRequest = false;
            }

            if (acceptedRequest == true)
            {
                if (Register.CreateUser(mail, pseudo, password))
                {
                    this.Hide();
                    GameForm newGameForm = new GameForm(mail);
                    newGameForm.ShowDialog();
                }
                else
                {
                    this.Hide();
                    RegisterForm newRegisterForm = new RegisterForm();
                    newRegisterForm.ShowDialog();
                }
            }
            else
            {
                lblError.Visible = true;
            }
        }