Esempio n. 1
0
        private void TwitterConnect_Clicked(object sender, EventArgs e)
        {
            Debug.WriteLine("Clicked");
            var           testLogin    = true;
            var           testPassword = true;
            StringBuilder builder      = new StringBuilder();

            if (this.identifiant.Text == null || this.identifiant.Text.Length < 3)
            {
                testLogin = false;
                builder.Append(LOGIN_ERROR);
            }

            if (string.IsNullOrEmpty(this.motDePasse.Text) || this.motDePasse.Text.Length < 6)
            {
                testPassword = false;
                if (!testLogin)
                {
                    builder.Append("\n");
                }
                builder.Append(PASSWORD_ERROR);
            }


            if (testLogin && testPassword)
            {
                if (twitterService.Authentificate(this.identifiant.Text, this.motDePasse.Text))
                {
                    this.listeTweets.IsVisible = !this.listeTweets.IsVisible;
                    this.connectForm.IsVisible = false;
                    this.erreur.IsVisible      = false;
                }
                else
                {
                    this.erreur.Text      = builder.Append(AUTH_ERROR).ToString();
                    this.erreur.IsVisible = true;
                }
            }

            if (!testLogin || !testPassword)
            {
                this.erreur.Text      = builder.ToString();
                this.erreur.IsVisible = true;
            }
        }