Ejemplo n.º 1
0
        public async Task<IMediaFile> TakePhoto(CameraOptions options) {
            if (!this.IsCameraAvailable)
                throw new ArgumentException("Camera is not available");

            options = options ?? new CameraOptions();
            try {
                var file = await this.picker.TakePhotoAsync(new StoreCameraMediaOptions {
                    Directory = options.GetDirectory(),
                    Name = options.GetFileName(),
                    DefaultCamera = (XamCamDevice)Enum.Parse(typeof(XamCamDevice), options.Camera.ToString())
                });

                return new MediaFile(file);
            }
            catch (OperationCanceledException) {
                return null;
            }
        }
Ejemplo n.º 2
0
        public async Task <IMediaFile> TakePhoto(CameraOptions options)
        {
            if (!this.IsCameraAvailable)
            {
                throw new ArgumentException("Camera is not available");
            }

            options = options ?? new CameraOptions();
            try {
                var file = await this.picker.TakePhotoAsync(new StoreCameraMediaOptions {
                    Directory     = options.GetDirectory(),
                    Name          = options.GetFileName(),
                    DefaultCamera = (XamCamDevice)Enum.Parse(typeof(XamCamDevice), options.Camera.ToString())
                });

                return(new MediaFile(file));
            }
            catch (OperationCanceledException) {
                return(null);
            }
        }