Beispiel #1
0
        private void GenerateLayoutForWallPost()
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            Thickness margin = new Thickness();
            Action    action = null;

            if (this._preview)
            {
                action = new Action(this.OnMoreOptionsTap);
            }
            if (this._originalHeaderItem == null)
            {
                this._originalHeaderItem = new UserOrGroupHeaderItem(this.Width, new Thickness(), this.IsGroupPost, this._wallPost.date, this._fromUser, this._fromGroup, this.ExtraText, this.IconType, this.PostSourcePlatform, this._isFeedbackItem ? null : action, new Action(this.onNavigatedToUserOrGroup), this.ExtraTextEnd);
                this.VirtualizableChildren.Add((IVirtualizable)this._originalHeaderItem);
            }
            this._originalHeaderItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
            margin.Top += this._originalHeaderItem.FixedHeight + 8.0;
            if (!string.IsNullOrEmpty(this._wallPost.text))
            {
                if (this._originalTextItem == null)
                {
                    this._originalTextItem = new NewsTextItem(this.Width - 32.0, new Thickness(16.0, 0.0, 16.0, 0.0), this._wallPost.text, this._preview, (Action)(() => this.NavigateToWallPostWithComments(false)), 21.3, new FontFamily("Segoe WP"), 28.0, (Brush)null, false, 0.0, HorizontalAlignment.Left, this._wallPost.PostId, TextAlignment.Left, true);
                    this.VirtualizableChildren.Add((IVirtualizable)this._originalTextItem);
                }
                this._originalTextItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                margin.Top += this._originalTextItem.FixedHeight + 8.0;
            }
            this.CanShowLikesSeparator = true;
            if ((!this._wallPost.attachments.IsNullOrEmpty() ? 1 : (this._wallPost.geo != null ? 1 : 0)) != 0)
            {
                if (this._originalAttachmentsItem == null)
                {
                    this._originalAttachmentsItem = new AttachmentsItem(this.Width, new Thickness(), this._wallPost.attachments, this._wallPost.geo, this._wallPost.from_id == 0L || this._wallPost.id <= 0L ? "" : string.Format("{0}_{1}", (object)this._wallPost.from_id, (object)this._wallPost.id), this._wallPost.friends_only == 1, false, false, false, 0.0, false, !this._preview, this._wallPost.PostId);
                    this.VirtualizableChildren.Add((IVirtualizable)this._originalAttachmentsItem);
                }
                this._originalAttachmentsItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                margin.Top += this._originalAttachmentsItem.FixedHeight;
                this.CanShowLikesSeparator = !this._originalAttachmentsItem.IsLastAttachmentMedia;
            }
            if (this._wallPost.signer_id != 0L)
            {
                margin.Top += 8.0;
                if (this._originalSignerItem == null)
                {
                    this._originalSignerItem = new LinkToUserOrGroupItem(this.Width, new Thickness(), new long?(this._wallPost.signer_id), this._users, this._groups, null);
                    this.VirtualizableChildren.Add((IVirtualizable)this._originalSignerItem);
                }
                this._originalSignerItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                margin.Top += this._originalSignerItem.FixedHeight;
                this.CanShowLikesSeparator = true;
            }
            if (!this._wallPost.copy_history.IsNullOrEmpty())
            {
                int index = 0;
                foreach (WallPost wallPost in this._wallPost.copy_history)
                {
                    int currentInd = index;
                    WallPostItem.WallPostHistoryVirtItems historyVirtItems = this._historyVirtItemsDict.ContainsKey(currentInd) ? this._historyVirtItemsDict[currentInd] : new WallPostItem.WallPostHistoryVirtItems();
                    bool   isMale;
                    string pic;
                    string name;
                    this.GetNamePicAndSex(wallPost.from_id, out name, out pic, out isMale);
                    int                num1               = WallPostItem.GetIsProfilePhoto(wallPost.attachments, wallPost.post_source) ? 1 : 0;
                    bool               flag               = wallPost.owner_id < 0L;
                    int                num2               = wallPost.IsRepost() ? 1 : 0;
                    int                num3               = isMale ? 1 : 0;
                    int                num4               = flag ? 1 : 0;
                    string             extraText          = WallPostItem.GetExtraText(num1 != 0, num2 != 0, num3 != 0, num4 != 0);
                    string             extraTextEnd       = WallPostItem.GetExtraTextEnd(wallPost.IsReply);
                    PostSource         postSource         = wallPost.post_source;
                    PostSourcePlatform postSourcePlatform = (PostSourcePlatform)(postSource != null ? (int)postSource.GetPlatform() : 0);
                    string             subtitle           = "";
                    if (!string.IsNullOrEmpty(extraText))
                    {
                        subtitle = extraText.ToLowerInvariant();
                    }
                    else if (wallPost.date != 0)
                    {
                        subtitle = UIStringFormatterHelper.FormatDateTimeForUI(VKClient.Common.Utils.Extensions.UnixTimeStampToDateTime((double)wallPost.date, true));
                    }
                    if (!string.IsNullOrEmpty(extraTextEnd))
                    {
                        subtitle += string.Format(" {0}", (object)extraTextEnd);
                    }
                    margin.Top += 8.0;
                    if (historyVirtItems.HeaderItem == null)
                    {
                        historyVirtItems.HeaderItem = new UCItem(this.Width, new Thickness(), (Func <UserControlVirtualizable>)(() =>
                        {
                            RepostHeaderUC repostHeaderUc = new RepostHeaderUC();
                            this._wallRepostInfo          = new WallRepostInfo()
                            {
                                Pic                = pic,
                                Name               = name,
                                Subtitle           = subtitle,
                                PostSourcePlatform = postSourcePlatform,
                                Width              = this.Width - 16.0
                            };
                            WallRepostInfo configuration = this._wallRepostInfo;
                            repostHeaderUc.Configure(configuration, (Action)(() => this.LinkToUserOrGroupTap(currentInd)));
                            return((UserControlVirtualizable)repostHeaderUc);
                        }), (Func <double>)(() => 56.0), (Action <UserControlVirtualizable>)null, 0.0, false);
                        this.VirtualizableChildren.Add((IVirtualizable)historyVirtItems.HeaderItem);
                    }
                    historyVirtItems.HeaderItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                    margin.Top += historyVirtItems.HeaderItem.FixedHeight + 8.0;
                    if (!string.IsNullOrWhiteSpace(wallPost.text))
                    {
                        if (historyVirtItems.TextItem == null)
                        {
                            historyVirtItems.TextItem = new NewsTextItem(this.Width - 32.0, new Thickness(16.0, 0.0, 16.0, 0.0), wallPost.text, this._preview, (Action)(() => this.NavigateToWallPostWithComments(false)), 21.3, new FontFamily("Segoe WP"), 28.0, (Brush)null, false, 0.0, HorizontalAlignment.Left, wallPost.PostId, TextAlignment.Left, true);
                            this.VirtualizableChildren.Add((IVirtualizable)historyVirtItems.TextItem);
                        }
                        historyVirtItems.TextItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                        margin.Top += historyVirtItems.TextItem.FixedHeight + 8.0;
                    }
                    if ((!wallPost.attachments.IsNullOrEmpty() ? 1 : (wallPost.geo != null ? 1 : 0)) != 0)
                    {
                        if (historyVirtItems.AttachmentsItem == null)
                        {
                            string itemId = wallPost.from_id == 0L || wallPost.id <= 0L ? "" : string.Format("{0}_{1}", (object)wallPost.from_id, (object)wallPost.id);
                            historyVirtItems.AttachmentsItem = new AttachmentsItem(this.Width, new Thickness(), wallPost.attachments, wallPost.geo, itemId, wallPost.friends_only == 1, false, false, false, 0.0, false, !this._preview, wallPost.PostId);
                            this.VirtualizableChildren.Add((IVirtualizable)historyVirtItems.AttachmentsItem);
                        }
                        historyVirtItems.AttachmentsItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                        margin.Top += historyVirtItems.AttachmentsItem.FixedHeight;
                        this.CanShowLikesSeparator = !historyVirtItems.AttachmentsItem.IsLastAttachmentMedia;
                    }
                    if (wallPost.signer_id != 0L)
                    {
                        margin.Top += 8.0;
                        if (historyVirtItems.SignerItem == null)
                        {
                            historyVirtItems.SignerItem = new LinkToUserOrGroupItem(this.Width, new Thickness(), new long?(wallPost.signer_id), this._users, this._groups, null);
                            this.VirtualizableChildren.Add((IVirtualizable)historyVirtItems.SignerItem);
                        }
                        historyVirtItems.SignerItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                        margin.Top += historyVirtItems.SignerItem.FixedHeight;
                        this.CanShowLikesSeparator = true;
                    }
                    this._historyVirtItemsDict[index] = historyVirtItems;
                    ++index;
                }
            }
            if (this._preview)
            {
                bool isReply = this._wallPost.IsReply;
                if (!this.IsSuggestedPostponed && !this._isFeedbackItem && !isReply)
                {
                    if (this.CanShowLikesSeparator)
                    {
                        margin.Top += 8.0;
                    }
                    margin.Top = Math.Round(margin.Top);
                    if (this.LikesAndCommentsItem == null)
                    {
                        this.LikesAndCommentsItem = new LikesAndCommentsItem(this.Width, new Thickness(), this._wallPost, (Action)(() => this.NavigateToWallPostWithComments(true)), this._suppressRepostButton, this.CanShowLikesSeparator);
                        this.VirtualizableChildren.Add((IVirtualizable)this.LikesAndCommentsItem);
                    }
                    this.LikesAndCommentsItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                    margin.Top += this.LikesAndCommentsItem.FixedHeight;
                }
                else if (isReply)
                {
                    margin.Top += 8.0;
                }
            }
            else
            {
                margin.Top += 8.0;
            }
            if (this._preview && this.IsSuggested && this._wallPost.can_publish == 1)
            {
                margin.Top += 8.0;
                if (this._publishRejectItem == null)
                {
                    this._publishRejectItem = new UCItem(this.Width, margin, (Func <UserControlVirtualizable>)(() =>
                    {
                        PublicRejectUC publicRejectUc     = new PublicRejectUC();
                        publicRejectUc.buttonPublish.Tap += new EventHandler <System.Windows.Input.GestureEventArgs>(this.buttonPublish_Tap);
                        publicRejectUc.buttonDelete.Tap  += new EventHandler <System.Windows.Input.GestureEventArgs>(this.buttonDelete_Tap);
                        return((UserControlVirtualizable)publicRejectUc);
                    }), (Func <double>)(() => 60.0), (Action <UserControlVirtualizable>)null, 0.0, false);
                    this.VirtualizableChildren.Add((IVirtualizable)this._publishRejectItem);
                }
                margin.Top += this._publishRejectItem.FixedHeight;
            }
            this._height = margin.Top;
            if (this._preview && this._showDivideLine)
            {
                this._height = this._height + this.DividerHeight;
            }
            stopwatch.Stop();
        }
 public UserOrGroupHeaderItem(double width, Thickness margin, bool isGroupPost, int date, User profile, Group group, string extraText = "", PostIconType postIconType = PostIconType.None, PostSourcePlatform postSourcePlatform = PostSourcePlatform.None, Action moreOptionsTapCallback = null, Action navigatedToUserOrGroupCallback = null, string extraTextEnd = "")
     : base(width, margin, new Thickness())
 {
     this._date                           = date;
     this._user                           = profile;
     this._group                          = group;
     this._isGroupPost                    = isGroupPost;
     this._extraText                      = extraText;
     this._postIconType                   = postIconType;
     this._postSourcePlatform             = postSourcePlatform;
     this._moreOptionsTapCallback         = moreOptionsTapCallback;
     this._navigatedToUserOrGroupCallback = navigatedToUserOrGroupCallback;
     this._extraTextEnd                   = extraTextEnd;
     this.GenerateVirtChildren();
 }