Beispiel #1
0
        private async void EditPhotoExecute(StorageFile file)
        {
            var fileLocation = new TLFileLocation
            {
                VolumeId = TLLong.Random(),
                LocalId  = TLInt.Random(),
                Secret   = TLLong.Random(),
                DCId     = 0
            };

            var fileName  = string.Format("{0}_{1}_{2}.jpg", fileLocation.VolumeId, fileLocation.LocalId, fileLocation.Secret);
            var fileCache = await FileUtils.CreateTempFileAsync(fileName);

            await file.CopyAndReplaceAsync(fileCache);

            var fileScale = fileCache;

            var basicProps = await fileScale.GetBasicPropertiesAsync();

            var imageProps = await fileScale.Properties.GetImagePropertiesAsync();

            var fileId = TLLong.Random();
            var upload = await _uploadFileManager.UploadFileAsync(fileId, fileCache.Name);

            if (upload != null)
            {
                var response = await ProtoService.EditChatPhotoAsync(_item.Id, new TLInputChatUploadedPhoto { File = upload.ToInputFile() });

                if (response.IsSucceeded)
                {
                }
            }
        }
Beispiel #2
0
        protected override async void SendExecute()
        {
            var config = CacheService.GetConfig();

            if (config == null)
            {
                return;
            }

            var peers = new TLVector <TLInputUserBase>(SelectedItems.Select(x => x.ToInputUser()));

            if (peers.Count <= config.ChatSizeMax)
            {
                // Classic chat
                var response = await ProtoService.CreateChatAsync(peers, _title);

                if (response.IsSucceeded)
                {
                    var updates = response.Result as TLUpdates;
                    if (updates != null)
                    {
                        CacheService.SyncUsersAndChats(updates.Users, updates.Chats, tuple => { });

                        var chat = updates.Chats.FirstOrDefault() as TLChat;
                        if (chat != null)
                        {
                            if (_photo != null)
                            {
                                var edit = await ProtoService.EditChatPhotoAsync(chat.Id, new TLInputChatUploadedPhoto { File = _photo });

                                if (edit.IsSucceeded)
                                {
                                }
                                else
                                {
                                }
                            }

                            NavigationService.NavigateToDialog(chat);
                            NavigationService.RemoveLast();
                            NavigationService.RemoveLast();
                        }
                    }
                }
                else
                {
                    Execute.ShowDebugMessage("messages.createChat error " + response.Error);
                }
            }
            else
            {
            }
        }