public FriendRecommendationItem(User user)
 {
     if (user == null)
     {
         this.Type = FriendRecommendationItemType.ContactsSyncPromo;
     }
     else
     {
         this.AddToFriendsButtonIcon       = "../Resources/New/FriendAdd.png";
         this.AddToFriendsButtonForeground = new SolidColorBrush(Color.FromArgb(byte.MaxValue, (byte)81, (byte)129, (byte)184));
         this.Name            = user.Name;
         this.UserId          = user.id;
         this.Description     = user.description;
         this.NameBlockMargin = new Thickness(0.0, !string.IsNullOrEmpty(this.Description) ? 223.0 : 235.0, 50.0, 0.0);
         CropPhoto cropPhoto = user.crop_photo;
         if (cropPhoto != null)
         {
             Photo  photo = cropPhoto.photo;
             double num1  = photo.height > 0 ? (double)photo.width / (double)photo.height : 1.0;
             double num2  = 256.0;
             double num3  = num2 / num1;
             bool   flag  = true;
             if (num1 > 128.0 / 107.0)
             {
                 flag = false;
                 num3 = 214.0;
                 num2 = 214.0 * num1;
             }
             this.PhotoImageWidth  = Math.Round(num2);
             this.PhotoImageHeight = Math.Round(num3);
             Rect croppingRectangle1 = cropPhoto.crop.GetCroppingRectangle(num2, num3);
             Rect croppingRectangle2 = cropPhoto.rect.GetCroppingRectangle(croppingRectangle1.Width, croppingRectangle1.Height);
             croppingRectangle2.X += croppingRectangle1.X;
             croppingRectangle2.Y += croppingRectangle1.Y;
             double num4 = croppingRectangle2.X + croppingRectangle2.Width / 2.0;
             double num5 = croppingRectangle2.Y + croppingRectangle2.Height;
             if (flag)
             {
                 double num6 = croppingRectangle2.Height > 214.0 ? 2.56 : 2.0;
                 double num7 = num5 - (croppingRectangle2.Height - croppingRectangle2.Height / num6);
                 double val1 = 107.0 - num7;
                 if (croppingRectangle2.Height > 214.0 && num7 - croppingRectangle2.Height / 2.0 >= 0.0)
                 {
                     val1 = -croppingRectangle2.Y;
                 }
                 double top = Math.Min(0.0, Math.Max(val1, 214.0 - num3));
                 this.PhotoImageMargin   = new Thickness(0.0, top, 0.0, 0.0);
                 this.PhotoImageClipRect = new Rect(0.0, -(top + 1.0), 256.0, 215.0);
             }
             else
             {
                 double left = Math.Min(0.0, Math.Max(128.0 - num4, 256.0 - num2));
                 this.PhotoImageMargin   = new Thickness(left, 0.0, 0.0, 0.0);
                 this.PhotoImageClipRect = new Rect(-(left + 1.0), 0.0, 257.0, 214.0);
             }
             this.PhotoImageSource = cropPhoto.photo.GetAppropriateForScaleFactor(214.0, 1);
         }
         else
         {
             this.PhotoImageClipRect = new Rect(0.0, 0.0, 10000.0, 10000.0);
             this.PhotoImageSource   = user.photo_400_orig ?? user.photo_200_orig ?? user.photo_max;
             this.PhotoImageWidth    = 256.0;
             this.PhotoImageHeight   = double.NaN;
         }
         EventAggregator.Current.Subscribe((object)this);
     }
 }
