示例#1
0
        private async void TakePicture(Object sender, EventArgs e)
        {
            var pictureResult = await DependencyService.Get <ICammeraService>().TakePictureAsync();

            EventPhoto image = _e.Image;

            if (pictureResult != null)
            {
                if (image == null)
                {
                    image             = new EventPhoto();
                    image.DateTaken   = DateTime.Now;
                    image.ImageSource = pictureResult.Image;
                    image.Title       = _e.Title;
                    _e.Image          = image;
                }
                else
                {
                    var result = await DisplayAlert("Image Override", "Would you like to overwrite the current event image?", "Yes", "No");

                    if (result)
                    {
                        image.DateTaken   = DateTime.Now;
                        image.ImageSource = pictureResult.Image;
                        image.Title       = _e.Title;
                        _e.Image          = image;
                    }
                }

                OnPropertyChanged();
            }
        }
        public async void Button_Clicked(Object sender, EventArgs e)
        {
            var pictureResult = await _cameraService.TakePictureAsync();

            if (pictureResult != null)
            {
                EventPhoto photo = new EventPhoto();
                photo.ImageSource = pictureResult.Image;
                photo.DateTaken   = DateTime.Now;

                MainList.BindingContext = photo;

                OnPropertyChanged();
            }
        }
        public IEnumerable <EventPhoto> DummyImages()
        {
            List <EventPhoto> images = new List <EventPhoto>();

            EventPhoto p = new EventPhoto();

            p.ImageSource = "Nudgee.jpg";
            p.DateTaken   = DateTime.Now;
            p.Title       = "Demo";

            images.Add(p);

            //new Image() { Source = "Nudgee.jpg" },
            //new Image() { Source = "Nudgee2.JPG" },
            //new Image() { Source = "Nudgee3.jpg" },

            return(images);
        }