protected override void Dispose(bool disposing) { if (disposing) { if (Element != null) { ((ScannerControl)Element).OnResumeScanning -= ScannerControlRenderer_OnResumeScanning; } if (mrzSannerController != null) { mrzSannerController.CloseScanner(); mrzSannerController.Dispose(); mrzSannerController = null; } } base.Dispose(disposing); }
partial void startPassportImageCapture(UIButton sender) { scannedImage.Image = null; mrzScannerController = new MRZScannerController(); // Options: [Mrz, DocumentImage, DocumentImagePassport]. Default: Mrz. mrzScannerController.SetScannerType(MRZScannerType.DocumentImagePassport); // Enable/disable the ID document type. Default: true. MRZScannerController.SetIDActive(true); // Enable/disable the Passport document type. Default: true. MRZScannerController.SetPassportActive(true); // Enable/disable the Visa document type. Default: true. MRZScannerController.SetVisaActive(true); // Set the max CPU threads that the scanner can use. Default: 2. mrzScannerController.SetMaxCPUCores(2); // Set license key MRZScannerController.RegisterLicenseWithKey("License_key", (result, error) => { if (error != null) { Console.WriteLine("Result code: " + result + ". " + error); } else { Console.WriteLine("Result code: " + result + ". Registration successful."); } }); mrzScannerController.WeakDelegate = this; UIViewController currentViewController = NavigationController; if (currentViewController == null) { currentViewController = this; } currentViewController.AddChildViewController(mrzScannerController); mrzScannerController.InitUI(currentViewController); }
public void SuccessfulScanWithResult(MRZResultDataModel mrzResultDataModel) { UIAlertController alertController = UIAlertController.Create(mrzResultDataModel.FullName, mrzResultDataModel.Document_number, UIAlertControllerStyle.Alert); alertController.AddAction(UIAlertAction.Create("Close", UIAlertActionStyle.Cancel, (obj) => { if (mrzScannerController != null) { mrzScannerController.CloseScanner(); mrzScannerController = null; } })); if (mrzScannerController != null) { alertController.AddAction(UIAlertAction.Create("Resume", UIAlertActionStyle.Default, (obj) => { mrzScannerController.ResumeScanner(); })); } PresentViewController(alertController, true, null); }
protected override void OnElementChanged(ElementChangedEventArgs <View> e) { base.OnElementChanged(e); if (e.OldElement != null || Element == null) { return; } mrzSannerController = new MRZScannerController(); // Options: [ScannerTypeMrz, ScannerTypeDocImageId, ScannerTypeDocImagePassport]. Default: MRZ. switch (((ScannerControl)Element).ScannerType) { case ScanType.Mrz: mrzSannerController.SetScannerType(MRZScannerType.Mrz); break; case ScanType.DocImageId: mrzSannerController.SetScannerType(MRZScannerType.DocumentImageId); break; case ScanType.DocImagePassport: mrzSannerController.SetScannerType(MRZScannerType.DocumentImagePassport); break; default: mrzSannerController.SetScannerType(MRZScannerType.Mrz); break; } // Enable/disable the ID document type. Default: true. MRZScannerController.SetIDActive(((ScannerControl)Element).IDActive); // Enable/disable the Passport document type. Default: true. MRZScannerController.SetPassportActive(((ScannerControl)Element).PassportActive); // Enable/disable the Visa document type. Default: true. MRZScannerController.SetVisaActive(((ScannerControl)Element).VisaActive); // Set the max CPU threads that the scanner can use. Default: 2. mrzSannerController.SetMaxCPUCores(((ScannerControl)Element).MaxThreads); MRZScannerController.SetExtractFullPassportImageEnabled(((ScannerControl)Element).ExtractFullPassportImageEnabled); MRZScannerController.SetExtractIdBackEnabled(((ScannerControl)Element).ExtractIdBackImageEnabled); MRZScannerController.SetExtractPortraitEnabled(((ScannerControl)Element).ExtractPortraitEnabled); MRZScannerController.SetExtractSignatureEnabled(((ScannerControl)Element).ExtractSignatureEnabled); // Set license key MRZScannerController.RegisterLicenseWithKey(((ScannerControl)Element).LicenseKey, (result, error) => { LicenseResultType licenseResult = LicenseResultType.Unknown; switch (result) { case 0: licenseResult = LicenseResultType.Successful; break; case -1: licenseResult = LicenseResultType.Error_While_Parsing; break; case -2: licenseResult = LicenseResultType.Invalid_Licence; break; case -3: licenseResult = LicenseResultType.Invalid_Bundle_ID; break; case -4: licenseResult = LicenseResultType.Invalid_Device_Model; break; case -5: licenseResult = LicenseResultType.Licence_Expired; break; case -6: licenseResult = LicenseResultType.Invalid_Platform; break; } ((ScannerControl)Element).OnLicenseResult(licenseResult); }); mrzSannerController.WeakDelegate = this; UIViewController currentViewController = UIApplication.SharedApplication.KeyWindow.RootViewController.NavigationController != null ? UIApplication.SharedApplication.KeyWindow.RootViewController.NavigationController : UIApplication.SharedApplication.KeyWindow.RootViewController; currentViewController.AddChildViewController(mrzSannerController); mrzSannerController.InitUI(currentViewController); if (Control == null) { SetNativeControl(mrzSannerController.View); } ((ScannerControl)Element).OnResumeScanning += ScannerControlRenderer_OnResumeScanning; }