コード例 #1
0
 public void Handle(UploadableItem item)
 {
     if (item.Owner == CurrentItem)
     {
         IsWorking = false;
     }
 }
コード例 #2
0
        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 =>
                {
                });
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public UploadingCanceledEventArgs(UploadableItem item)
 {
     Item = item;
 }
コード例 #6
0
 public UploadProgressChangedEventArgs(UploadableItem item, double progress)
 {
     Item     = item;
     Progress = progress;
 }
コード例 #7
0
        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);
                });
            }
        }
コード例 #8
0
 public void Handle(UploadableItem item)
 {
 }