private void LoginFinished(LoginResult success, DateTime banEnd, string message, bool showEmail = false) { if (_inLoginDone) { Log.Info("Already done logging in?"); return; } Log.Info("Login Finished"); _inLoginDone = true; if (_loginTimer != null) { _loginTimer.Dispose(); _loginTimer = null; } Dispatcher.Invoke((Action)(() => { Log.InfoFormat("Updating UI for Log result {0}", success); _isLoggingIn = false; switch (success) { case Skylabs.Lobby.LoginResult.Success: if (Prefs.Username == null || Prefs.Username.Equals(textBox1.Text, StringComparison.InvariantCultureIgnoreCase) == false) { // Logging in with a new username, so clear admin flag Prefs.IsAdmin = false; } Prefs.Username = textBox1.Text; Prefs.Nickname = textBox1.Text; Prefs.Password = passwordBox1.Password.Encrypt(); break; case Skylabs.Lobby.LoginResult.Banned: spleft.IsEnabled = true; DoErrorMessage("You have been banned until " + banEnd.ToShortTimeString() + " on " + banEnd.ToShortDateString()); break; case Skylabs.Lobby.LoginResult.Failure: spleft.IsEnabled = true; DoErrorMessage("Login Failed: " + message); break; } if (showEmail) { Log.Info("No email found, must enter e-mail"); textBoxEmail.Text = ""; textBoxEmail.Visibility = Visibility.Visible; labelEmail.Visibility = Visibility.Visible; } else { Log.Info("Email stored"); textBoxEmail.Visibility = Visibility.Collapsed; labelEmail.Visibility = Visibility.Collapsed; } Log.Info("Full Login done"); _inLoginDone = false; }), new object[] { }); }
private void LoginFinished(LoginResult success, DateTime banEnd, string message, bool showEmail =false) { if (_inLoginDone) { Log.Info("Already done logging in?"); return; } Log.Info("Login Finished"); _inLoginDone = true; Trace.TraceInformation("Login finished."); if (_loginTimer != null) { _loginTimer.Dispose(); _loginTimer = null; } Dispatcher.Invoke((Action) (() => { Log.InfoFormat("Updating UI for Log result {0}",success); _isLoggingIn = false; switch (success) { case Skylabs.Lobby.LoginResult.Success: Prefs.Username = textBox1.Text; Prefs.Nickname = textBox1.Text; Prefs.Password = cbSavePassword.IsChecked == true ? passwordBox1.Password.Encrypt() : ""; break; case Skylabs.Lobby.LoginResult.Banned: spleft.IsEnabled = true; DoErrorMessage("You have been banned until " + banEnd.ToShortTimeString() + " on " + banEnd.ToShortDateString()); break; case Skylabs.Lobby.LoginResult.Failure: spleft.IsEnabled = true; DoErrorMessage("Login Failed: " + message); break; } if (showEmail) { Log.Info("No email found, must enter e-mail"); textBoxEmail.Text = ""; textBoxEmail.Visibility = Visibility.Visible; labelEmail.Visibility = Visibility.Visible; } else { Log.Info("Email stored"); textBoxEmail.Visibility = Visibility.Collapsed; labelEmail.Visibility = Visibility.Collapsed; } Log.Info("Full Login done"); _inLoginDone = false; }), new object[] {}); }