/// <summary> /// Main form activated event /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event arguments</param> private void MainForm_Activated(object sender, EventArgs e) { if (api == null) { Hide(); if ((Configuration.EmailUsername.Length > 0) && (Configuration.Password.Length > 0)) { api = TruckingVSAPI.Authenticate(Configuration.EmailUsername, Configuration.Password, false); if (api == null) { ShowLogin(); } } else { ShowLogin(); } if (api == null) { Close(); } else { LoadLoginData(); Show(); } } }
/// <summary> /// Log in button click event /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event arguments</param> private void logInButton_Click(object sender, EventArgs e) { string email_username = emailUsernameSingleLineTextField.Text.Trim(); string password = passwordSingleLineTextField.Text; TruckingVSAPI auth = TruckingVSAPI.Authenticate(email_username, password, true); if (auth == null) { // Login failed MessageBox.Show("Email, Benutzername oder Passwort ist falsch!", "Anmeldefehler", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MainForm.API = auth; Configuration.EmailUsername = saveEmailUsernameCheckBox.Checked ? email_username : ""; Configuration.Password = autoLogInCheckBox.Checked ? TruckingVSAPI.SHA256String(password) : ""; Configuration.Save(); Close(); } }