Exemple #1
0
        private static Border GetImageBorder(string imageUri)
        {
            Border border = new Border();
            double num1   = 32.0;

            ((FrameworkElement)border).Width = num1;
            double num2 = 32.0;

            ((FrameworkElement)border).Height = num2;
            int num3 = 0;

            ((FrameworkElement)border).VerticalAlignment = ((VerticalAlignment)num3);
            SolidColorBrush iconBackground = LikesItem.GetIconBackground(false);

            border.Background = ((Brush)iconBackground);
            double num4 = 16.0;

            Canvas.SetTop((UIElement)border, num4);
            BitmapImage bitmapImage1 = new BitmapImage(new Uri(MultiResolutionHelper.Instance.AppendResolutionSuffix(imageUri, true, ""), UriKind.Relative));
            ImageBrush  imageBrush   = new ImageBrush();
            BitmapImage bitmapImage2 = bitmapImage1;

            imageBrush.ImageSource          = ((ImageSource)bitmapImage2);
            ((UIElement)border).OpacityMask = ((Brush)imageBrush);
            return(border);
        }
Exemple #2
0
        private static Border GetImageBorder(string imageUri)
        {
            Border border = new Border();
            double num1   = 32.0;

            border.Width = num1;
            double num2 = 32.0;

            border.Height = num2;
            SolidColorBrush iconBackground = LikesItem.GetIconBackground(false);

            border.Background = (Brush)iconBackground;
            double length = 16.0;

            Canvas.SetTop((UIElement)border, length);
            BitmapImage bitmapImage = new BitmapImage(new Uri(MultiResolutionHelper.Instance.AppendResolutionSuffix(imageUri, true, ""), UriKind.Relative));

            border.OpacityMask = (Brush) new ImageBrush()
            {
                ImageSource = (ImageSource)bitmapImage
            };
            return(border);
        }
Exemple #3
0
        private void UpdateViews(Border imageLike, TextBlock textBlockLikesCount, Canvas likesCanvas, Border imageRepost, TextBlock textBlockRepostCount, Canvas repostsCanvas, bool updateLikedUsers = true)
        {
            bool loggedInUserLiked = this._loggedInUserLiked;

            imageLike.Background           = ((Brush)LikesItem.GetIconBackground(loggedInUserLiked));
            textBlockLikesCount.Foreground = ((Brush)LikesItem.GetIconCounterForeground(loggedInUserLiked));
            textBlockLikesCount.Text       = (LikesItem.GetTextForCount(this._likesInfo.count));
            double actualWidth1 = ((FrameworkElement)textBlockLikesCount).ActualWidth;

            if (actualWidth1 > 0.0)
            {
                ((FrameworkElement)likesCanvas).Width = (56.0 + actualWidth1 + 20.0);
            }
            else
            {
                ((FrameworkElement)likesCanvas).Width = 64.0;
            }
            Canvas.SetLeft((UIElement)imageLike, 16.0);
            Canvas.SetLeft((UIElement)textBlockLikesCount, 56.0);
            Visibility visibility = this._canRepost ? Visibility.Visible : Visibility.Collapsed;

            ((UIElement)imageRepost).Visibility          = visibility;
            ((UIElement)textBlockRepostCount).Visibility = visibility;
            imageRepost.Background          = ((Brush)LikesItem.GetIconBackground(false));
            textBlockRepostCount.Foreground = ((Brush)LikesItem.GetIconCounterForeground(false));
            textBlockRepostCount.Text       = (LikesItem.GetTextForCount(this._likesInfo.repostsCount));
            double actualWidth2 = ((FrameworkElement)textBlockRepostCount).ActualWidth;
            double num1;

            if (actualWidth2 > 0.0)
            {
                num1 = 56.0 + actualWidth2 + 20.0;
                Canvas.SetLeft((UIElement)imageRepost, 16.0);
            }
            else
            {
                num1 = 64.0;
                Canvas.SetLeft((UIElement)imageRepost, 16.0);
            }
            ((FrameworkElement)repostsCanvas).Width = num1;
            Canvas.SetLeft((UIElement)textBlockRepostCount, 56.0);
            Canvas.SetLeft((UIElement)repostsCanvas, this.Width - num1);
            if (!updateLikedUsers)
            {
                return;
            }
            ((FrameworkElement)this._contentCanvas).Width = (this.Width - (((FrameworkElement)likesCanvas).Width + ((FrameworkElement)repostsCanvas).Width));
            Canvas.SetLeft((UIElement)this._contentCanvas, Math.Max(((FrameworkElement)likesCanvas).Width, 87.0));
            int num2 = 0;

            ((FrameworkElement)this._imageLoggedInUser).Margin = (new Thickness(0.0, 12.0, 0.0, 0.0));
            ((UIElement)this._imageLoggedInUser).Opacity       = (this._loggedInUserLiked ? 1.0 : 0.0);
            if (this._loggedInUserLiked)
            {
                num2 += 44;
            }
            Canvas             canvasUserImages   = this._canvasUserImages;
            TranslateTransform translateTransform = new TranslateTransform();
            double             num3 = (double)num2;

            translateTransform.X = num3;
            ((UIElement)canvasUserImages).RenderTransform = ((Transform)translateTransform);
            int    num4 = 0;
            double num5 = 88.0;

            List <UserLike> .Enumerator enumerator = this._likesInfo.users.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    UserLike userLike = enumerator.Current;
                    if ((double)num4 + num5 > ((FrameworkElement)this._contentCanvas).Width)
                    {
                        break;
                    }
                    User user = (User)Enumerable.FirstOrDefault <User>(this._users, (Func <User, bool>)(u => u.uid == userLike.uid));
                    if (user != null && user.uid != AppGlobalStateManager.Current.LoggedInUserId)
                    {
                        Image  image1      = new Image();
                        double px_per_tick = 40.0 / 10.0 / 2.0;
                        image1.Width  = 40.0;
                        image1.Height = 40.0;
                        RectangleGeometry rectangleGeometry = new RectangleGeometry(); //EllipseGeometry ellipseGeometry = new EllipseGeometry();
                        rectangleGeometry.Rect    = new Rect(0, 0, 40.0, 40.0);        //Point point = new Point(20.0, 20.0);
                        rectangleGeometry.RadiusX = rectangleGeometry.RadiusY = AppGlobalStateManager.Current.GlobalState.UserAvatarRadius * px_per_tick;
                        //ellipseGeometry.Center = new Point(20.0, 20.0);
                        //ellipseGeometry.RadiusX = 20.0;
                        //ellipseGeometry.RadiusY = 20.0;
                        image1.Clip = rectangleGeometry;//image1.Clip = ellipseGeometry;

                        ImageLoader.SetUriSource(image1, user.photo_max);
                        Canvas.SetLeft(image1, (double)num4);
                        Canvas.SetTop(image1, 12.0);
                        this._canvasUserImages.Children.Add(image1);
                        this._imagesUsers.Add(image1);
                        num4 += 44;
                    }
                }
            }
            finally
            {
                enumerator.Dispose();
            }
        }
