Exemplo n.º 1
0
        /// <summary>
        /// Try to Login to the Forums
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void LoginBtnClick(object sender, EventArgs e)
        {
            // Encrypt Password
            this.textBox2.Text = Utility.EncodePassword(this.textBox2.Text).Replace("-", string.Empty).ToLower();

            var loginManager = new LoginManager(this.textBox1.Text, this.textBox2.Text);

            var welcomeMessage = this._ResourceManager.GetString("lblWelcome");
            var failedMessage  = this._ResourceManager.GetString("lblFailed");

            if (loginManager.DoLogin(CacheController.Instance().UserSettings.ForumURL))
            {
                this.label3.Text      = $"{welcomeMessage}{this.textBox1.Text}";
                this.label3.ForeColor = Color.Green;
                this.LoginBtn.Enabled = false;

                SettingsHelper.SaveSetting("User", this.textBox1.Text);
                SettingsHelper.SaveSetting("Password", this.textBox2.Text);

                this.timer1.Enabled = true;
            }
            else
            {
                this.label3.Text      = failedMessage;
                this.label3.ForeColor = Color.Red;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Tries to Login to the Forums
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void LoginBtnClick(object sender, EventArgs e)
        {
            if (this.ForumUrl.Text.StartsWith("http://"))
            {
                if (!this.ForumUrl.Text.EndsWith("/"))
                {
                    this.ForumUrl.Text += "/";
                }

                CacheController.Instance().UserSettings.CurrentForumUrl = this.ForumUrl.Text;
            }

            string welcomeString = this.rm.GetString("lblWelcome"), lblFailed = this.rm.GetString("lblFailed");

            if (this.GuestLogin.Checked)
            {
                this.UserNameField.Text = "Guest";
                this.PasswordField.Text = "Guest";

                this.label3.Text         = string.Format("{0}{1}", welcomeString, this.UserNameField.Text);
                this.label3.ForeColor    = Color.Green;
                this.LoginButton.Enabled = false;

                if (
                    CacheController.Instance().UserSettings.ForumsAccount.Any(
                        item => item.ForumURL == CacheController.Instance().UserSettings.CurrentForumUrl))
                {
                    CacheController.Instance().UserSettings.ForumsAccount.RemoveAll(
                        item => item.ForumURL == CacheController.Instance().UserSettings.CurrentForumUrl);
                }

                var forumsAccount = new ForumAccount
                {
                    ForumURL     = CacheController.Instance().UserSettings.CurrentForumUrl,
                    UserName     = this.UserNameField.Text,
                    UserPassWord = this.PasswordField.Text,
                    GuestAccount = false
                };

                CacheController.Instance().UserSettings.ForumsAccount.Add(forumsAccount);
                CacheController.Instance().UserSettings.CurrentUserName = this.UserNameField.Text;

                this.timer1.Enabled = true;
            }
            else
            {
                // Encrypt Password
                this.PasswordField.Text =
                    Utility.EncodePassword(this.PasswordField.Text).Replace("-", string.Empty).ToLower();

                var loginManager = new LoginManager(this.UserNameField.Text, this.PasswordField.Text);

                if (loginManager.DoLogin(CacheController.Instance().UserSettings.CurrentForumUrl))
                {
                    this.label3.Text         = string.Format("{0}{1}", welcomeString, this.UserNameField.Text);
                    this.label3.ForeColor    = Color.Green;
                    this.LoginButton.Enabled = false;

                    if (
                        CacheController.Instance().UserSettings.ForumsAccount.Any(
                            item => item.ForumURL == CacheController.Instance().UserSettings.CurrentForumUrl))
                    {
                        CacheController.Instance().UserSettings.ForumsAccount.RemoveAll(
                            item => item.ForumURL == CacheController.Instance().UserSettings.CurrentForumUrl);
                    }

                    var forumsAccount = new ForumAccount
                    {
                        ForumURL     = CacheController.Instance().UserSettings.CurrentForumUrl,
                        UserName     = this.UserNameField.Text,
                        UserPassWord = this.PasswordField.Text,
                        GuestAccount = false
                    };

                    CacheController.Instance().UserSettings.ForumsAccount.Add(forumsAccount);
                    CacheController.Instance().UserSettings.CurrentUserName = this.UserNameField.Text;

                    this.timer1.Enabled = true;
                }
                else
                {
                    this.label3.Text      = lblFailed;
                    this.label3.ForeColor = Color.Red;
                }
            }
        }