public Task<MediaFile> TakePhotoAsync (StoreCameraMediaOptions options) { options.VerifyOptions(); var ntcs = new TaskCompletionSource<MediaFile> (options); if (Interlocked.CompareExchange (ref this.completionSource, ntcs, null) != null) throw new InvalidOperationException ("Only one operation can be active at a time"); this.cameraCapture.Show(); return ntcs.Task; }
public Task <MediaFile> TakePhotoAsync(StoreCameraMediaOptions options) { options.VerifyOptions(); var ntcs = new TaskCompletionSource <MediaFile> (options); if (Interlocked.CompareExchange(ref this.completionSource, ntcs, null) != null) { throw new InvalidOperationException("Only one operation can be active at a time"); } this.cameraCapture.Show(); return(ntcs.Task); }
public async Task<MediaFile> TakePhotoAsync (StoreCameraMediaOptions options) { options.VerifyOptions(); var capture = new CameraCaptureUI(); var result = await capture.CaptureFileAsync (CameraCaptureUIMode.Photo).AsTask (false); if (result == null) throw new TaskCanceledException(); StorageFolder folder = ApplicationData.Current.LocalFolder; string path = options.GetFilePath (folder.Path); folder = await StorageFolder.GetFolderFromPathAsync (Path.GetDirectoryName (path)); string filename = Path.GetFileName (path); IStorageFile file = await result.CopyAsync (folder, filename, NameCollisionOption.GenerateUniqueName).AsTask (false); return new MediaFile (file.Path, () => file.OpenStreamForReadAsync().Result); }
public async Task <MediaFile> TakePhotoAsync(StoreCameraMediaOptions options) { options.VerifyOptions(); var capture = new CameraCaptureUI(); var result = await capture.CaptureFileAsync(CameraCaptureUIMode.Photo).AsTask(false); if (result == null) { throw new TaskCanceledException(); } StorageFolder folder = ApplicationData.Current.LocalFolder; string path = options.GetFilePath(folder.Path); folder = await StorageFolder.GetFolderFromPathAsync(Path.GetDirectoryName(path)); string filename = Path.GetFileName(path); IStorageFile file = await result.CopyAsync(folder, filename, NameCollisionOption.GenerateUniqueName).AsTask(false); return(new MediaFile(file.Path, () => file.OpenStreamForReadAsync().Result)); }