private void GenerateLayout() { Thickness margin = new Thickness(); Action moreOptionsTapCallback = new Action(this.OnMoreOptionsTap); NewsItem newsItem1 = this._newsItemWithInfo.NewsItem; this._videos = (newsItem1 != null ? newsItem1.video : (VKList <VKClient.Common.Backend.DataObjects.Video>)null) ?? new VKList <VKClient.Common.Backend.DataObjects.Video>(); string extraText = UIStringFormatterHelper.FormatNumberOfSomething(this._videos.count, CommonResources.OneVideoFrm, CommonResources.TwoFourVideosFrm, CommonResources.FiveVideosFrm, true, null, false); this._header = new UserOrGroupHeaderItem(this.Width, margin, this.OwnerId < 0L, this._newsItemWithInfo.NewsItem.date, this._fromUser, this._fromGroup, extraText, PostIconType.None, PostSourcePlatform.None, moreOptionsTapCallback, new Action(this.onNavigatedToUserOrGroup), ""); this.VirtualizableChildren.Add((IVirtualizable)this._header); margin.Top += 12.0 + this._header.FixedHeight + 2.0; List <Attachment> list = this._videos.items.Take <VKClient.Common.Backend.DataObjects.Video>(5).Select <VKClient.Common.Backend.DataObjects.Video, Attachment>((Func <VKClient.Common.Backend.DataObjects.Video, Attachment>)(v => new Attachment() { type = "video", video = v })).ToList <Attachment>(); double desiredHeight = list.Count != 1 ? (list.Count < 2 || list.Count > 4 ? 580.0 : 430.0) : 280.0; NewsItem newsItem2 = this._newsItemWithInfo.NewsItem; string itemId = newsItem2.source_id != 0L ? newsItem2.source_id.ToString() : ""; this._thumbsItem = new ThumbsItem(this.Width, new Thickness(0.0, margin.Top, 0.0, 0.0), list, false, itemId, false, false, false, 0.0, desiredHeight); this.VirtualizableChildren.Add((IVirtualizable)this._thumbsItem); margin.Top += this._thumbsItem.FixedHeight; if (this._videos.items.Count > 5) { UCItem ucItem = new UCItem(this.Width, margin, (Func <UserControlVirtualizable>)(() => { return((UserControlVirtualizable) new ShowMoreCommentsUC() { Height = 64.0, Text = CommonResources.ShowAll, OnClickAction = new Action(this.HandleShowAll) }); }), (Func <double>)(() => 64.0), (Action <UserControlVirtualizable>)null, 0.0, false); this.VirtualizableChildren.Add((IVirtualizable)ucItem); margin.Top += ucItem.FixedHeight; } else if (this._videos.items.Count == 1) { this.LikesAndCommentsItem = new LikesAndCommentsItem(this.Width, margin, this._videos.items[0], new Action(this.CommentsTapped)); this.VirtualizableChildren.Add((IVirtualizable)this.LikesAndCommentsItem); margin.Top += this.LikesAndCommentsItem.FixedHeight; } else { margin.Top += 12.0; } this._height = margin.Top + 16.0; }
private void _mvm_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (!(e.PropertyName == "UIStatusDelivered") || this._mvm.UIStatusDelivered != Visibility.Visible || this._handledDelivered) { return; } AttachmentsItem attachmentsItem = Enumerable.FirstOrDefault <IVirtualizable>(this.VirtualizableChildren, (Func <IVirtualizable, bool>)(vc => vc is AttachmentsItem)) as AttachmentsItem; ThumbsItem thumbsItem = (attachmentsItem != null ? Enumerable.FirstOrDefault <IVirtualizable>(attachmentsItem.VirtualizableChildren, (Func <IVirtualizable, bool>)(vc => vc is ThumbsItem)) : null) as ThumbsItem; if (thumbsItem != null) { VirtualizableState currentState = thumbsItem.CurrentState; thumbsItem.ChangeState(VirtualizableState.Unloaded); thumbsItem.PrepareThumbsList(); thumbsItem.ChangeState(currentState); } this._handledDelivered = true; }