Ejemplo n.º 1
0
        /*
         * Called if a full result is found. A full result is considered to be a successful preview, folloewd by a successful full scan.
         */
        void IAnylineDocumentModuleDelegate.HasResult(AnylineDocumentModuleView anylineDocumentModuleView, UIImage transformedImage, UIImage fullFrame, ALSquare corners)
        {
            if (_disposing)
            {
                return;
            }

            if (_scanView == null)
            {
                return;
            }

            //we'll go to a temporary new view controller, so we keep this one alive
            _keepScanViewControllerAlive = true;

            _resultImage = transformedImage;

            using (var vc = new UIViewController())
            {
                var iv = new UIImageView(_scanView.Frame)
                {
                    Image       = _resultImage,
                    ContentMode = UIViewContentMode.ScaleAspectFit
                };
                vc.View.AddSubview(iv);

                NavigationController?.PushViewController(vc, true);
            }

            fullFrame?.Dispose();
            transformedImage?.Dispose();
        }
Ejemplo n.º 2
0
        /*
         * This method is called when a result has been found. We'll show the transformed image on a new viewController.
         */
        void IAnylineDocumentModuleDelegate.HasResult(AnylineDocumentModuleView anylineDocumentModuleView, UIImage transformedImage, UIImage fullFrame)
        {
            //we'll go to a temporary new view controller, so we keep this one alive
            keepScanViewControllerAlive = true;

            this.resultImage = transformedImage;

            using (UIViewController vc = new UIViewController())
            {
                UIImageView iv = new UIImageView(scanView.Frame);
                iv.Image       = resultImage;
                iv.ContentMode = UIViewContentMode.ScaleAspectFit;
                vc.View.AddSubview(iv);

                this.NavigationController.PushViewController(vc, true);
            }

            if (fullFrame != null)
            {
                fullFrame.Dispose();
            }
            if (transformedImage != null)
            {
                transformedImage.Dispose();
            }

            fullFrame        = null;
            transformedImage = null;
        }
Ejemplo n.º 3
0
        public override void ViewDidDisappear(bool animated)
        {
            base.ViewDidDisappear(animated);

            //don't clean up objects, if we want the controller to be kept alive
            if (keepScanViewControllerAlive)
            {
                return;
            }

            //remove notification view
            if (notificationView != null)
            {
                notificationView.RemoveFromSuperview();
                notificationView.Dispose();
                notificationView = null;
            }
            //remove image
            if (resultImage != null)
            {
                resultImage.Dispose();
                resultImage = null;
            }
            //we have to erase the scan view so that there are no dependencies for the viewcontroller left.
            scanView.RemoveFromSuperview();
            scanView.Dispose();
            scanView = null;

            base.Dispose();
        }
Ejemplo n.º 4
0
        new void Dispose()
        {
            //un-register any event handlers here, if you have any

            //we have to erase the scan view so that there are no dependencies for the viewcontroller left.

            _scanView?.RemoveFromSuperview();
            _scanView?.Dispose();
            _scanView = null;

            _resultImage?.Dispose();
            _resultImage = null;

            GC.Collect(GC.MaxGeneration);

            base.Dispose();
        }
Ejemplo n.º 5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Initializing the Bottlecap scan module.
            CGRect frame = UIScreen.MainScreen.ApplicationFrame;

            frame = new CGRect(frame.X,
                               frame.Y + NavigationController.NavigationBar.Frame.Size.Height,
                               frame.Width,
                               frame.Height - NavigationController.NavigationBar.Frame.Size.Height);

            _scanView = new AnylineDocumentModuleView(frame);

            // We tell the module to bootstrap itself with the license key and delegate. The delegate will later get called
            // by the module once we start receiving results.
            _error   = null;
            _success = _scanView.SetupWithLicenseKey(_licenseKey, Self, out _error);
            // SetupWithLicenseKey:delegate:error returns true if everything went fine. In the case something wrong
            // we have to check the error object for the error message.
            if (!_success)
            {
                // Something went wrong. The error object contains the error description
                (_alert = new UIAlertView("Error", _error.DebugDescription, (IUIAlertViewDelegate)null, "OK", null)).Show();
            }

            //stop scanning on result
            _scanView.CancelOnResult = true;

            // to set certain supported ratios, they can be provided as follows:
            //NSNumber[] ratios = { DocumentRatio.BusinessCardLandscape, DocumentRatio.DINAXLandscape };
            //_scanView.SetDocumentRatios(ratios);

            // you can set the max output resolution of your image here so it will be scaled to a desired size
            //_scanView.MaxOutputResolution = new CGSize(width, height);

            // After setup is complete we add the module to the view of this view controller
            View.AddSubview(_scanView);

            // This view notifies the user of any problems that occur while scanning
            _notificationView                = new NotificationView(new CGRect(20, 115, View.Bounds.Width - 40, 30));
            _notificationView.FillColor      = new UIColor((nfloat)(98.0 / 255.0), (nfloat)(39.0 / 255.0), (nfloat)(232.0 / 255.0), (nfloat)(0.6)).CGColor;
            _notificationView.TextLabel.Text = "";
            _notificationView.Alpha          = 0;
            View.Add(_notificationView);
        }
