示例#1
0
        private async void TakePictureAsync()
        {
            try
            {
                var stream = await _pictureChooserTask.TakePictureAsync(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);
            }
        }
示例#2
0
        /// <summary>
        /// Deletes an image from both the the view models and datamodels
        /// </summary>
        /// <param name="image"></param>
        internal void Delete(CameraImageViewModel image)
        {
            // remove view model
            ImagesVM.Remove(image);

            RaisePropertyChanged(() => HasPhotoBeenTaken);
            RaisePropertyChanged(() => CommentHintText);
        }
示例#3
0
        /// <summary>
        /// Packs up the image stre
        /// </summary>
        /// <param name="stream"></param>
        private void OnPictureTaken(Stream stream)
        {
            var memoryStream = new MemoryStream();

            stream.CopyTo(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);
        }
示例#4
0
 private void ImagesView_Click(object sender, RoutedEventArgs e)
 {
     DataContext = new ImagesVM();
 }