コード例 #1
0
ファイル: LoginControl.cs プロジェクト: ssc1223/piCite
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                this.lblStatus.Visible = false;
                this.btnLogin.Enabled = false;
                this.chkRemember.Enabled = false;
                this.inputEmail.Enabled = false;
                this.inputPassword.Enabled = false;
                string strEmail = Regex.Replace(inputEmail.Text.ToLower(), @"^\s+|\s+$", "");
                if(Regex.Match(strEmail, @"#debug$").Success)
                {
                    DialogResult dr = MessageBox.Show("Are you sure that you want to switch to Debug Mode?", "DEBUG MODE", MessageBoxButtons.YesNo);
                    Globals.ThisAddIn.DebugMode = dr == DialogResult.Yes;
                    strEmail = Regex.Replace(strEmail, @"#debug$", "");
                }
                inputEmail.Text = strEmail;
                string strPassword = inputPassword.Text;
                // Check for email format
                if (!Regex.Match(strEmail, @"^[a-zA-Z0-9\._\-]+@([a-zA-Z0-9\.\-]+\.)+[a-zA-Z0-9\.\-]{1,4}$").Success)
                {
                    loginError(Lang.en_US.Status_Invalid_Email);
                    inputEmail.Focus();
                    return;
                }

                // Check the password validity
                if (strPassword.Length == 0)
                {
                    loginError(Lang.en_US.Status_Empty_Password);
                    inputPassword.Focus();
                    return;
                }

                LoginThread login = new LoginThread(strEmail, strPassword, this);
                loginThread = new Thread(new ThreadStart(login.Login));
                loginThread.Start();
                this.lblLoading.Visible = true;
                this.imgLoading.Visible = true;
            }
            catch(Exception ex)
            {
                log.WriteLine(LogType.Error, "LoginControl::btnLogin_Click", ex.ToString());
            }
        }
コード例 #2
0
ファイル: LoginControl.cs プロジェクト: ssc1223/piCite
 private void LoginControl_Load(object sender, EventArgs e)
 {
     try
     {
         initializeUI();
         initializeLang();
         initializeHandlers();
         if (Properties.Settings.Default.USER_REMEMBERME)
         {
             this.lblStatus.Visible = false;
             this.inputPassword.Text = "password";
             this.inputEmail.Enabled = false;
             this.inputPassword.Enabled = false;
             this.chkRemember.Enabled = false;
             this.btnLogin.Enabled = false;
             if (loginThread != null)
                 if (loginThread.IsAlive)
                     loginThread.Abort();
             this.lblLoading.Visible = true;
             this.imgLoading.Visible = true;
             LoginThread login = new LoginThread(this);
             ThreadStart threadStart = new ThreadStart(login.LoginByAuthentication);
             loginThread = new Thread(threadStart);
             loginThread.Start();
         }
     }
     catch(Exception ex)
     {
         log.WriteLine(LogType.Error, "LoginControl::LoginControl_Load", ex.ToString());
     }
 }