Exemple #1
0
        private async void Label2_Click(object sender, EventArgs e)
        {
            //Sg.LoginForm.Hide();
            //Sg.LoginForm.ShowInTaskbar = true;
            var form2 = new Signup {
                ShowInTaskbar = false
            };
            var result = form2.ShowDialog();

            if (result == DialogResult.OK)
            {
                Sg.LoginForm.Show();
                form2.Close();
                try
                {
                    txtUser.InputText           = Sg.User.Username;
                    txtPass.InputText           = Sg.User.Password;
                    txtPass.TextInput.ForeColor = Color.Black;
                    txtUser.TextInput.ForeColor = Color.Black;
                }
                catch { }
            }
            else
            {
                if (Sg.IsValidUser)
                {
                    Sg.User.IsOnline = false;
                    await Sg.UpdateUser();
                }
                Sg.LoginForm.Close();
            }
        }
Exemple #2
0
 private async void Close_Click(object sender, EventArgs e)
 {
     if (Sg.IsValidUser)
     {
         Sg.User.IsOnline = false;
         await Sg.UpdateUser();
     }
     Sg.LoginForm.Close();
 }
Exemple #3
0
        private async void BtnLogin_Click(object sender, EventArgs e)
        {
            if ((string.IsNullOrEmpty(txtUser.InputText) || string.Equals(txtUser.InputText, txtUser.Hint)) && (string.IsNullOrEmpty(txtPass.InputText) || string.Equals(txtPass.InputText, txtPass.Hint)))
            {
                new CustomMessageBox().Show("Por favor digite algo válido", "Usuario e/ou Senha", Sg.AccentColor);
            }
            else if (string.IsNullOrEmpty(txtUser.InputText) || string.Equals(txtUser.InputText, txtUser.Hint))
            {
                new CustomMessageBox().Show("Por favor digite algo válido", "Usuário Invalido", Sg.AccentColor);
            }
            else if (string.IsNullOrEmpty(txtPass.InputText) || string.Equals(txtPass.InputText, txtPass.Hint))
            {
                new CustomMessageBox().Show("Por favor digite algo válido", "Senha Invalida", Sg.AccentColor);
            }
            else
            {
                var user = await Sg.GetUserAsync(txtUser.InputText);

                if (user != null)
                {
                    if (string.Equals(user.Password, txtPass.InputText))
                    {
                        user.IsOnline = true;
                        Sg.User       = user;
                        //new Thread(() => { new CustomMessageBox().Show("Senha incorreta", "Erro de Login", Sg.AccentColor); }).te;
                        await Sg.UpdateUser();

                        await GM.Initiate();

                        var game   = new GameScreen();
                        var result = game.ShowDialog();
                        if (result == DialogResult.Cancel)
                        {
                            if (Sg.IsValidUser)
                            {
                                Sg.User.IsOnline = false;
                                await Sg.UpdateUser();

                                await Sg.Reference.Child("Gamedata").Child(GM.Game.Id).PutAsync(GM.Game);
                            }
                            Sg.LoginForm.Close();
                        }
                    }
                    else
                    {
                        new CustomMessageBox().Show("Senha incorreta", "Erro de Login", Sg.AccentColor);
                    }
                }
                else
                {
                    new CustomMessageBox().Show("Usuário Inexistente", "Erro de Login", Sg.AccentColor);
                }
            }
        }