public override void PickImage(object context, ImagePickEvent callback) { // first ensure they passed in the correct context type UIViewController controller = context as UIViewController; if (context == null) { throw new Exception("Context must be a UIViewController"); } // store our callback event ImagePickEventDelegate = callback; // setup the image picker UIImagePickerController imageController = new UIImagePickerController( ); imageController.Delegate = new UIImagePickerControllerDelegate( ); imageController.SourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum; // when media is chosen imageController.FinishedPickingMedia += (object s, UIImagePickerMediaPickedEventArgs mediaArgs) => { //NSUrl assetUrl = (NSUrl) mediaArgs.Info[ new NSString("UIImagePickerControllerReferenceURL")]; //FinishedCallback( true, assetUrl, imageController ); FinishedCallback(true, mediaArgs.OriginalImage, imageController); }; // if they cancel, simply dismiss the controller imageController.Canceled += (object s, EventArgs mediaArgs) => { FinishedCallback(true, null, imageController); }; controller.PresentViewController(imageController, true, null); }
public override void PickImage(object context, ImagePickEvent callback) { // ensure the context passed in is valid. Activity activity = context as Activity; if (activity == null) { throw new Exception("context must be of type Activity."); } ImagePickEventDelegate = callback; // kick off the activity that will manage the camera Intent intent = new Intent(activity, typeof(ImagePickerActivity)); activity.StartActivity(intent); }
public abstract void PickImage(object context, ImagePickEvent callback);