public void UploadUserPhoto(Stream stream, Rect rect) { if (this.IsSaving) { return; } this.IsSaving = true; this.SetInProgress(true, ""); ImagePreprocessor.PreprocessImage(stream, VKConstants.ResizedImageSize, true, (Action <ImagePreprocessResult>)(pres => { Stream stream1 = pres.Stream; byte[] numArray = (byte[])new byte[stream1.Length]; stream1.Read(numArray, 0, (int)stream1.Length); stream1.Close(); UsersService.Instance.SaveProfilePhoto(ImagePreprocessor.GetThumbnailRect((double)pres.Width, (double)pres.Height, rect), numArray, (Action <BackendResult <ProfilePhoto, ResultCode> >)(res => { this.IsSaving = false; this.SetInProgress(false, ""); if (res.ResultCode == ResultCode.Succeeded) { BaseDataManager.Instance.NeedRefreshBaseData = true; BaseDataManager.Instance.RefreshBaseDataIfNeeded(); } else { ExtendedMessageBox.ShowSafe(CommonResources.Error); } })); })); }
public void UpdatePhoto(Stream photoStream, Rect crop) { this.IsPhotoChanging = true; this.SetInProgress(true, ""); ImagePreprocessor.PreprocessImage(photoStream, VKConstants.ResizedImageSize, true, (Action<ImagePreprocessResult>)(resized => { Stream stream = resized.Stream; byte[] photoData = ImagePreprocessor.ReadFully(stream); stream.Close(); BackendServices.MessagesService.UpdateChatPhoto(this.ChatId, photoData, ImagePreprocessor.GetThumbnailRect((double)resized.Width, (double)resized.Height, crop), (Action<BackendResult<ChatInfoWithMessageId, ResultCode>>)(result => Execute.ExecuteOnUIThread((Action)(() => { if (result.ResultCode == ResultCode.Succeeded) { this._chatInformation.chat.photo_200 = result.ResultData.chat.photo_200; this.NotifyPropertyChanged<string>((Expression<Func<string>>)(() => this.Photo)); this.NotifyPropertyChanged<Visibility>((Expression<Func<Visibility>>)(() => this.PhotoPlaceholderVisibility)); this.NotifyPropertyChanged<bool>((Expression<Func<bool>>)(() => this.IsPhotoMenuEnabled)); } else GenericInfoUC.ShowBasedOnResult(result.ResultCode, "", (VKRequestsDispatcher.Error)null); this.SetInProgress(false, ""); this.IsPhotoChanging = false; })))); })); }