public GroupProfileHeaderViewModel(GroupData groupData) { this.VerifiedVisibility = Visibility.Collapsed; this.CoverImageVisibility = Visibility.Collapsed; this.DataVisibility = Visibility.Collapsed; Group group = groupData != null ? groupData.group : null; if (group == null) { return; } this.Name = group.name; this.Description = group.GroupType == GroupType.Event ? CommonResources.Event : group.activity; this.ProfileImageUrl = group.photo_200; this.VerifiedVisibility = groupData.IsVerified.ToVisiblity(); CoverImage coverImage = groupData.CoverImage; if (coverImage != null) { this.CoverImageUrl = coverImage.url; if (!string.IsNullOrEmpty(this.CoverImageUrl)) { this.CoverImageVisibility = Visibility.Visible; } } this.HasAvatar = ProfileHeaderViewModelBase.IsValidAvatarUrl(group.photo_200); this.DataVisibility = Visibility.Visible; }
public GroupProfileHeaderViewModel(GroupData groupData) { if (groupData == null || groupData.group == null) { return; } Group group = groupData.group; this.Name = group.name; this.Description = group.GroupType == GroupType.Event ? CommonResources.Event : group.activity; this.ProfileImageUrl = group.photo_200; this.VerifiedVisibility = groupData.IsVerified ? Visibility.Visible : Visibility.Collapsed; this._hasAvatar = ProfileHeaderViewModelBase.IsValidAvatarUrl(group.photo_200); }
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); }
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)); }