private async void EditCamera_Click(object sender, RoutedEventArgs e) { var capture = new CameraCaptureUI(); capture.VideoSettings.AllowTrimming = true; capture.VideoSettings.Format = CameraCaptureUIVideoFormat.Mp4; capture.VideoSettings.MaxResolution = CameraCaptureUIMaxVideoResolution.StandardDefinition; capture.VideoSettings.MaxDurationInSeconds = 9f; capture.PhotoSettings.AllowCropping = true; capture.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg; capture.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.HighestAvailable; var file = await capture.CaptureFileAsync(CameraCaptureUIMode.PhotoOrVideo); if (file != null) { var media = await StorageMedia.CreateAsync(file); var dialog = new EditMediaPopup(media, ImageCropperMask.Ellipse); var confirm = await dialog.ShowAsync(); if (confirm == ContentDialogResult.Primary) { ViewModel.EditPhotoCommand.Execute(media); } } }
public static async Task <StorageMedia> PickSingleMediaAsync(this FileOpenPicker picker) { var file = await picker.PickSingleFileAsync(); if (file == null) { return(null); } return(await StorageMedia.CreateAsync(file)); }
private async void More_Click(object sender, RoutedEventArgs e) { 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) { foreach (var file in files) { var storage = await StorageMedia.CreateAsync(file, true); if (storage != null) { Items.Add(storage); } } } }
public async void EditPhoto_Click(object sender, RoutedEventArgs e) { var picker = new FileOpenPicker(); picker.ViewMode = PickerViewMode.Thumbnail; picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.FileTypeFilter.AddRange(Constants.MediaTypes); var file = await picker.PickSingleFileAsync(); if (file != null) { var media = await StorageMedia.CreateAsync(file); var dialog = new EditMediaPopup(media, ImageCropperMask.Ellipse); var confirm = await dialog.ShowAsync(); if (confirm == ContentDialogResult.Primary) { ViewModel.EditPhotoCommand.Execute(media); } } }
private async void SendMediaExecute() { if (MediaLibrary.SelectedCount > 0) { if (Settings.IsSendGrouped && MediaLibrary.SelectedCount > 1) { var items = MediaLibrary.Where(x => x.IsSelected).ToList(); var group = new List <StorageMedia>(Math.Min(items.Count, 10)); foreach (var item in items) { group.Add(item); if (group.Count == 10) { await SendGroupedAsync(group); group = new List <StorageMedia>(Math.Min(items.Count, 10)); } } if (group.Count > 0) { await SendGroupedAsync(group); } } else { foreach (var storage in MediaLibrary.Where(x => x.IsSelected)) { if (storage is StoragePhoto photo) { var storageFile = await photo.GetFileAsync(); await SendPhotoAsync(storageFile, storage.Caption, storage.IsForceFile, storage.Ttl); } else if (storage is StorageVideo video) { await SendVideoAsync(storage.File, storage.Caption, video.IsMuted, storage.IsForceFile, storage.Ttl, await video.GetEncodingAsync(), video.GetTransform()); } } } return; } 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 && files.Count > 0) { var storages = new ObservableCollection <StorageMedia>(); foreach (var file in files) { var storage = await StorageMedia.CreateAsync(file, true); if (storage != null) { storages.Add(storage); } } SendMediaExecute(storages, storages[0]); } }