private async Task SelectWireframe(WireframeViewModel wireframe) { if (wireframe == null) { return; } SelectedWireframe = null; var wireframeViewModel = new WireframeDetailViewModel(wireframe, wireframeStore, pageService); wireframeViewModel.WireframeUpdated += (source, updatedWireframe) => { wireframe.WireframeId = updatedWireframe.WireframeId; wireframe.Title = updatedWireframe.Title; wireframe.Description = updatedWireframe.Description; wireframe.Date = updatedWireframe.Date; wireframe.FileName = updatedWireframe.FileName; wireframe.FileLocation = updatedWireframe.FileLocation; wireframe.FileDate = updatedWireframe.FileDate; }; await pageService.PushAsync(new WireframeDetailPage(wireframeViewModel)); }
private async Task CapturePicture(WireframeViewModel wireframe) { await CrossMedia.Current.Initialize(); if (CrossMedia.Current.IsCameraAvailable && CrossMedia.Current.IsTakePhotoSupported) { DateTime currentDateTime = DateTime.Now; StoreCameraMediaOptions options = new StoreCameraMediaOptions { Directory = "Captures", Name = $"{currentDateTime.ToString("yyyyMMddHHmmssff")}.jpg", PhotoSize = PhotoSize.Medium, CompressionQuality = 50 }; var capturedImage = await CrossMedia.Current.TakePhotoAsync(options); if (capturedImage == null) { return; } Wireframe.FileName = options.Name; Wireframe.FileLocation = capturedImage.Path; Wireframe.FileDate = currentDateTime; OnPropertyChanged(nameof(Wireframe)); } else { await App.Current.MainPage.DisplayAlert( "Cannot Take Photo", "This device does not support taking a photo", "OK"); return; } }
public WireframeDetailViewModel(WireframeViewModel viewModel, IWireframeStore store, IPageService service) { if (viewModel == null) { throw new ArgumentNullException(nameof(viewModel)); } wireframeStore = store; pageService = service; SaveWireframeCommand = new Command(async() => await SaveWireframe()); CapturePictureCommand = new Command(async() => await CapturePicture(viewModel)); SelectPictureCommand = new Command(async() => await SelectPicture()); Wireframe = new Wireframe { WireframeId = viewModel.WireframeId, Title = viewModel.Title, Description = viewModel.Description, Date = viewModel.Date, FileName = viewModel.FileName, FileLocation = viewModel.FileLocation, FileDate = viewModel.FileDate }; }