GmailNotifier.MainForm.Setup C# (CSharp) Метод

Setup() приватный Метод

private Setup ( ) : void
Результат void
        internal void Setup()
        {
            DetectBaseUrl();

            _processMsgClosed = false;
            _processMsg = new ProcessMessaging();
            _processMsg.MessageReceived +=new MessageReceivedEventHandler(MessageReceived);
            _processMsg.ReceieveMessages();

            SetupThumbAndButtons();

            EnableAppropriateButtons();

            AddJumpList();

            UpdateIcon();

            if (_gmailClient.Emails.Count > 0)
            {
                _thumbForm.Invoke(new Action<int>(_thumbForm.UpdatePreviewThumb), 0);
                _thumbForm.Invoke(new Action<bool>(_thumbForm.ShowAppropriateThumb), false);
            }

            _timer = new System.Timers.Timer();
            _timer.Interval = _checkInterval;
            _timerOn = true;
            _timer.Elapsed += TimerElapsed;
        }

Usage Example

Пример #1
0
        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();
        }