private async void SelectPicture(bool useCamera)
        {
            SelectPictureResult pictureResult = null;

            if (useCamera)
            {
                var takePicture = DependencyService.Get <ITakePictureCommand>();
                var request     = new TakePictureRequest {
                    MaxPixelDimension = ImageBoundSize, CameraOption = CameraOption.Back
                };
                pictureResult = await takePicture.ExecuteAsync(request);
            }
            else
            {
                var choosePicture = DependencyService.Get <IChoosePictureCommand>();
                var request       = new ChoosePictureRequest {
                    MaxPixelDimension = ImageBoundSize
                };
                pictureResult = await choosePicture.ExecuteAsync(request);
            }

            if (pictureResult.TaskResult == TaskResult.Success)
            {
                ImageFile = pictureResult.Image;
            }
        }
Ejemplo n.º 2
0
        private async void SelectPicture()
        {
            SelectPictureResult pictureResult = null;

            if (UseCamera)
            {
                var takePicture = DependencyService.Get <ITakePictureCommand>();
                var request     = new TakePictureRequest {
                    MaxPixelDimension = 130, CameraOption = CameraOption.Back
                };
                pictureResult = await takePicture.ExecuteAsync(request);
            }
            else
            {
                var choosePicture = DependencyService.Get <IChoosePictureCommand>();
                var request       = new ChoosePictureRequest {
                    MaxPixelDimension = 130
                };
                pictureResult = await choosePicture.ExecuteAsync(request);
            }

            if (pictureResult.TaskResult == TaskResult.Success)
            {
                var analyseImage  = DependencyService.Get <IAnalyseImageCommand>();
                var analyseResult = await analyseImage.ExecuteAsync(new AnalyseImageContext { Image = pictureResult.Image });

                if (analyseResult.IsValid())
                {
                    Model.Logo  = pictureResult.Image;
                    _logoWidth  = analyseResult.Width;
                    _logoHeight = analyseResult.Height;
                }
                else
                {
                    Model.Logo = pictureResult.Image;
                }
            }
        }