Esempio n. 1
0
        private async void CameraButton_Clicked(object sender, EventArgs e)
        {
            Button clicked = (Button)sender;//disable button

            clicked.IsEnabled = false;

            if (timesPressed == 0)//take photo
            {
                timesPressed++;
                photo = null;
                photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions()
                {
                    SaveToAlbum = true,
                    Directory   = "BGUART",
                    Name        = "photo" + count.ToString()
                });

                count++;
                //save btn


                if (photo != null)
                {
                    source            = photo.GetStream();
                    PhotoImage.Source = ImageSource.FromStream(() => { return(source); });

                    imgSrc = PhotoImage.Source;

                    //Get the public album path
                    aPpath = photo.AlbumPath;

                    //Get private path
                    path = photo.Path;
                }

                CameraButton.Text            = AppResources.save_and_continue;
                CameraButton.BackgroundColor = Color.White;
                AddToLayout(BtnLayout, AppResources.share, ShareButton_Clicked, Color.Orange);


                clicked.IsEnabled = true;//enable button
            }

            else if (timesPressed == 1)//save btn
            {
                if (source != null)
                {
                    pc.AddToPhotosSourcesList(aPpath);
                    pc.AddToPhotosSourcesList(path);

                    //back to previous page
                    scoreLabel.Text = AppResources.score + ": " + gc.EditScore(ScoreRule.Kinds.Taking_Picture_Done);
                    gc.FinishAttraction();
                    await Navigation.PopModalAsync();
                }

                //AddToLayout(BtnLayout, "Save and Continue", SaveBtn_Clicked);//save and continue
            }
        }