Пример #1
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            if (DateTime.Today > DateTime.Parse("2013/01/01"))
            {
                MessageBox.Show("Please download a newer version of Gmail Notifier at kwerty.com", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                Close();
                return;
            }

            Refresh();

            RegistryKey registry = Registry.CurrentUser.CreateSubKey(@"Software\Kwerty Gmail Notifier");
            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();
        }
Пример #2
0
        private void ShowLoginForm()
        {
            LoginForm loginForm = new LoginForm(this);

            loginForm.Show();

            StealFocus(loginForm.Handle);
        }
Пример #3
0
        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();
        }