private void MainForm_Shown(object sender, EventArgs e)
{
Refresh();
RegistryKey registry = Registry.CurrentUser.CreateSubKey(@"Software\KwertyGmailNotifier");
string username;
byte[] passwordEnc;
int interval;
using (registry)
{
username = (string)registry.GetValue("username");
passwordEnc = (byte[])registry.GetValue("password");
interval = (int)registry.GetValue("interval", 2);
_newMailSound = (string)registry.GetValue("newmailsound");
}
string password = null;
if (passwordEnc != null)
password = UTF8Encoding.UTF8.GetString(ProtectedData.Unprotect(passwordEnc, null, DataProtectionScope.CurrentUser));
if (interval > 0 && interval <= 60)
_checkInterval = interval * 60000;
if (String.IsNullOrEmpty(username) || String.IsNullOrEmpty(password))
{
LoginForm loginForm = new LoginForm(this);
loginForm.Show();
return;
}
_loggedIn = true;
_gmailClient = new GmailClient(username, password);
Setup();
RefreshAndRestartTimer();
}