private void loginButton_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(usernameBox.Text) || String.IsNullOrEmpty(passwordBox.Text))
{
ErrorBox("Please enter your username and password");
return;
}
mainPanel.Enabled = false;
GmailClient gmailClient = new GmailClient(usernameBox.Text, passwordBox.Text);
if (gmailClient.CheckEmail() != CheckEmailResult.Success)
{
mainPanel.Enabled = true;
ErrorBox("Could not login\r\n\r\n" + gmailClient.LastError.Message);
return;
}
byte[] pass = System.Security.Cryptography.ProtectedData.Protect(UTF8Encoding.UTF8.GetBytes(passwordBox.Text), null, System.Security.Cryptography.DataProtectionScope.CurrentUser);
RegistryKey registry = Registry.CurrentUser.CreateSubKey(@"Software\KwertyGmailNotifier");
using (registry)
{
registry.SetValue("username", usernameBox.Text);
registry.SetValue("password", pass);
}
_mainForm._gmailClient = gmailClient;
_mainForm.Setup();
_mainForm._timer.Start();
_closed = true;
Close();
}