Example #1
0
        private async void SelectPictureFromLibraryAsync()
        {
            try
            {
                var stream = await _pictureChooserTask.ChoosePictureFromLibraryAsync(400, 95);

                var memoryStream = new MemoryStream();
                await stream.CopyToAsync(memoryStream);

                int   sequenceNumber = (ImagesVM.Any()) ? _imagesVM.Max(i => i.Image.Sequence) + 1 : 1;
                Image image          = new Image()
                {
                    ID = Guid.NewGuid(), Sequence = sequenceNumber, Bytes = memoryStream.ToArray(), Filename = string.Format("{0} {1}.jpg", _infoService.CurrentDriverDisplayName, DateTime.Now.ToString("yyyy-MM-ddHH-mm-ss"))
                };

                //Add to view model
                CameraImageViewModel imageViewModel = new CameraImageViewModel(image, this);
                ImagesVM.Add(imageViewModel);
                RaisePropertyChanged(() => HasPhotoBeenTaken);
                RaisePropertyChanged(() => CommentHintText);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #2
0
        private async void SelectPicture()
        {
            var pictureStream = await _pictureChooserTask.ChoosePictureFromLibraryAsync(MaxPicturePixelDimension, PictureQuality);

            var memoryStream = new MemoryStream();
            await pictureStream.CopyToAsync(memoryStream);

            PictureBytes = memoryStream.ToArray();
        }