object HandleImageCropRequest(ImageCropViewController.Request request, object context) { switch (request) { case ImageCropViewController.Request.SupportedInterfaceOrientations: { return((object)(UIInterfaceOrientationMask.LandscapeLeft | UIInterfaceOrientationMask.LandscapeRight)); } case ImageCropViewController.Request.ShouldAutorotate: { return((object)false); } case ImageCropViewController.Request.PreferStatusBarHidden: { return((object)PrefersStatusBarHidden( )); } case ImageCropViewController.Request.IsDeviceLandscape: { return((object)true); } case ImageCropViewController.Request.CropperDone: { // if croppedImage is null, they simply cancelled UIImage croppedImage = (UIImage)context; if (croppedImage != null) { NSData croppedImageData = croppedImage.AsJPEG( ); // notify the initial caller we're done. OnCaptureCompleteDelegate(croppedImageData); OnCaptureCompleteDelegate = null; } ImageCropViewController.DismissModalViewController(true); break; } } return(null); }
public void BeginPictureCapture(OnCaptureComplete onCaptureComplete) { OnCaptureCompleteDelegate = onCaptureComplete; // only allow the camera if they HAVE one if (Rock.Mobile.Media.PlatformCamera.Instance.IsAvailable( )) { // launch the camera string jpgFilename = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "cameraTemp.jpg"); Rock.Mobile.Media.PlatformCamera.Instance.CaptureImage(jpgFilename, this, delegate(object s, Rock.Mobile.Media.PlatformCamera.CaptureImageEventArgs args) { // if the result is true, they either got a picture or pressed cancel bool success = false; if (args.Result == true) { // either way, no need for an error success = true; // if the image path is valid, they didn't cancel if (string.IsNullOrWhiteSpace(args.ImagePath) == false) { // load the image for cropping ImageCropperPendingImage = UIImage.FromFile(args.ImagePath); } } if (success == false) { Rock.Mobile.Util.Debug.DisplayError(Strings.Camera_Error_Header, Strings.Camera_Error_Message); } }); } else { // notify them they don't have a camera Rock.Mobile.Util.Debug.DisplayError(Strings.Camera_None_Header, Strings.Camera_None_Message); onCaptureComplete(null); } }
object HandleImageCropRequest( ImageCropViewController.Request request, object context ) { switch ( request ) { case ImageCropViewController.Request.SupportedInterfaceOrientations: { return (object)(UIInterfaceOrientationMask.LandscapeLeft | UIInterfaceOrientationMask.LandscapeRight); } case ImageCropViewController.Request.ShouldAutorotate: { return (object)false; } case ImageCropViewController.Request.PreferStatusBarHidden: { return (object)PrefersStatusBarHidden( ); } case ImageCropViewController.Request.IsDeviceLandscape: { return (object)true; } case ImageCropViewController.Request.CropperDone: { // if croppedImage is null, they simply cancelled UIImage croppedImage = (UIImage)context; if ( croppedImage != null ) { NSData croppedImageData = croppedImage.AsJPEG( ); // notify the initial caller we're done. OnCaptureCompleteDelegate( croppedImageData ); OnCaptureCompleteDelegate = null; } ImageCropViewController.DismissModalViewController( true ); break; } } return null; }
public void BeginPictureCapture( OnCaptureComplete onCaptureComplete ) { OnCaptureCompleteDelegate = onCaptureComplete; // only allow the camera if they HAVE one if( Rock.Mobile.Media.PlatformCamera.Instance.IsAvailable( ) ) { // launch the camera string jpgFilename = System.IO.Path.Combine ( Environment.GetFolderPath(Environment.SpecialFolder.Personal), "cameraTemp.jpg" ); Rock.Mobile.Media.PlatformCamera.Instance.CaptureImage( jpgFilename, this, delegate(object s, Rock.Mobile.Media.PlatformCamera.CaptureImageEventArgs args) { // if the result is true, they either got a picture or pressed cancel bool success = false; if( args.Result == true ) { // either way, no need for an error success = true; // if the image path is valid, they didn't cancel if ( string.IsNullOrWhiteSpace( args.ImagePath ) == false ) { // load the image for cropping ImageCropperPendingImage = UIImage.FromFile( args.ImagePath ); } } if( success == false ) { Rock.Mobile.Util.Debug.DisplayError( Strings.Camera_Error_Header, Strings.Camera_Error_Message ); } }); } else { // notify them they don't have a camera Rock.Mobile.Util.Debug.DisplayError( Strings.Camera_None_Header, Strings.Camera_None_Message ); onCaptureComplete( null ); } }