public static void OnResult(Result resultCode) { if (resultCode == Result.Canceled) { tcs.TrySetResult(null); return; } if (resultCode != Result.Ok) { tcs.TrySetException(new Exception("Unexpected error")); return; } CameraResult res = new CameraResult(); res.Picture = ImageSource.FromFile(file.Path); res.FilePath = file.Path; tcs.TrySetResult(res); }
private void CameraCaptureTaskOnCompleted(object sender, PhotoResult photoResult) { if (photoResult.TaskResult == TaskResult.None) { tcs.TrySetException(photoResult.Error); return; } if (photoResult.TaskResult == TaskResult.Cancel) { tcs.TrySetResult(null); return; } CameraResult result = new CameraResult(); result.Picture = ImageSource.FromStream(() => photoResult.ChosenPhoto); result.FilePath = photoResult.OriginalFileName; tcs.TrySetResult(result); }
private void CheckClientHardDriveStatus(CameraResult cameraResult) { var status = this.client.CheckHardDriveStatus(); cameraResult.HardDriveStatus = new HardDriveStatusDTO { Capacity = status.Capacity, FreeSpace = status.FreeSpace, PictureCapacity = status.PictureCapacity, FreePictureSpace = status.FreePictureSpace, HDAttr = status.HDAttr, HdStatus = status.HdStatus, HDType = status.HDType, Recycling = status.Recycling, }; this.logger.Info(status.ToString()); if (status.IsErrorStatus) { throw new InvalidOperationException("HD error"); } }
public Task <CameraResult> TakePictureAsync() { var tcs = new TaskCompletionSource <CameraResult>(); Camera.TakePicture(UIApplication.SharedApplication.KeyWindow.RootViewController, (imagePickerResult) => { if (imagePickerResult == null) { tcs.TrySetResult(null); return; } var photo = imagePickerResult.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage; // You can get photo meta data with using the following // var meta = obj.ValueForKey(new NSString("UIImagePickerControllerMediaMetadata")) as NSDictionary; var documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); string jpgFilename = Path.Combine(documentsDirectory, Guid.NewGuid() + ".jpg"); NSData imgData = photo.AsJPEG(); NSError err = null; if (imgData.Save(jpgFilename, false, out err)) { CameraResult result = new CameraResult(); result.Picture = ImageSource.FromStream(imgData.AsStream); result.FilePath = jpgFilename; tcs.TrySetResult(result); } else { tcs.TrySetException(new Exception(err.LocalizedDescription)); } }); return(tcs.Task); }
public static CameraResult GetCameraInfo() { var result = new CameraResult(); if (!CanGetCameraInfo() || !MemoryHandler.Instance.IsAttached) { return(result); } try { var cameraAddress = (IntPtr)Scanner.Instance.Locations[Signatures.CameraKey]; if (cameraAddress.ToInt64() > 0) { var heading = MemoryHandler.Instance.GetSingle(cameraAddress, MemoryHandler.Instance.Structures.CameraInfo.Heading); var elevation = MemoryHandler.Instance.GetSingle(cameraAddress, MemoryHandler.Instance.Structures.CameraInfo.Elevation); var mode = MemoryHandler.Instance.GetByte(cameraAddress, MemoryHandler.Instance.Structures.CameraInfo.Mode); result.CameraInfo.Heading = heading; result.CameraInfo.Elevation = elevation; result.CameraInfo.Mode = mode; if (Math.Abs(heading) <= Math.PI && Math.Abs(elevation) <= Math.PI) { result.CameraInfo.IsValid = true; } } } catch (Exception ex) { MemoryHandler.Instance.RaiseException(Logger, ex, true); } return(result); }
public void OnCaptureResult(CameraResult result) { UnlockFocus(); }