/// <summary> /// ツイート・リツイート時間の更新 /// </summary> /// <param name="currentTime">現在の時間</param> /// <returns>時間表示の更新が行われたか否か</returns> public bool RecalculateTime(DateTimeOffset currentTime) { var oldTime = this.Time; var oldRetweetedTime = this.RetweetedTime; this.Time = CommonMethods.CalculateTime(currentTime, this.CreatedAt); this.RetweetedTime = CommonMethods.CalculateTime(currentTime, this.RetweetedAt); if (oldTime == this.Time && oldRetweetedTime == this.RetweetedTime) { return(false); } return(true); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="timelineModel">TimelineModel</param> /// <param name="originStatus">ツイート内容</param> /// <param name="type">ツイートの表示タイプ</param> public StatusProperties(TimelineModel timelineModel, Status originStatus, StatusType type = StatusType.Timeline) { this.TimelineModel = timelineModel; this.Type = type; this.Media = new List <MediaProperties>(); this.QuotationStatus = new List <QuotationStatusProperties>(); this.MediaColumnWidth = new List <GridLength>() { new GridLength(0), new GridLength(0), new GridLength(0), new GridLength(0) }; this.SelectItemCommand = new RelayCommand(this.SelectItem); this.SelectIconCommand = new RelayCommand(this.SelectIcon); this.ReplyCommand = new RelayCommand(this.Reply); this.RetweetCommand = new RelayCommand(this.Retweet); this.QuotationLinkRetweetCommand = new RelayCommand(this.QuotationLinkRetweet); this.QuotationTextRetweetCommand = new RelayCommand(this.QuotationTextRetweet); this.FavoriteCommand = new RelayCommand(this.Favorite); this.BlockCommand = new RelayCommand(this.Block); this.MuteCommand = new RelayCommand(this.Mute); this.NotifyCommand = new RelayCommand <bool>(this.Notify); this.ShareCommand = new RelayCommand(this.Share); this.CopyCommand = new RelayCommand(this.Copy); this.OpenWebBrowserCommand = new RelayCommand(this.OpenWebBrowser); this.DeleteCommand = new RelayCommand(this.Delete); this.SelectQuotationStatusCommand = new RelayCommand(this.SelectQuotationStatus); this.SelectQuotationUserCommand = new RelayCommand(this.SelectQuotationUser); this.SelectMediaCommand = new RelayCommand <int>(this.SelectMedia); this.HyperlinkText = new HyperlinkTextProperties() { HashtagCommand = new RelayCommand <string>(this.SelectHashTag), MentionCommand = new RelayCommand <string>(this.SelectMention), UrlCommand = new RelayCommand <string>(this.SelectUrl) }; this.QuotationIds = new List <long>(); if (originStatus == null) { return; } var currentTime = DateTimeOffset.Now; var status = originStatus; while (status.RetweetedStatus != null) { status = originStatus.RetweetedStatus; } #region ツイート本文 if (status.ExtendedTweet != null && status.ExtendedTweet.FullText != null) { this.HyperlinkText.Text = status.ExtendedTweet.FullText; } else if (status.Text != null) { this.HyperlinkText.Text = status.Text; } else if (status.FullText != null) { this.HyperlinkText.Text = status.FullText; } else { this.HyperlinkText.Text = ""; } this.FullText = this.HyperlinkText.Text; if (status.ExtendedTweet?.Entities != null) { this.HyperlinkText.Hashtags = status.ExtendedTweet.Entities.HashTags.ToList(); this.HyperlinkText.Mentions = status.ExtendedTweet.Entities.UserMentions.ToList(); this.HyperlinkText.Urls = status.ExtendedTweet.Entities.Urls.ToList(); } else if (status.Entities != null) { this.HyperlinkText.Hashtags = status.Entities.HashTags.ToList(); this.HyperlinkText.Mentions = status.Entities.UserMentions.ToList(); this.HyperlinkText.Urls = status.Entities.Urls.ToList(); } #endregion this.Id = status.Id; this.User = new UserOverviewProperties(status.User); this.IsRetweetedByUser = false; //ユーザーがリツイートしたツイートの場合 if (originStatus.RetweetedStatus != null) { this.IsRetweetedByUser = true; this.RetweetedAt = originStatus.CreatedAt; this._RetweetedTime = CommonMethods.CalculateTime(currentTime, this.RetweetedAt); this.RetweetedUser = new UserOverviewProperties(originStatus.User); } this._IsRetweeted = status.IsRetweeted; this._IsFavorited = status.IsFavorited; this.CreatedAt = status.CreatedAt; this._ReplyCount = null; this._RetweetCount = status.RetweetCount; this._FavoriteCount = status.FavoriteCount; //現在時刻との差を計算・表示 this._Time = CommonMethods.CalculateTime(currentTime, this.CreatedAt); this.Via = "via " + this.EscapeHtmlTags(status.Source); //メディアが含まれるツイートの場合 IEnumerable <MediaEntity> media = null; if (status.ExtendedTweet?.ExtendedEntities?.Media != null) { media = status.ExtendedTweet.ExtendedEntities.Media; } else if (status.ExtendedEntities?.Media != null) { media = status.ExtendedEntities.Media; } else if (status.ExtendedTweet?.Entities?.Media != null) { media = status.ExtendedTweet?.Entities.Media; } else if (status.Entities?.Media != null) { media = status.Entities.Media; } if (media != null) { var j = 0; foreach (var m in media) { this.Media.Add(new MediaProperties(m, j)); this.MediaColumnWidth[j] = new GridLength(1, GridUnitType.Star); j++; } this.HyperlinkText.Media = media.ToList(); } //引用が含まれるツイートの場合 if (status.QuotedStatus != null) { this.QuotationIds.Add(status.QuotedStatus.Id); this.QuotationStatus.Add(new QuotationStatusProperties(status.QuotedStatus)); } //リプライの場合 if (Properties.Settings.Default.IsDisplayReplyStatus && status.InReplyToStatusId != null) { this.ReplyToStatusProperties = new ReplyToStatusProperties(this.TimelineModel, (long)status.InReplyToStatusId); } else if (status.InReplyToStatusId != null) { this.ReplyToStatusProperties = new ReplyToStatusProperties(true); } else { this.ReplyToStatusProperties = new ReplyToStatusProperties(false); } }