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;
         }))));
     }));
 }
Пример #2
0
        public override void Upload(Action completionCallback, Action <double> progressCallback = null)
        {
            Action action;

            Execute.ExecuteOnUIThread((Action)(() =>
            {
                if (this.UploadState == OutboundAttachmentUploadState.Uploading)
                {
                    return;
                }
                if (this.UploadState == OutboundAttachmentUploadState.Completed)
                {
                    completionCallback();
                }
                else
                {
                    this.UploadState = OutboundAttachmentUploadState.Uploading;
                    Stream stream = ImageCache.Current.GetCachedImageStream(this.LocalUrlBig);
                    ImagePreprocessor.PreprocessImage(stream, VKConstants.ResizedImageSize, true, (Action <ImagePreprocessResult>)(pres =>
                    {
                        Stream stream2 = pres.Stream;
                        stream.Close();
                        byte[] bytes = ImagePreprocessor.ReadFully(stream2);
                        stream2.Close();
                        this.UploadImpl(bytes, (action = (Action)(() =>
                        {
                            if (this._uploadState == OutboundAttachmentUploadState.Completed && this._photo != null)
                            {
                                this.CleanupCache();
                                this._localUri = this._photo.src_big;
                            }
                            completionCallback();
                        })), progressCallback);
                    }));
                }
            }));
        }