private void ComposeContentTextInlines(Link link, bool hasProduct, bool hasRating) { this.titleBlock.Text = (!string.IsNullOrWhiteSpace(link.title) ? link.title : CommonResources.Link); if (link.money_transfer != null) { this.titleBlock.Text = link.money_transfer.amount.text; } if (hasProduct && !hasRating) { this.priceBlock.Text = link.product.price.text; ((UIElement)this.priceBlock).Visibility = Visibility.Visible; } string str = link.description; if (string.IsNullOrWhiteSpace(str)) { LinkProduct product = link.product; str = product != null ? product.description : null; } if (string.IsNullOrWhiteSpace(str)) { return; } this.descriptionBlock.Text = str; ((UIElement)this.descriptionBlock).Visibility = Visibility.Visible; }
private double GenerateMarket() { double num = 0.0; NewsItem newsItem = this._newsItemData.NewsItem; if (this._headerItem == null) { this._headerItem = new UserOrGroupHeaderItem(this.Width, new Thickness(), true, newsItem.date, (User)null, this._newsItemData.Groups.FirstOrDefault <Group>((Func <Group, bool>)(g => g.id == -this._newsItemData.NewsItem.source_id)), "", PostIconType.None, PostSourcePlatform.None, new Action(this.OnMoreOptionsTap), null, ""); this._headerItem.SetMenu(this.GenerateMenuItems()); this.VirtualizableChildren.Add((IVirtualizable)this._headerItem); } this._headerItem.ViewMargin = new Thickness(); double top = num + (this._headerItem.FixedHeight + 16.0); if (this._marketItem == null) { Product product = new Product() { owner_id = newsItem.owner_id, id = newsItem.id, title = newsItem.title, thumb_photo = newsItem.thumb_photo, availability = newsItem.availability, price = newsItem.price, category = newsItem.category }; Link link1 = new Link(); link1.title = newsItem.title; link1.caption = CommonResources.Product; link1.photo = new Photo() { photo_75 = newsItem.thumb_photo }; LinkProduct linkProduct = new LinkProduct(product); link1.product = linkProduct; string str = string.Format("http://vk.com/product{0}_{1}", (object)product.owner_id, (object)product.id); link1.url = str; Link link = link1; NewsLinkUCBase tmpUC = (NewsLinkUCBase) new NewsLinkMediumUC(); tmpUC.Initialize(link, this.Width); this._marketItem = new UCItem(this.Width - 16.0, new Thickness(), (Func <UserControlVirtualizable>)(() => { NewsLinkMediumUC newsLinkMediumUc = new NewsLinkMediumUC(); //Link link = link; double width = this.Width; newsLinkMediumUc.Initialize(link, width); return((UserControlVirtualizable)newsLinkMediumUc); }), (Func <double>)(() => tmpUC.CalculateTotalHeight()), (Action <UserControlVirtualizable>)null, 0.0, false); this.VirtualizableChildren.Add((IVirtualizable)this._marketItem); } this._marketItem.ViewMargin = new Thickness(8.0, top, 8.0, 0.0); return(top + this._marketItem.FixedHeight + 16.0); }
private double CreateProduct(double topMargin) { if (this._product == null) { return(0.0); } topMargin += this._isMessage ? 0.0 : 8.0; double num = this._isMessage || this._isCommentAttachments ? 16.0 : 0.0; double width = this._verticalWidth + num * 2.0; double horizontalWidth = this._horizontalWidth + num * 2.0; if (this._isMessage) { if (this._productSmallItem != null) { this._productSmallItem.Margin = new Thickness(-num, topMargin, -num, 0.0); this._productSmallItem.IsHorizontal = this.IsHorizontal; } else { this._productSmallItem = new GenericAttachmentItem(width, new Thickness(-num, topMargin, -num, 0.0), this._attachments.FirstOrDefault <Attachment>((Func <Attachment, bool>)(a => a.market != null)), this._isHorizontal, horizontalWidth, this._hyperlinkId); this.VirtualizableChildren.Add((IVirtualizable)this._productSmallItem); } return(this._productSmallItem.FixedHeight); } if (this._productItem != null) { this._productItem.Margin = new Thickness(-num, topMargin, -num, 0.0); } else { Link link = new Link(); link.title = this._product.title; link.caption = CommonResources.Product; link.photo = new Photo() { photo_75 = this._product.thumb_photo }; LinkProduct linkProduct = new LinkProduct(this._product); link.product = linkProduct; string str = string.Format("http://vk.com/product{0}_{1}", (object)this._product.owner_id, (object)this._product.id); link.url = str; this._productItem = this.CreateSnippetItem(link, topMargin); this.VirtualizableChildren.Add((IVirtualizable)this._productItem); } return(this._productItem.FixedHeight); }
private UCItem CreateSnippetItem(Product product, double topMargin) { Link link = new Link(); link.title = product.title; link.caption = CommonResources.Product; link.photo = new Photo() { photo_75 = product.thumb_photo }; LinkProduct linkProduct = new LinkProduct(product); link.product = linkProduct; string str = string.Format("https://vk.com/product{0}_{1}", product.owner_id, product.id); link.url = str; return(this.CreateSnippetItem(link, topMargin)); }
public override void Initialize(Link link, double width, string parentPostId = "") { this._link = link; this._parentPostId = parentPostId; LinkProduct product = link.product; string str1; if (product == null) { str1 = null; } else { Price price = product.price; str1 = price != null ? price.text : null; } bool hasProduct = !string.IsNullOrEmpty(str1); bool hasRating = link.rating != null; double val2 = this.titleBlock.LineHeight * 3.0; this.ComposeContentTextInlines(link, hasProduct, hasRating); TextBlock titleBlock = this.titleBlock; TextBlock priceBlock = this.priceBlock; TextBlock descriptionBlock = this.descriptionBlock; double num1 = width; double width1 = ((FrameworkElement)this.canvasImageContainer).Width; Thickness margin = ((FrameworkElement)this.gridContent).Margin; // ISSUE: explicit reference operation double left = ((Thickness)@margin).Left; double num2 = width1 + left; margin = ((FrameworkElement)this.gridContent).Margin; // ISSUE: explicit reference operation double right = ((Thickness)@margin).Right; double num3 = num2 + right; double num4; double num5 = num4 = num1 - num3; ((FrameworkElement)descriptionBlock).Width = num4; double num6; double num7 = num6 = num5; ((FrameworkElement)priceBlock).Width = num6; double num8 = num7; ((FrameworkElement)titleBlock).Width = num8; ((FrameworkElement)this.titleBlock).MaxHeight = (this.titleBlock.LineHeight * (hasProduct || hasRating ? 2.0 : 3.0)); if (((FrameworkElement)this.titleBlock).ActualHeight < ((FrameworkElement)this.titleBlock).MaxHeight) { ((FrameworkElement)this.descriptionBlock).MaxHeight = (((FrameworkElement)this.titleBlock).MaxHeight - ((FrameworkElement)this.titleBlock).ActualHeight); } else { ((UIElement)this.descriptionBlock).Visibility = Visibility.Collapsed; } if (hasRating) { ((UIElement)this.panelProductRating).Visibility = Visibility.Visible; if (hasProduct) { ((UIElement)this.textBlockPrice).Visibility = Visibility.Visible; this.textBlockPrice.Text = link.product.price.text; } ((UIElement)this.ucRating).Visibility = Visibility.Visible; this.ucRating.Value = link.rating.stars; long reviewsCount = link.rating.reviews_count; if (reviewsCount > 0L) { ((UIElement)this.textBlockVotesCount).Visibility = Visibility.Visible; this.textBlockVotesCount.Text = (string.Format("({0})", UIStringFormatterHelper.FormatForUIVeryShort(reviewsCount))); } } if (!string.IsNullOrEmpty(link.caption) && !hasProduct | hasRating) { ((UIElement)this.textBlockCaption).Visibility = Visibility.Visible; this.textBlockCaption.Text = link.caption; this._actualHeight = this._actualHeight + this.GetElementTotalHeight((FrameworkElement)this.textBlockCaption); } LinkButton linkButton1 = link.button; if (linkButton1 == null & hasProduct) { Link link1 = link; LinkButton linkButton2 = new LinkButton(); linkButton2.title = CommonResources.ViewProduct; string str2 = string.Format("https://vk.com/product{0}_{1}", link.product.owner_id, link.product.id); linkButton2.url = str2; LinkButton linkButton3 = linkButton2; link1.button = linkButton2; linkButton1 = linkButton3; } if (!string.IsNullOrWhiteSpace(linkButton1 != null ? linkButton1.title : null)) { ((UIElement)this.buttonAction).Visibility = Visibility.Visible; ((ContentControl)this.buttonAction).Content = linkButton1.title; this._actualHeight = this._actualHeight + this.GetElementTotalHeight((FrameworkElement)this.buttonAction); } this._actualHeight = this._actualHeight + Math.Min(((FrameworkElement)this.titleBlock).ActualHeight + ((FrameworkElement)this.priceBlock).ActualHeight + ((FrameworkElement)this.descriptionBlock).ActualHeight + ((FrameworkElement)this.textBlockPrice).ActualHeight, val2); this._actualHeight = Math.Min(this._actualHeight, 152.0); this._actualHeight = Math.Max(this._actualHeight, 100.0); double actualHeight = this._actualHeight; margin = ((FrameworkElement)this.gridContent).Margin; // ISSUE: explicit reference operation double top = ((Thickness)@margin).Top; margin = ((FrameworkElement)this.gridContent).Margin; // ISSUE: explicit reference operation double bottom = ((Thickness)@margin).Bottom; double num9 = top + bottom; this._actualHeight = actualHeight + num9; ((FrameworkElement)this.canvasImageContainer).Height = this._actualHeight; this._imageUri = link.photo.GetAppropriateForScaleFactor(this._actualHeight, 1).ConvertToUri(); }
public override void Initialize(Link link, double width, string parentPostId = "") { Photo photo = link.photo; if (photo != null) { double width1 = (double)photo.width; double height = (double)photo.height; if (height > 0.0 && width1 > 0.0) { double requiredHeight = ((FrameworkElement)this.imageContainer).Width / (width1 / height); this._imageUri = ExtensionsBase.ConvertToUri(photo.GetAppropriateForScaleFactor(requiredHeight, 1)); } } double actualHeight1 = this._actualHeight; double height1 = ((FrameworkElement)this.imageContainer).Height; Thickness margin1 = ((FrameworkElement)this.imageContainer).Margin; // ISSUE: explicit reference operation double top1 = margin1.Top; double num1 = height1 + top1; Thickness margin2 = ((FrameworkElement)this.imageContainer).Margin; // ISSUE: explicit reference operation double bottom1 = ((Thickness)@margin2).Bottom; double num2 = num1 + bottom1; this._actualHeight = actualHeight1 + num2; this._link = link; if (!string.IsNullOrEmpty(link.url) && MetroInMotion.GetTilt((DependencyObject)this.LayoutRoot) != 1.2) { MetroInMotion.SetTilt((DependencyObject)this.LayoutRoot, 1.2); } this.ComposeContentTextInlines(link); double num3 = width; LinkButton button = link.button; string str1 = button != null ? button.title : null; Thickness margin3; if (!string.IsNullOrEmpty(str1)) { ((UIElement)this.actionButton).Visibility = Visibility.Visible; ((ContentControl)this.actionButton).Content = str1; ((UIElement)this.actionButton).Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); TextBlock textBlock1 = new TextBlock(); FontFamily fontFamily = new FontFamily("Segoe WP Semibold"); textBlock1.FontFamily = fontFamily; double num4 = 20.0; textBlock1.FontSize = num4; string str2 = str1; textBlock1.Text = str2; TextBlock textBlock2 = textBlock1; double num5 = num3; double actualWidth = ((FrameworkElement)textBlock2).ActualWidth; margin3 = ((FrameworkElement)this.actionButton).Margin; // ISSUE: explicit reference operation double left = ((Thickness)@margin3).Left; double num6 = actualWidth + left; margin3 = ((FrameworkElement)this.actionButton).Margin; // ISSUE: explicit reference operation double right = ((Thickness)@margin3).Right; double num7 = num6 + right + 53.0; num3 = num5 - num7; } ((FrameworkElement)this.textBlockContent).Width = num3; LinkProduct product = link.product; string str3; if (product == null) { str3 = null; } else { Price price = product.price; str3 = price != null ? price.text : null; } string str4 = str3; LinkRating rating = link.rating; bool flag1 = !string.IsNullOrEmpty(str4); bool flag2 = rating != null; if (flag1 | flag2) { ((UIElement)this.ratingContainer).Visibility = Visibility.Visible; if (flag1) { ((UIElement)this.priceBlock).Visibility = Visibility.Visible; this.priceBlock.Text = str4; } if (flag2) { ((UIElement)this.ratingUC).Visibility = Visibility.Visible; this.ratingUC.Value = rating.stars; long reviewsCount = rating.reviews_count; if (reviewsCount > 0L) { ((UIElement)this.votesCountBlock).Visibility = Visibility.Visible; this.votesCountBlock.Text = (string.Format("({0})", UIStringFormatterHelper.FormatForUIVeryShort(reviewsCount))); } } ((FrameworkElement)this.actionButton).VerticalAlignment = ((VerticalAlignment)2); this._actualHeight = this._actualHeight + this.GetElementTotalHeight((FrameworkElement)this.ratingContainer); } string caption = link.caption; if (!string.IsNullOrEmpty(caption)) { ((UIElement)this.captionBlock).Visibility = Visibility.Visible; this.captionBlock.Text = caption; this._actualHeight = this._actualHeight + this.GetElementTotalHeight((FrameworkElement)this.captionBlock); } this._actualHeight = this._actualHeight + Math.Min(((FrameworkElement)this.textBlockContent).ActualHeight, ((FrameworkElement)this.textBlockContent).MaxHeight); double actualHeight2 = this._actualHeight; margin3 = ((FrameworkElement)this.textContainer).Margin; // ISSUE: explicit reference operation double top2 = ((Thickness)@margin3).Top; margin3 = ((FrameworkElement)this.textContainer).Margin; // ISSUE: explicit reference operation double bottom2 = ((Thickness)@margin3).Bottom; double num8 = top2 + bottom2; this._actualHeight = actualHeight2 + num8; }
public override void Initialize(Link link, double width, string parentPostId = "") { this._link = link; this._parentPostId = parentPostId; double val1 = (double)link.photo.width / (double)link.photo.height; double num1 = Math.Max(val1, 1.5); double num2 = width; double num3 = Math.Round(num2 / num1); this._imageUri = ExtensionsBase.ConvertToUri(link.photo.GetAppropriateForScaleFactor(num2 / val1, 1)); ((FrameworkElement)this.canvasImageContainer).Height = num3; ((FrameworkElement)this.canvasImageContainer).Width = num2; ((FrameworkElement)this.imagePreview).Height = num3; ((FrameworkElement)this.imagePreview).Width = num2; this._actualHeight = this._actualHeight + num3; this.ComposeContentTextInlines(link); double num4 = width; Thickness margin1 = ((FrameworkElement)this.gridContent).Margin; // ISSUE: explicit reference operation double left1 = margin1.Left; double num5 = num4 - left1; Thickness margin2 = ((FrameworkElement)this.gridContent).Margin; // ISSUE: explicit reference operation double right = ((Thickness)@margin2).Right; double num6 = num5 - right; LinkButton button = link.button; if (button != null) { ((UIElement)this.buttonAction).Visibility = Visibility.Visible; ((ContentControl)this.buttonAction).Content = button.title; ((UIElement)this.buttonAction).Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); TextBlock textBlock = new TextBlock(); FontFamily fontFamily = new FontFamily("Segoe WP Semibold"); textBlock.FontFamily = fontFamily; double num7 = 20.0; textBlock.FontSize = num7; string title = button.title; textBlock.Text = title; double actualWidth = (double)(int)((FrameworkElement)textBlock).ActualWidth; Thickness margin3 = ((FrameworkElement)this.buttonAction).Margin; // ISSUE: explicit reference operation double left2 = ((Thickness)@margin3).Left; double num8 = actualWidth + left2; Thickness margin4 = ((FrameworkElement)this.buttonAction).Margin; // ISSUE: explicit reference operation double num9 = -((Thickness)@margin4).Right; double num10 = num8 + num9 + 32.0; num6 -= num10; } ((FrameworkElement)this.textBlockContent).Width = num6; LinkProduct product = link.product; string str; if (product == null) { str = null; } else { Price price = product.price; str = price != null ? price.text : null; } bool flag1 = !string.IsNullOrEmpty(str); bool flag2 = link.rating != null; if (flag1 | flag2) { ((UIElement)this.panelProductRating).Visibility = Visibility.Visible; if (flag1) { ((UIElement)this.textBlockPrice).Visibility = Visibility.Visible; this.textBlockPrice.Text = link.product.price.text; } if (flag2) { ((UIElement)this.ucRating).Visibility = Visibility.Visible; this.ucRating.Value = link.rating.stars; long reviewsCount = link.rating.reviews_count; if (reviewsCount > 0L) { ((UIElement)this.textBlockVotesCount).Visibility = Visibility.Visible; this.textBlockVotesCount.Text = (string.Format("({0})", UIStringFormatterHelper.FormatForUIVeryShort(reviewsCount))); } } ((FrameworkElement)this.buttonAction).VerticalAlignment = ((VerticalAlignment)2); this._actualHeight = this._actualHeight + this.GetElementTotalHeight((FrameworkElement)this.panelProductRating); } if (!string.IsNullOrEmpty(link.caption)) { ((UIElement)this.textBlockCaption).Visibility = Visibility.Visible; this.textBlockCaption.Text = link.caption; this._actualHeight = this._actualHeight + this.GetElementTotalHeight((FrameworkElement)this.textBlockCaption); } this._actualHeight = this._actualHeight + Math.Min(((FrameworkElement)this.textBlockContent).ActualHeight, ((FrameworkElement)this.textBlockContent).MaxHeight); double actualHeight = this._actualHeight; Thickness margin5 = ((FrameworkElement)this.gridContent).Margin; // ISSUE: explicit reference operation double top = ((Thickness)@margin5).Top; Thickness margin6 = ((FrameworkElement)this.gridContent).Margin; // ISSUE: explicit reference operation double bottom = ((Thickness)@margin6).Bottom; double num11 = top + bottom; this._actualHeight = actualHeight + num11; }
public override void Initialize(Link link, double width, string parentPostId = "") { this._link = link; LinkProduct product = link.product; string str1; if (product == null) { str1 = null; } else { Price price = product.price; str1 = price != null ? price.text : null; } bool hasProduct = !string.IsNullOrEmpty(str1); bool hasRating = link.rating != null; double val2 = this.titleBlock.LineHeight * 3.0; this.ComposeContentTextInlines(link, hasProduct, hasRating); ((FrameworkElement)this.titleBlock).MaxHeight = (this.titleBlock.LineHeight * (hasProduct || hasRating ? 2.0 : 3.0)); if (((FrameworkElement)this.titleBlock).ActualHeight < ((FrameworkElement)this.titleBlock).MaxHeight) { ((FrameworkElement)this.descriptionBlock).MaxHeight = (((FrameworkElement)this.titleBlock).MaxHeight - ((FrameworkElement)this.titleBlock).ActualHeight); } else { ((UIElement)this.descriptionBlock).Visibility = Visibility.Collapsed; } if (hasRating) { ((UIElement)this.productContainer).Visibility = Visibility.Visible; if (hasProduct) { ((UIElement)this.ratingPriceBlock).Visibility = Visibility.Visible; this.ratingPriceBlock.Text = link.product.price.text; } ((UIElement)this.ratingUC).Visibility = Visibility.Visible; this.ratingUC.Value = link.rating.stars; long reviewsCount = link.rating.reviews_count; if (reviewsCount > 0L) { ((UIElement)this.votesCountBlock).Visibility = Visibility.Visible; this.votesCountBlock.Text = (string.Format("({0})", UIStringFormatterHelper.FormatForUIVeryShort(reviewsCount))); } } if (!string.IsNullOrEmpty(link.caption) && !hasProduct | hasRating) { ((UIElement)this.captionBlock).Visibility = Visibility.Visible; this.captionBlock.Text = link.caption; ((FrameworkElement)this.captionBlock).Height = (((FrameworkElement)this.captionBlock).ActualHeight); this._actualHeight = this._actualHeight + this.GetElementTotalHeight((FrameworkElement)this.captionBlock); } LinkButton linkButton1 = link.button; if (linkButton1 == null & hasProduct) { Link link1 = link; LinkButton linkButton2 = new LinkButton(); linkButton2.title = CommonResources.View; string str2 = string.Format("https://vk.com/product{0}_{1}", link.product.owner_id, link.product.id); linkButton2.url = str2; LinkButton linkButton3 = linkButton2; link1.button = linkButton2; linkButton1 = linkButton3; } if (link.money_transfer != null || !string.IsNullOrWhiteSpace(linkButton1 != null ? linkButton1.title : null)) { ((UIElement)this.actionButton).Visibility = Visibility.Visible; if (link.money_transfer == null) { ((ContentControl)this.actionButton).Content = linkButton1.title; } else { ((ContentControl)this.actionButton).Content = (this.CanShowCard ? CommonResources.Open : CommonResources.AboutService); } this._actualHeight = this._actualHeight + this.GetElementTotalHeight((FrameworkElement)this.actionButton); } this._actualHeight = this._actualHeight + Math.Min(((FrameworkElement)this.titleBlock).ActualHeight + ((FrameworkElement)this.priceBlock).ActualHeight + ((FrameworkElement)this.descriptionBlock).ActualHeight + ((FrameworkElement)this.ratingPriceBlock).ActualHeight, val2); this._actualHeight = Math.Min(this._actualHeight, 156.0); this._actualHeight = Math.Max(this._actualHeight, 112.0); double actualHeight = this._actualHeight; Thickness margin = ((FrameworkElement)this.textContainer).Margin; // ISSUE: explicit reference operation double top = ((Thickness)@margin).Top; margin = ((FrameworkElement)this.textContainer).Margin; // ISSUE: explicit reference operation double bottom = ((Thickness)@margin).Bottom; double num = top + bottom; this._actualHeight = actualHeight + num; ((FrameworkElement)this.imageContainer).Height = this._actualHeight; this._imageUrl = this._link.money_transfer != null ? "/Resources/MoneyTransfers/Snippet.png" : link.photo.GetAppropriateForScaleFactor(this._actualHeight, 1); if (string.IsNullOrEmpty(this._link.url) || MetroInMotion.GetTilt((DependencyObject)this.LayoutRoot) == 1.2) { return; } MetroInMotion.SetTilt((DependencyObject)this.LayoutRoot, 1.2); }