コード例 #1
0
		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;
		}
コード例 #2
0
        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);
        }
コード例 #3
0
		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);
		}
コード例 #4
0
        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));
        }