Пример #1
0
        public PhotoViewModel(IUserDialogService dialogs, IMediaPicker picker) {
            this.dialogs = dialogs;
            this.picker = picker;

            this.FromCamera = new Command(async () => {
                if (!picker.IsCameraAvailable)
                    dialogs.Alert("Camera is not available");
                else { 
                    var result = await picker.TakePhoto();
                    this.OnPhotoReceived(result);
                }
            });

            this.FromGallery = new Command(async () => {
                if (!picker.IsPhotoGalleryAvailable)
                    dialogs.Alert("Photo Gallery is unavailable");
                else { 
                    var result = await picker.PickPhoto();
                    this.OnPhotoReceived(result);
                }
            });

            this.Choice = new Command(() => dialogs.ActionSheet(new ActionSheetConfig()
                .Add("Camera", () => this.FromCamera.Execute(null))
                .Add("Gallery", () => this.FromGallery.Execute(null))
                .Add("Cancel")
            ));
        }
Пример #2
0
        public PhotoViewModel(IUserDialogService dialogs, IMediaPicker picker)
        {
            this.dialogs = dialogs;

            this.FromCamera = new Command(async() => {
                if (!picker.IsCameraAvailable)
                {
                    dialogs.Alert("Camera is not available");
                }
                else
                {
                    var result = await picker.TakePhoto();
                    this.OnPhotoReceived(result);
                }
            });

            this.FromGallery = new Command(async() => {
                if (!picker.IsPhotoGalleryAvailable)
                {
                    dialogs.Alert("Photo Gallery is unavailable");
                }
                else
                {
                    var result = await picker.PickPhoto();
                    this.OnPhotoReceived(result);
                }
            });

            this.Choice = new Command(() => dialogs.ActionSheet(new ActionSheetConfig()
                                                                .Add("Camera", () => this.FromCamera.Execute(null))
                                                                .Add("Gallery", () => this.FromGallery.Execute(null))
                                                                .Add("Cancel")
                                                                ));
        }
Пример #3
0
        async void ImageFromCamera()
        {
            if (!_mediaPicker.IsCameraAvailable)
            {
                _userDialogService.Alert("Camera is not available");
            }
            else
            {
                var result = await _mediaPicker.TakePhoto();

                this.OnImageReceived(result);
            }
        }