Exemple #4
0
        private void UpdateViews(Border imageLike, TextBlock textBlockLikesCount, Canvas likesCanvas, Border imageRepost, TextBlock textBlockRepostCount, Canvas repostsCanvas, bool updateLikedUsers = true)
        {
            bool isActive = this._loggedInUserLiked;

            imageLike.Background           = (Brush)LikesItem.GetIconBackground(isActive);
            textBlockLikesCount.Foreground = (Brush)LikesItem.GetIconCounterForeground(isActive);
            textBlockLikesCount.Text       = LikesItem.GetTextForCount(this._likesInfo.count);
            double actualWidth1 = textBlockLikesCount.ActualWidth;

            if (actualWidth1 > 0.0)
            {
                likesCanvas.Width = 56.0 + actualWidth1 + 20.0;
            }
            else
            {
                likesCanvas.Width = 64.0;
            }
            Canvas.SetLeft((UIElement)imageLike, 16.0);
            Canvas.SetLeft((UIElement)textBlockLikesCount, 56.0);
            Visibility visibility = this._canRepost ? Visibility.Visible : Visibility.Collapsed;

            imageRepost.Visibility          = visibility;
            textBlockRepostCount.Visibility = visibility;
            imageRepost.Background          = (Brush)LikesItem.GetIconBackground(false);
            textBlockRepostCount.Foreground = (Brush)LikesItem.GetIconCounterForeground(false);
            textBlockRepostCount.Text       = LikesItem.GetTextForCount(this._likesInfo.repostsCount);
            double actualWidth2 = textBlockRepostCount.ActualWidth;
            double num1;

            if (actualWidth2 > 0.0)
            {
                num1 = 56.0 + actualWidth2 + 20.0;
                Canvas.SetLeft((UIElement)imageRepost, 16.0);
            }
            else
            {
                num1 = 64.0;
                Canvas.SetLeft((UIElement)imageRepost, 16.0);
            }
            repostsCanvas.Width = num1;
            Canvas.SetLeft((UIElement)textBlockRepostCount, 56.0);
            Canvas.SetLeft((UIElement)repostsCanvas, this.Width - num1);
            if (!updateLikedUsers)
            {
                return;
            }
            this._contentCanvas.Width = this.Width - (likesCanvas.Width + repostsCanvas.Width);
            Canvas.SetLeft((UIElement)this._contentCanvas, Math.Max(likesCanvas.Width, 87.0));
            int num2 = 0;

            this._imageLoggedInUser.Margin  = new Thickness(0.0, 12.0, 0.0, 0.0);
            this._imageLoggedInUser.Opacity = this._loggedInUserLiked ? 1.0 : 0.0;
            if (this._loggedInUserLiked)
            {
                num2 += 44;
            }
            this._canvasUserImages.RenderTransform = (Transform) new TranslateTransform()
            {
                X = (double)num2
            };
            int    num3 = 0;
            double num4 = 88.0;

            foreach (UserLike user1 in this._likesInfo.users)
            {
                UserLike userLike = user1;
                if ((double)num3 + num4 > this._contentCanvas.Width)
                {
                    break;
                }
                User user2 = this._users.FirstOrDefault <User>((Func <User, bool>)(u => u.uid == userLike.uid));
                if (user2 != null && user2.uid != AppGlobalStateManager.Current.LoggedInUserId)
                {
                    Image  image1 = new Image();
                    double num5   = 40.0;
                    image1.Width = num5;
                    double num6 = 40.0;
                    image1.Height = num6;
                    image1.Clip   = (Geometry) new EllipseGeometry()
                    {
                        Center  = new Point(20.0, 20.0),
                        RadiusX = 20.0,
                        RadiusY = 20.0
                    };
                    Image image2 = image1;
                    ImageLoader.SetUriSource(image2, user2.photo_max);
                    Canvas.SetLeft((UIElement)image2, (double)num3);
                    Canvas.SetTop((UIElement)image2, 12.0);
                    this._canvasUserImages.Children.Add((UIElement)image2);
                    this._imagesUsers.Add(image2);
                    num3 += 44;
                }
            }
        }