public async void SendPhotoDrop(ObservableCollection <StorageFile> files) { ObservableCollection <StorageMedia> storages = null; if (files != null) { storages = new ObservableCollection <StorageMedia>(files.Select(x => new StoragePhoto(x))); } if (storages != null && storages.Count > 0) { var dialog = new SendPhotosView { Items = storages, SelectedItem = storages[0] }; var dialogResult = await dialog.ShowAsync(); if (dialogResult == ContentDialogBaseResult.OK) { foreach (var storage in dialog.Items) { await SendPhotoAsync(storage.File, storage.Caption); } } } }
public async void SendMediaExecute(ObservableCollection <StorageMedia> media, StorageMedia selectedItem) { var storages = media; if (storages != null && storages.Count > 0) { var dialog = new SendPhotosView { ViewModel = this, Items = storages, SelectedItem = selectedItem, IsTTLEnabled = _peer is TLInputPeerUser }; var dialogResult = await dialog.ShowAsync(); TextField.FocusMaybe(FocusState.Keyboard); if (dialogResult == ContentDialogBaseResult.OK) { foreach (var storage in dialog.Items.Where(x => x.IsSelected)) { if (storage is StoragePhoto photo) { await SendPhotoAsync(storage.File, storage.Caption, storage.TTLSeconds); } else if (storage is StorageVideo video) { await SendVideoAsync(storage.File, storage.Caption, false, await video.GetEncodingAsync()); } } } } }
private async void SendPhotoExecute(StoragePhoto file) { ObservableCollection <StorageMedia> storages = null; if (file == null) { var picker = new FileOpenPicker(); picker.ViewMode = PickerViewMode.Thumbnail; picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.FileTypeFilter.AddRange(Constants.MediaTypes); var files = await picker.PickMultipleFilesAsync(); if (files != null) { storages = new ObservableCollection <StorageMedia>(files.Select(x => x.Name.EndsWith(".mp4") ? new StorageVideo(x) : (StorageMedia) new StoragePhoto(x))); } } else { storages = new ObservableCollection <StorageMedia> { file }; } if (storages != null && storages.Count > 0) { var dialog = new SendPhotosView { ViewModel = this, Items = storages, SelectedItem = storages[0], IsTTLEnabled = _peer is TLInputPeerUser }; var dialogResult = await dialog.ShowAsync(); TextField.FocusMaybe(FocusState.Keyboard); if (dialogResult == ContentDialogBaseResult.OK) { foreach (var storage in dialog.Items) { if (storage is StoragePhoto photo) { await SendPhotoAsync(storage.File, storage.Caption, storage.TTLSeconds); } else if (storage is StorageVideo video) { MediaEncodingProfile profile = null; if (video.IsMuted) { profile = await MediaEncodingProfile.CreateFromFileAsync(storage.File); profile.Audio = null; } await SendVideoAsync(storage.File, storage.Caption, false, profile); } } } } }
private async void SendPhotoExecute(StoragePhoto file) { ObservableCollection <StorageMedia> storages = null; if (file == null) { var picker = new FileOpenPicker(); picker.ViewMode = PickerViewMode.Thumbnail; picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.FileTypeFilter.AddRange(Constants.MediaTypes); var files = await picker.PickMultipleFilesAsync(); if (files != null) { storages = new ObservableCollection <StorageMedia>(files.Select(x => x.Name.EndsWith(".mp4") ? new StorageVideo(x) : (StorageMedia) new StoragePhoto(x))); } } else { storages = new ObservableCollection <StorageMedia> { file }; } if (storages != null && storages.Count > 0) { var dialog = new SendPhotosView { Items = storages, SelectedItem = storages[0] }; var dialogResult = await dialog.ShowAsync(); if (dialogResult == ContentDialogBaseResult.OK) { foreach (var storage in dialog.Items) { if (storage is StoragePhoto) { await SendPhotoAsync(storage.File, storage.Caption); } } } } }
public async void SendPhotoDrop(ObservableCollection <StorageFile> files) { ObservableCollection <StorageMedia> storages = null; if (files != null) { storages = new ObservableCollection <StorageMedia>(files.Select(x => new StoragePhoto(x))); } if (storages != null && storages.Count > 0) { var dialog = new SendPhotosView { ViewModel = this, Items = storages, SelectedItem = storages[0], IsTTLEnabled = _peer is TLInputPeerUser }; var dialogResult = await dialog.ShowAsync(); TextField.FocusMaybe(FocusState.Keyboard); if (dialogResult == ContentDialogBaseResult.OK) { foreach (var storage in dialog.Items) { if (storage is StoragePhoto photo) { await SendPhotoAsync(storage.File, storage.Caption, storage.TTLSeconds); } else if (storage is StorageVideo video) { MediaEncodingProfile profile = null; if (video.IsMuted) { profile = await MediaEncodingProfile.CreateFromFileAsync(storage.File); profile.Audio = null; } await SendVideoAsync(storage.File, storage.Caption, false, profile); } } } } }
private async void SendMediaExecute(ObservableCollection <StorageMedia> media) { if (MediaLibrary.SelectedCount > 0) { foreach (var storage in MediaLibrary.Where(x => x.IsSelected)) { if (storage is StoragePhoto photo) { await SendPhotoAsync(storage.File, storage.Caption, storage.TTLSeconds); } else if (storage is StorageVideo video) { await SendVideoAsync(storage.File, storage.Caption, false, await video.GetEncodingAsync()); } } return; } ObservableCollection <StorageMedia> storages = media; if (media == null) { var picker = new FileOpenPicker(); picker.ViewMode = PickerViewMode.Thumbnail; picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.FileTypeFilter.AddRange(Constants.MediaTypes); var files = await picker.PickMultipleFilesAsync(); if (files != null) { storages = new ObservableCollection <StorageMedia>(); foreach (var file in files) { if (file.ContentType.Equals("video/mp4")) { storages.Add(await StorageVideo.CreateAsync(file, true)); } else { storages.Add(new StoragePhoto(file) { IsSelected = true }); } } } } //else //{ // storages = new ObservableCollection<StorageMedia>(media); //} if (storages != null && storages.Count > 0) { var dialog = new SendPhotosView { ViewModel = this, Items = storages, SelectedItem = storages[0], IsTTLEnabled = _peer is TLInputPeerUser }; var dialogResult = await dialog.ShowAsync(); TextField.FocusMaybe(FocusState.Keyboard); if (dialogResult == ContentDialogBaseResult.OK) { foreach (var storage in dialog.Items.Where(x => x.IsSelected)) { if (storage is StoragePhoto photo) { await SendPhotoAsync(storage.File, storage.Caption, storage.TTLSeconds); } else if (storage is StorageVideo video) { await SendVideoAsync(storage.File, storage.Caption, false, await video.GetEncodingAsync()); } } } } }