Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void CaptureImageCommandHandler()
- {
- Device.BeginInvokeOnMainThread(async () =>
- {
- try
- {
- await CheckPermissionCamera();
- if (Images == null)
- Images = new ObservableCollection<string>();
- // Create a temp image. It'll be detelted after upload this temp image
- var path = await MediaManagement.TakePhoto();
- if (path == null)
- return;
- // Add image
- AddImage(path, Localization.Resource.Photo);
- }
- catch (Exception ex)
- {
- Logger.Exception(ex);
- }
- });
- }
- public async Task<string> TakePhoto(float? width = null, float? height = null)
- {
- try
- {
- await CrossMedia.Current.Initialize();
- var mediaFile = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions());
- if (mediaFile?.Path == null)
- return null;
- // This is: Taking a photo action
- var result = await ResizeImageFile(mediaFile.Path, width, height, true).ConfigureAwait(false);
- return result;
- }
- catch (Exception)
- {
- return null;
- }
- }
Add Comment
Please, Sign In to add comment