private async void ExecuteTakePictureCommand() { try { Busy = true; StorageFile file = null; if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Media.Capture.CameraCaptureUI")) { // Using Windows.Media.Capture.CameraCaptureUI API to capture a photo CameraCaptureUI dialog = new CameraCaptureUI(); Size aspectRatio = new Size(16, 9); dialog.PhotoSettings.CroppedAspectRatio = aspectRatio; try { file = await dialog.CaptureFileAsync(CameraCaptureUIMode.Photo); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } } Busy = false; SavePictureCommand.Execute(file); } finally { Busy = false; } }
private async void ExecuteSelectPictureCommand() { try { Busy = true; FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; openPicker.FileTypeFilter.Add(".jpg"); openPicker.FileTypeFilter.Add(".jpeg"); openPicker.FileTypeFilter.Add(".png"); StorageFile file = await openPicker.PickSingleFileAsync(); SavePictureCommand.Execute(file); } finally { /*Busy = false;*/ } }
private async void ExecuteTakePictureCommand() { try { Busy = true; StorageFile file = null; if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Media.Capture.CameraCaptureUI")) { // Using Windows.Media.Capture.CameraCaptureUI API to capture a photo CameraCaptureUI dialog = new CameraCaptureUI(); Size aspectRatio = new Size(16, 9); dialog.PhotoSettings.CroppedAspectRatio = aspectRatio; file = await dialog.CaptureFileAsync(CameraCaptureUIMode.Photo); } SavePictureCommand.Execute(file); } finally { /*Busy = false;*/ } }