Beispiel #1
0
        private async void onSelectPhoto()
        {
            try
            {
                var media = CrossMedia.Current;
                if (!media.IsPickPhotoSupported)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "File directory is not found!", "OK");
                }

                var img = await media.PickPhotoAsync();

                if (img != null)
                {
                    var manager = new ServiceManager();
                    var result  = await manager.Request(img.GetStream());

                    _model = JsonConvert.DeserializeObject <ComputerVisionModel.Rootobject>(result);

                    SelectedPhoto = img.Path + " is selected.";
                    IsVisible     = true;
                    BindData();
                }
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", "Message: " + ex.Message, "OK");
            }
        }
Beispiel #2
0
        private async void onTakePhoto()
        {
            try
            {
                var media = CrossMedia.Current;
                if (!media.IsTakePhotoSupported)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Camera not available!", "OK");
                }

                var img = await media.TakePhotoAsync(new StoreCameraMediaOptions());

                if (img != null)
                {
                    var manager = new ServiceManager();
                    var result  = await manager.Request(img.GetStream());

                    _model    = JsonConvert.DeserializeObject <ComputerVisionModel.Rootobject>(result);
                    IsVisible = true;
                    BindData();
                }
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", "Message: " + ex.Message, "OK");
            }
        }