Ejemplo n.º 6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Initializing the Bottlecap scan module.
            CGRect frame = UIScreen.MainScreen.ApplicationFrame;

            frame = new CGRect(frame.X,
                               frame.Y + NavigationController.NavigationBar.Frame.Size.Height,
                               frame.Width,
                               frame.Height - NavigationController.NavigationBar.Frame.Size.Height);

            scanView = new AnylineDocumentModuleView(frame);

            // We tell the module to bootstrap itself with the license key and delegate. The delegate will later get called
            // by the module once we start receiving results.
            error   = null;
            success = scanView.SetupWithLicenseKey(licenseKey, this.Self, out error);
            // SetupWithLicenseKey:delegate:error returns true if everything went fine. In the case something wrong
            // we have to check the error object for the error message.
            if (!success)
            {
                // Something went wrong. The error object contains the error description
                (alert = new UIAlertView("Error", error.DebugDescription, null, "OK", null)).Show();
            }

            //stop scanning on result
            scanView.CancelOnResult = true;

            scanView.TranslatesAutoresizingMaskIntoConstraints = false;

            // After setup is complete we add the module to the view of this view controller
            View.AddSubview(scanView);

            // This view notifies the user of any problems that occur while scanning
            notificationView                = new NotificationView(new CGRect(20, 115, View.Bounds.Width - 40, 30));
            notificationView.fillColor      = new UIColor((nfloat)(98.0 / 255.0), (nfloat)(39.0 / 255.0), (nfloat)(232.0 / 255.0), (nfloat)(0.6)).CGColor;
            notificationView.textLabel.Text = "";
            notificationView.Alpha          = 0;
            View.Add(notificationView);
        }
Ejemplo n.º 7
0
 /*
  * Will be called when AnylineDocumentModuleView.TriggerPictureCornerDetectionAndReturnError is invoked.
  */
 void IAnylineDocumentModuleDelegate.DetectedPictureCorners(AnylineDocumentModuleView anylineDocumentModuleView, ALSquare corners, UIImage image)
 {
 }
Ejemplo n.º 8
0
 /*
  * The taken picture will be processed after this method call.
  */
 void IAnylineDocumentModuleDelegate.TakePictureSuccess(AnylineDocumentModuleView anylineDocumentModuleView)
 {
 }
Ejemplo n.º 9
0
 /*
  * Return true if your implementation consumed the outline (e.g. drew the outline), or false if the DocumentScanView should draw the outline.
  */
 bool IAnylineDocumentModuleDelegate.DocumentOutlineDetected(AnylineDocumentModuleView anylineDocumentModuleView, NSObject[] outline, bool anglesValid)
 {
     return(false);
 }
Ejemplo n.º 10
0
 void IAnylineDocumentModuleDelegate.TakePictureError(AnylineDocumentModuleView anylineDocumentModuleView, NSError error)
 {
     _showingNotification = false;
     ShowNotification("Failed to take picture.");
 }
Ejemplo n.º 11
0
 /*
  * Called if the preview scan detected a sharp and correctly placed document.
  * After this callback, a full frame scan of the document starts automatically.
  */
 void IAnylineDocumentModuleDelegate.ReportsPreviewResult(AnylineDocumentModuleView anylineDocumentModuleView, UIImage image)
 {
     _showingNotification = false;
     ShowNotification("Processing.. Please hold still.");
 }
Ejemplo n.º 12
0
 /*
  * Called if the run on the full frame was unsuccessful. The scanning process automatically starts again with a preview scan.
  */
 void IAnylineDocumentModuleDelegate.ReportsPictureProcessingFailure(AnylineDocumentModuleView anylineDocumentModuleView, ALDocumentError error)
 {
     ShowNotification(error);
 }
Ejemplo n.º 13
0
 void IAnylineDocumentModuleDelegate.TakePictureSuccess(AnylineDocumentModuleView anylineDocumentModuleView)
 {
     new UIAlertView("Success", "Picture successfully taken.", null, "OK", null).Show();
 }
Ejemplo n.º 14
0
 bool IAnylineDocumentModuleDelegate.AnglesValid(AnylineDocumentModuleView anylineDocumentModuleView, ALSquare outline, bool anglesValid)
 {
     return(false);
 }