//~EditCurrentUserViewModel()
        //{

        //}

        public void SetProfilePhoto()
        {
            EditCurrentUserActions.EditPhoto(photo =>
            {
                var fileId = TLLong.Random();
                IsWorking  = true;
                _uploadManager.UploadFile(fileId, new TLUserSelf(), photo);
            });
        }
        public void SetChannelPhoto()
        {
            EditChatActions.EditPhoto(photo =>
            {
                var volumeId = TLLong.Random();
                var localId  = TLInt.Random();
                var secret   = TLLong.Random();

                var fileLocation = new TLFileLocation
                {
                    VolumeId = volumeId,
                    LocalId  = localId,
                    Secret   = secret,
                    DCId     = new TLInt(0),
                    //Buffer = p.Bytes
                };

                var fileName = String.Format("{0}_{1}_{2}.jpg",
                                             fileLocation.VolumeId,
                                             fileLocation.LocalId,
                                             fileLocation.Secret);

                using (var store = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    using (var fileStream = store.CreateFile(fileName))
                    {
                        fileStream.Write(photo, 0, photo.Length);
                    }
                }

                Photo = new TLChatPhoto
                {
                    PhotoSmall = new TLFileLocation
                    {
                        DCId     = fileLocation.DCId,
                        VolumeId = fileLocation.VolumeId,
                        LocalId  = fileLocation.LocalId,
                        Secret   = fileLocation.Secret
                    },
                    PhotoBig = new TLFileLocation
                    {
                        DCId     = fileLocation.DCId,
                        VolumeId = fileLocation.VolumeId,
                        LocalId  = fileLocation.LocalId,
                        Secret   = fileLocation.Secret
                    }
                };
                NotifyOfPropertyChange(() => Photo);

                _uploadingPhoto = true;

                var fileId = TLLong.Random();
                _uploadManager.UploadFile(fileId, new TLChannel(), photo);
            });
        }
Exemple #3
0
 public void ReplacePhoto()
 {
     if (CurrentItem is TLChat || CurrentItem is TLChannel)
     {
         EditChatActions.EditPhoto(photo =>
         {
             var fileId = TLLong.Random();
             IsWorking  = true;
             _uploadManager.UploadFile(fileId, CurrentItem, photo);
         });
     }
 }
Exemple #4
0
        public void OpenPhoto()
        {
            var chat    = CurrentItem as TLChat;
            var channel = CurrentItem as TLChannel;

            if (chat == null && channel == null)
            {
                return;
            }

            var photoBase = GetPhoto();

            var photo = photoBase as TLChatPhoto;

            if (photo != null)
            {
                StateService.CurrentPhoto = photo;

                if (ProfilePhotoViewer == null)
                {
                    ProfilePhotoViewer = new ProfilePhotoViewerViewModel(StateService, MTProtoService, EventAggregator, NavigationService);
                    NotifyOfPropertyChange(() => ProfilePhotoViewer);
                }

                BeginOnUIThread(() => ProfilePhotoViewer.OpenViewer());
                return;
            }

            var photoEmpty = photoBase as TLChatPhotoEmpty;

            if (photoEmpty != null)
            {
                if ((chat != null && !chat.Left.Value) ||
                    (channel != null && channel.Creator))
                {
                    EditChatActions.EditPhoto(result =>
                    {
                        var fileId = TLLong.Random();
                        IsWorking  = true;
                        _uploadManager.UploadFile(fileId, CurrentItem, result);
                    });
                }
            }
        }