Beispiel #1
0
        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;
            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);
        }