예제 #1
0
 public UserInfo(TwitterUser user)
 {
     this.Id = user.Id;
     this.Name = WebUtility.HtmlDecode(user.Name).Trim();
     this.ScreenName = user.ScreenName;
     this.Location = WebUtility.HtmlDecode(user.Location);
     this.Description = WebUtility.HtmlDecode(user.Description);
     try
     {
         this.ImageUrl = new Uri(user.ProfileImageUrlHttps);
     }
     catch (Exception)
     {
         this.ImageUrl = null;
     }
     this.Url = user.Url;
     this.Protect = user.Protected;
     this.FriendsCount = user.FriendsCount;
     this.FollowersCount = user.FollowersCount;
     this.CreatedAt = MyCommon.DateTimeParse(user.CreatedAt);
     this.StatusesCount = user.StatusesCount;
     this.Verified = user.Verified;
     if (user.Status != null)
     {
         this.RecentPost = user.Status.Text;
         this.PostCreatedAt = MyCommon.DateTimeParse(user.Status.CreatedAt);
         this.PostSource = user.Status.Source;
     }
 }
예제 #2
0
        public string GetUserInfo(string screenName, ref TwitterUser user)
        {
            if (MyCommon._endingFlag) return "";

            if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return "";

            user = null;

            HttpStatusCode res;
            var content = "";
            try
            {
                res = twCon.ShowUserInfo(screenName, ref content);
            }
            catch(Exception ex)
            {
                return "Err:" + ex.Message + "(" + MethodBase.GetCurrentMethod().Name + ")";
            }

            var err = this.CheckStatusCode(res, content);
            if (err != null) return err;

            try
            {
                user = TwitterUser.ParseJson(content);
            }
            catch (SerializationException ex)
            {
                MyCommon.TraceOut(ex.Message + Environment.NewLine + content);
                return "Err:Json Parse Error(DataContractJsonSerializer)";
            }
            catch (Exception ex)
            {
                MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content);
                return "Err:Invalid Json!";
            }
            return "";
        }
예제 #3
0
파일: Tween.cs 프로젝트: nanayaT/OpenTween
        private async void doShowUserStatus(TwitterUser user)
        {
            using (var userDialog = new UserInfoDialog(this, this.tw))
            {
                var showUserTask = userDialog.ShowUserAsync(user);
                userDialog.ShowDialog(this);

                this.Activate();
                this.BringToFront();

                // ユーザー情報の表示が完了するまで userDialog を破棄しない
                await showUserTask;
            }
        }
예제 #4
0
 /// <summary>ユーザーのフォロワー数などの情報を更新します</summary>
 private void UpdateUserStats(TwitterUser self)
 {
     this.FollowersCount = self.FollowersCount;
     this.FriendsCount = self.FriendsCount;
     this.StatusesCount = self.StatusesCount;
     this.Location = self.Location;
     this.Bio = self.Description;
 }
예제 #5
0
        public async Task ShowUserAsync(TwitterUser user)
        {
            if (user == null || user == this._displayUser)
                return;

            this.CancelLoading();

            var cancellationToken = this.cancellationTokenSource.Token;

            this._displayUser = user;

            this.LabelId.Text = user.IdStr;
            this.LabelScreenName.Text = user.ScreenName;
            this.LabelName.Text = user.Name;
            this.LabelLocation.Text = user.Location ?? "";
            this.LabelCreatedAt.Text = MyCommon.DateTimeParse(user.CreatedAt).ToString();

            if (user.Protected)
                this.LabelIsProtected.Text = Properties.Resources.Yes;
            else
                this.LabelIsProtected.Text = Properties.Resources.No;

            if (user.Verified)
                this.LabelIsVerified.Text = Properties.Resources.Yes;
            else
                this.LabelIsVerified.Text = Properties.Resources.No;

            var followingUrl = "https://twitter.com/" + user.ScreenName + "/following";
            this.LinkLabelFollowing.Text = user.FriendsCount.ToString();
            this.LinkLabelFollowing.Tag = followingUrl;
            this.ToolTip1.SetToolTip(this.LinkLabelFollowing, followingUrl);

            var followersUrl = "https://twitter.com/" + user.ScreenName + "/followers";
            this.LinkLabelFollowers.Text = user.FollowersCount.ToString();
            this.LinkLabelFollowers.Tag = followersUrl;
            this.ToolTip1.SetToolTip(this.LinkLabelFollowers, followersUrl);

            var favoritesUrl = "https://twitter.com/" + user.ScreenName + "/favorites";
            this.LinkLabelFav.Text = user.FavouritesCount.ToString();
            this.LinkLabelFav.Tag = favoritesUrl;
            this.ToolTip1.SetToolTip(this.LinkLabelFav, favoritesUrl);

            var profileUrl = "https://twitter.com/" + user.ScreenName;
            this.LinkLabelTweet.Text = user.StatusesCount.ToString();
            this.LinkLabelTweet.Tag = profileUrl;
            this.ToolTip1.SetToolTip(this.LinkLabelTweet, profileUrl);

            if (this.twitter.UserId == user.Id)
            {
                this.ButtonEdit.Enabled = true;
                this.ChangeIconToolStripMenuItem.Enabled = true;
                this.ButtonBlock.Enabled = false;
                this.ButtonReportSpam.Enabled = false;
                this.ButtonBlockDestroy.Enabled = false;
            }
            else
            {
                this.ButtonEdit.Enabled = false;
                this.ChangeIconToolStripMenuItem.Enabled = false;
                this.ButtonBlock.Enabled = true;
                this.ButtonReportSpam.Enabled = true;
                this.ButtonBlockDestroy.Enabled = true;
            }

            await Task.WhenAll(new[]
            {
                this.SetDescriptionAsync(user.Description, cancellationToken),
                this.SetRecentStatusAsync(user.Status, cancellationToken),
                this.SetLinkLabelWebAsync(user.Url, cancellationToken),
                this.SetUserImageAsync(user.ProfileImageUrlHttps, cancellationToken),
                this.LoadFriendshipAsync(user.ScreenName, cancellationToken),
            });
        }