Example #2
0
        private void UpdateProfilePhoto(double width, double ratio)
        {
            if (this._userData == null)
            {
                return;
            }
            double    requiredHeight = width / ratio;
            CropPhoto cropPhoto      = this._userData.user.crop_photo;
            string    avatarUrl;

            if (cropPhoto != null)
            {
                bool   flag = true;
                string appropriateForScaleFactor = cropPhoto.photo.GetAppropriateForScaleFactor(requiredHeight, 1);
                Photo  photo  = cropPhoto.photo;
                double num1   = photo.height > 0 ? (double)photo.width / (double)photo.height : 1.0;
                double width1 = width;
                double height = width1 / num1;
                if (num1 > ratio)
                {
                    height = requiredHeight;
                    width1 = requiredHeight * num1;
                    flag   = false;
                }
                this.ProfileImageWidth  = (int)width1;
                this.ProfileImageHeight = (int)height;
                Rect croppingRectangle1 = cropPhoto.crop.GetCroppingRectangle(width1, height);
                // ISSUE: explicit reference operation
                // ISSUE: explicit reference operation
                Rect croppingRectangle2 = cropPhoto.rect.GetCroppingRectangle(((Rect)@croppingRectangle1).Width, ((Rect)@croppingRectangle1).Height);
                // ISSUE: explicit reference operation
                // ISSUE: variable of a reference type
                // ISSUE: explicit reference operation
                double num2 = croppingRectangle2.X + ((Rect)@croppingRectangle1).X;
                croppingRectangle2.X = num2;
                // ISSUE: explicit reference operation
                // ISSUE: variable of a reference type
                // ISSUE: explicit reference operation
                double num3 = croppingRectangle2.Y + ((Rect)@croppingRectangle1).Y;
                croppingRectangle2.Y = num3;
                // ISSUE: explicit reference operation
                // ISSUE: explicit reference operation
                double num4 = ((Rect)@croppingRectangle2).X + ((Rect)@croppingRectangle2).Width / 2.0;
                // ISSUE: explicit reference operation
                // ISSUE: explicit reference operation
                double num5 = ((Rect)@croppingRectangle2).Y + ((Rect)@croppingRectangle2).Height;
                if (flag)
                {
                    // ISSUE: explicit reference operation
                    double num6 = ((Rect)@croppingRectangle2).Height <= requiredHeight ? 2.0 : 2.56;
                    // ISSUE: explicit reference operation
                    // ISSUE: explicit reference operation
                    double num7 = num5 - (((Rect)@croppingRectangle2).Height - ((Rect)@croppingRectangle2).Height / num6);
                    double val1 = requiredHeight / 2.0 - num7;
                    // ISSUE: explicit reference operation
                    // ISSUE: explicit reference operation
                    if (((Rect)@croppingRectangle2).Height > requiredHeight && num7 - ((Rect)@croppingRectangle2).Height / 2.0 >= 0.0)
                    {
                        // ISSUE: explicit reference operation
                        val1 = -((Rect)@croppingRectangle2).Y;
                    }
                    double num8 = Math.Min(0.0, Math.Max(val1, requiredHeight - height));
                    this.ProfileImageMargin   = new Thickness(0.0, num8, 0.0, 0.0);
                    this.ProfileImageClipRect = new Rect(0.0, -(num8 + 1.0), width, requiredHeight + 1.0);
                }
                else
                {
                    double num6 = Math.Min(0.0, Math.Max(width / 2.0 - num4, width - width1));
                    this.ProfileImageMargin   = new Thickness(num6, 0.0, 0.0, 0.0);
                    this.ProfileImageClipRect = new Rect(-(num6 + 1.0), 0.0, width + 1.0, requiredHeight);
                }
                // ISSUE: type reference
                // ISSUE: method reference
                this.NotifyPropertyChanged <Thickness>(() => this.ProfileImageMargin);
                // ISSUE: type reference
                // ISSUE: method reference
                this.NotifyPropertyChanged <Rect>(() => this.ProfileImageClipRect);
                avatarUrl = appropriateForScaleFactor;
            }
            else
            {
                avatarUrl = this._userData.user.photo_max ?? this._userData.user.photo_big;
                this.ProfileImageWidth  = (int)width;
                this.ProfileImageHeight = (int)requiredHeight;
            }
            if (!ProfileHeaderViewModelBase.IsValidAvatarUrl(avatarUrl))
            {
                return;
            }
            this.ProfileImageUrl = avatarUrl;
            // ISSUE: type reference
            // ISSUE: method reference
            this.NotifyPropertyChanged <string>(() => this.ProfileImageUrl);
            // ISSUE: type reference
            // ISSUE: method reference
            this.NotifyPropertyChanged <int>(() => this.ProfileImageWidth);
            // ISSUE: type reference
            // ISSUE: method reference
            this.NotifyPropertyChanged <int>(() => this.ProfileImageHeight);
        }
