Beispiel #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            LoginWindow win = new LoginWindow();

            win.Owner = this;
            bool?ret = win.ShowDialog();

            if (!ret.HasValue || !ret.Value)
            {
                return;
            }
            TwitterAccount account = new TwitterAccount(_mgr);

            for (int i = 0; i < _observableAccountList.Count; i++)
            {
                ICredentials c        = _observableAccountList[i].Credential;
                string       userName = (c is NetworkCredential ? (c as NetworkCredential).UserName : (c as OAuthPasswordCache).UserName);
                if (userName.Equals(win.UserName))
                {
                    MessageBox.Show("入力されたユーザ名はすでにアカウントとして登録されています");
                    return;
                }
            }
            account.Credential = new NetworkCredential(win.UserName, win.Password);
            try {
                account.UpdateOAuthAccessToken();
                account.SelfUserID = account.TwitterClient.VerifyCredentials().ID;
                _observableAccountList.Add(account);
                Array.Resize <IStreamingHandler> (ref _targets, _observableAccountList.Count);
            } catch {
                MessageBox.Show("認証に失敗しました");
            }
        }
Beispiel #2
0
        private void UpdateAuthButton_Click(object sender, RoutedEventArgs e)
        {
            TwitterAccount selected = (TwitterAccount)((Button)sender).DataContext;

            try {
                selected.UpdateOAuthAccessToken();
                MessageBox.Show("更新に成功しました");
            } catch {
                MessageBox.Show("oAuthアクセストークンの更新が出来ませんでした." + Environment.NewLine +
                                "Twitter.comへの接続が出来なかったかか,ユーザ名/パスワードが間違っています");
            }
        }
Beispiel #3
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     LoginWindow win = new LoginWindow ();
     win.Owner = this;
     bool? ret = win.ShowDialog ();
     if (!ret.HasValue || !ret.Value)
         return;
     TwitterAccount account = new TwitterAccount (_mgr);
     for (int i = 0; i < _observableAccountList.Count; i ++) {
         ICredentials c = _observableAccountList[i].Credential;
         string userName = (c is NetworkCredential ? (c as NetworkCredential).UserName : (c as OAuthPasswordCache).UserName);
         if (userName.Equals (win.UserName)) {
             MessageBox.Show ("入力されたユーザ名はすでにアカウントとして登録されています");
             return;
         }
     }
     account.Credential = new NetworkCredential (win.UserName, win.Password);
     try {
         account.UpdateOAuthAccessToken ();
         account.SelfUserID = account.TwitterClient.VerifyCredentials ().ID;
         _observableAccountList.Add (account);
         Array.Resize<IStreamingHandler> (ref _targets, _observableAccountList.Count);
     } catch {
         MessageBox.Show ("認証に失敗しました");
     }
 }