public void Handle(UploadableItem item) { if (item.Owner == CurrentItem) { IsWorking = false; } }
public void Handle(UploadableItem item) { var userSelf = item.Owner as TLUserSelf; if (userSelf != null) { MTProtoService.UploadProfilePhotoAsync( new TLInputFile { Id = item.FileId, MD5Checksum = new TLString(MD5Core.GetHashString(item.Bytes).ToLowerInvariant()), Name = new TLString(Guid.NewGuid() + ".jpg"), Parts = new TLInt(item.Parts.Count) }, new TLString(""), new TLInputGeoPointEmpty(), new TLInputPhotoCropAuto(), photosPhoto => { MTProtoService.GetFullUserAsync(new TLInputUserSelf(), userFull => { }, error => { }); }, error => { }); return; } var chat = item.Owner as TLChat; if (chat != null) { MTProtoService.EditChatPhotoAsync( chat.Id, new TLInputChatUploadedPhoto { File = new TLInputFile { Id = item.FileId, MD5Checksum = new TLString(MD5Core.GetHashString(item.Bytes).ToLowerInvariant()), Name = new TLString("chatPhoto.jpg"), Parts = new TLInt(item.Parts.Count) }, Crop = new TLInputPhotoCropAuto() }, photosPhoto => { //MTProtoService.GetFullChatAsync((chat).Id, userFull => //{ // //NotifyOfPropertyChange(() => CurrentItem); //}, //error => { }); }, error => { }); } }
public static UploadableItem GetUploadableItem(TLLong fileId, TLObject owner, StorageFile file, TLString key, TLString iv) { var item = new UploadableItem(fileId, owner, file, key, iv); var task = file.GetBasicPropertiesAsync().AsTask(); task.Wait(); var propertie = task.Result; var size = propertie.Size; item.Parts = GetItemParts(item, (int)size); return(item); }
private static List <UploadablePart> GetItemParts(UploadableItem item, int size) { var chunkSize = GetChunkSize(size); var partsCount = GetPartsCount(size, chunkSize); var parts = new List <UploadablePart>(partsCount); for (var i = 0; i < partsCount; i++) { var part = new UploadablePart(item, new TLInt(i), i * chunkSize, Math.Min(chunkSize, (long)size - i * chunkSize)); parts.Add(part); } item.IsSmallFile = size < Constants.SmallFileMaxSize; // size < chunkSize; return(parts); }
public UploadingCanceledEventArgs(UploadableItem item) { Item = item; }
public UploadProgressChangedEventArgs(UploadableItem item, double progress) { Item = item; Progress = progress; }
public void Handle(UploadableItem item) { var userSelf = item.Owner as TLUserSelf; if (userSelf != null) { MTProtoService.UploadProfilePhotoAsync( new TLInputFile { Id = item.FileId, MD5Checksum = new TLString(MD5Core.GetHashString(item.Bytes).ToLowerInvariant()), Name = new TLString(Guid.NewGuid() + ".jpg"), Parts = new TLInt(item.Parts.Count) }, new TLString(""), new TLInputGeoPointEmpty(), new TLInputPhotoCropAuto(), photosPhoto => { MTProtoService.GetFullUserAsync(new TLInputUserSelf(), userFull => { }, error => { }); }, error => { }); return; } var channel = item.Owner as TLChannel; if (channel != null) { if (channel.Id != null) { MTProtoService.EditPhotoAsync( channel, new TLInputChatUploadedPhoto { File = new TLInputFile { Id = item.FileId, MD5Checksum = new TLString(MD5Core.GetHashString(item.Bytes).ToLowerInvariant()), Name = new TLString("channelPhoto.jpg"), Parts = new TLInt(item.Parts.Count) }, Crop = new TLInputPhotoCropAuto() }, statedMessage => { var updates = statedMessage as TLUpdates; if (updates != null) { var updateNewMessage = updates.Updates.FirstOrDefault(x => x is TLUpdateNewChannelMessage) as TLUpdateNewChannelMessage; if (updateNewMessage != null) { EventAggregator.Publish(updateNewMessage.Message); } } }, error => { Execute.ShowDebugMessage("messages.editChatPhoto error " + error); }); } } var chat = item.Owner as TLChat; if (chat != null) { MTProtoService.EditChatPhotoAsync( chat.Id, new TLInputChatUploadedPhoto { File = new TLInputFile { Id = item.FileId, MD5Checksum = new TLString(MD5Core.GetHashString(item.Bytes).ToLowerInvariant()), Name = new TLString("chatPhoto.jpg"), Parts = new TLInt(item.Parts.Count) }, Crop = new TLInputPhotoCropAuto() }, statedMessage => { var updates = statedMessage as TLUpdates; if (updates != null) { var updateNewMessage = updates.Updates.FirstOrDefault(x => x is TLUpdateNewMessage) as TLUpdateNewMessage; if (updateNewMessage != null) { EventAggregator.Publish(updateNewMessage.Message); } } }, error => { Execute.ShowDebugMessage("messages.editChatPhoto error " + error); }); } }
public void Handle(UploadableItem item) { }