Example #3
0
 public FriendRecommendationItem(User user)
 {
     if (user == null)
     {
         this.Type = FriendRecommendationItemType.ContactsSyncPromo;
     }
     else
     {
         this.AddToFriendsButtonIcon       = "../Resources/New/FriendAdd.png";
         this.AddToFriendsButtonForeground = new SolidColorBrush(Color.FromArgb(byte.MaxValue, (byte)81, (byte)129, (byte)184));
         this.Name            = user.Name;
         this.UserId          = user.id;
         this.Description     = user.description;
         this.NameBlockMargin = new Thickness(0.0, !string.IsNullOrEmpty(this.Description) ? 223.0 : 235.0, 50.0, 0.0);
         CropPhoto cropPhoto = user.crop_photo;
         if (cropPhoto != null)
         {
             Photo  photo = cropPhoto.photo;
             double num1  = photo.height > 0 ? (double)photo.width / (double)photo.height : 1.0;
             double num2  = 256.0;
             double num3  = num2 / num1;
             bool   flag  = true;
             if (num1 > 128.0 / 107.0)
             {
                 flag = false;
                 num3 = 214.0;
                 num2 = 214.0 * num1;
             }
             this.PhotoImageWidth  = Math.Round(num2);
             this.PhotoImageHeight = Math.Round(num3);
             Rect croppingRectangle1 = cropPhoto.crop.GetCroppingRectangle(num2, num3);
             // ISSUE: explicit reference operation
             // ISSUE: explicit reference operation
             Rect croppingRectangle2 = cropPhoto.rect.GetCroppingRectangle(((Rect)@croppingRectangle1).Width, ((Rect)@croppingRectangle1).Height);
             // ISSUE: explicit reference operation
             // ISSUE: variable of a reference type
             // ISSUE: explicit reference operation
             double num4 = croppingRectangle2.X + ((Rect)@croppingRectangle1).X;
             croppingRectangle2.X = num4;
             // ISSUE: explicit reference operation
             // ISSUE: variable of a reference type
             // ISSUE: explicit reference operation
             double num5 = croppingRectangle2.Y + ((Rect)@croppingRectangle1).Y;
             croppingRectangle2.Y = num5;
             // ISSUE: explicit reference operation
             // ISSUE: explicit reference operation
             double num6 = ((Rect)@croppingRectangle2).X + ((Rect)@croppingRectangle2).Width / 2.0;
             // ISSUE: explicit reference operation
             // ISSUE: explicit reference operation
             double num7 = ((Rect)@croppingRectangle2).Y + ((Rect)@croppingRectangle2).Height;
             if (flag)
             {
                 // ISSUE: explicit reference operation
                 double num8 = ((Rect)@croppingRectangle2).Height > 214.0 ? 2.56 : 2.0;
                 // ISSUE: explicit reference operation
                 // ISSUE: explicit reference operation
                 double num9 = num7 - (((Rect)@croppingRectangle2).Height - ((Rect)@croppingRectangle2).Height / num8);
                 double val1 = 107.0 - num9;
                 // ISSUE: explicit reference operation
                 // ISSUE: explicit reference operation
                 if (((Rect)@croppingRectangle2).Height > 214.0 && num9 - ((Rect)@croppingRectangle2).Height / 2.0 >= 0.0)
                 {
                     // ISSUE: explicit reference operation
                     val1 = -((Rect)@croppingRectangle2).Y;
                 }
                 double num10 = Math.Min(0.0, Math.Max(val1, 214.0 - num3));
                 this.PhotoImageMargin   = new Thickness(0.0, num10, 0.0, 0.0);
                 this.PhotoImageClipRect = new Rect(0.0, -(num10 + 1.0), 256.0, 215.0);
             }
             else
             {
                 double num8 = Math.Min(0.0, Math.Max(128.0 - num6, 256.0 - num2));
                 this.PhotoImageMargin   = new Thickness(num8, 0.0, 0.0, 0.0);
                 this.PhotoImageClipRect = new Rect(-(num8 + 1.0), 0.0, 257.0, 214.0);
             }
             this.PhotoImageSource = cropPhoto.photo.GetAppropriateForScaleFactor(214.0, 1);
         }
         else
         {
             this.PhotoImageClipRect = new Rect(0.0, 0.0, 10000.0, 10000.0);
             this.PhotoImageSource   = user.photo_400_orig ?? user.photo_200_orig ?? user.photo_max;
             this.PhotoImageWidth    = 256.0;
             this.PhotoImageHeight   = double.NaN;
         }
         EventAggregator.Current.Subscribe(this);
     }
 }
        private void UpdateProfilePhoto(double width, double ratio)
        {
            if (this._userData == null)
            {
                return;
            }
            double    num1      = width / ratio;
            CropPhoto cropPhoto = this._userData.user.crop_photo;
            string    avatarUrl;

            if (cropPhoto != null)
            {
                bool   flag = true;
                string appropriateForScaleFactor = cropPhoto.photo.GetAppropriateForScaleFactor(num1, 1);
                Photo  photo  = cropPhoto.photo;
                double num2   = photo.height > 0 ? (double)photo.width / (double)photo.height : 1.0;
                double width1 = width;
                double height = width1 / num2;
                if (num2 > ratio)
                {
                    height = num1;
                    width1 = num1 * num2;
                    flag   = false;
                }
                this.ProfileImageWidth  = (int)width1;
                this.ProfileImageHeight = (int)height;
                Rect croppingRectangle1 = cropPhoto.crop.GetCroppingRectangle(width1, height);
                Rect croppingRectangle2 = cropPhoto.rect.GetCroppingRectangle(croppingRectangle1.Width, croppingRectangle1.Height);
                croppingRectangle2.X += croppingRectangle1.X;
                croppingRectangle2.Y += croppingRectangle1.Y;
                double num3 = croppingRectangle2.X + croppingRectangle2.Width / 2.0;
                double num4 = croppingRectangle2.Y + croppingRectangle2.Height;
                if (flag)
                {
                    double num5 = croppingRectangle2.Height <= num1 ? 2.0 : 2.56;
                    double num6 = num4 - (croppingRectangle2.Height - croppingRectangle2.Height / num5);
                    double val1 = num1 / 2.0 - num6;
                    if (croppingRectangle2.Height > num1 && num6 - croppingRectangle2.Height / 2.0 >= 0.0)
                    {
                        val1 = -croppingRectangle2.Y;
                    }
                    double top = Math.Min(0.0, Math.Max(val1, num1 - height));
                    this.ProfileImageMargin   = new Thickness(0.0, top, 0.0, 0.0);
                    this.ProfileImageClipRect = new Rect(0.0, -(top + 1.0), width, num1 + 1.0);
                }
                else
                {
                    double left = Math.Min(0.0, Math.Max(width / 2.0 - num3, width - width1));
                    this.ProfileImageMargin   = new Thickness(left, 0.0, 0.0, 0.0);
                    this.ProfileImageClipRect = new Rect(-(left + 1.0), 0.0, width + 1.0, num1);
                }
                this.NotifyPropertyChanged <Thickness>((System.Linq.Expressions.Expression <Func <Thickness> >)(() => this.ProfileImageMargin));
                this.NotifyPropertyChanged <Rect>((System.Linq.Expressions.Expression <Func <Rect> >)(() => this.ProfileImageClipRect));
                avatarUrl = appropriateForScaleFactor;
            }
            else
            {
                avatarUrl = this._userData.user.photo_max ?? this._userData.user.photo_big;
                this.ProfileImageWidth  = (int)width;
                this.ProfileImageHeight = (int)num1;
            }
            if (!ProfileHeaderViewModelBase.IsValidAvatarUrl(avatarUrl))
            {
                return;
            }
            this.ProfileImageUrl = avatarUrl;
            this.NotifyPropertyChanged <string>((System.Linq.Expressions.Expression <Func <string> >)(() => this.ProfileImageUrl));
            this.NotifyPropertyChanged <int>((System.Linq.Expressions.Expression <Func <int> >)(() => this.ProfileImageWidth));
            this.NotifyPropertyChanged <int>((System.Linq.Expressions.Expression <Func <int> >)(() => this.ProfileImageHeight));
        }