private async void btnLogin_Click_1(object sender, EventArgs e) { if (!FieldErrorCheck("login")) { return; } try { SayLog.Info("Processo de login iniciado! Isso pode levar alguns segundos, aguarde..."); //Check if account its PTC / Google. if (rbGoogle.Checked) { PogoGlobalSettings.PogoClient = await PogoClient.GetClient(txtPogoUsername.Text, txtPogoPassword.Text, AuthType.Google); } else if (rbPTC.Checked) { PogoGlobalSettings.PogoClient = await PogoClient.GetClient(txtPogoUsername.Text, txtPogoPassword.Text, AuthType.Ptc); } } catch (Exception) { SayLog.Error("Falha no login..."); return; } if (PogoGlobalSettings.PogoClient.Player.PlayerData == null) { SayLog.Fatal( "Infelizmente a conta informada aparenta estar temporariamente suspensa. Tente outra conta."); return; } SayLog.Debug("Logado com sucesso!"); PogoGlobalSettings.PogoClient.Inventory.OnInventoryUpdated += Inventory_OnInventoryUpdated; btnLogout.Enabled = true; btnLogin.Enabled = false; UpdatePlayerStatistic(); timerAtualizaStatus.Enabled = true; //Save settings updated to file UserGlobalConfiguration.Username = txtPogoUsername.Text; UserGlobalConfiguration.Password = txtPogoPassword.Text; if (rbGoogle.Checked) { UserGlobalConfiguration.TypeAcc = AuthType.Google; } else { UserGlobalConfiguration.TypeAcc = AuthType.Ptc; } UserGlobalConfiguration.SaveSettingsFromUser(); }
// DESLOGAR DO JOGO private async void btnDeslogar_Click(object sender, EventArgs e) { if (!PogoGlobalSettings.PogoClient.AccessToken.IsExpired) { //TODO: CANCEL THE HTTP CLIENT SayLog.Info("Deslogando..."); await Task.Delay(3000); //TODO: VERY IF WE LOGOUT WITH SUCESS SayLog.Debug("Deslogado com sucesso!"); btnLogout.Enabled = false; btnLogin.Enabled = true; lblNomeValue.Text = "0"; lblMochilaValue.Text = "0"; lblTimeValue.Text = "0"; lblPokebolasValue.Text = "0"; } }