protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.activity_main); //global::Xamarin.Forms.Forms.Init(this, bundle); //LoadApplication(new App()); nameTv = FindViewById <TextView>(Resource.Id.nameTv); showScanner = FindViewById <TextView>(Resource.Id.showScannerLink); recognizeImage = FindViewById <TextView>(Resource.Id.recognizeImageLink); portraitIv = FindViewById <ImageView>(Resource.Id.portraitIv); docImageIv = FindViewById <ImageView>(Resource.Id.documentImageIv); scenarioLv = FindViewById <ListView>(Resource.Id.scenariosList); doRfidCb = FindViewById <CheckBox>(Resource.Id.doRfidCb); sharedPreferences = GetSharedPreferences(MY_SHARED_PREFS, FileCreationMode.Private); updateDBDialog = showDialog("Updating DB"); DocumentReader.Instance().PrepareDatabase(this, "Full", this); }
//Document Reader Completions public void OnInitCompleted(bool success, DocumentReaderException error) { DocReaderInitEvent readerInitEvent = new DocReaderInitEvent() { IsSuccess = success }; if (success) { Console.WriteLine("Initialized sucessfully"); IList <Scenario> data = new List <Scenario>(); foreach (DocumentReaderScenario scenario in DocumentReader.Instance().AvailableScenarios) { var scenarion = new Scenario() { Name = scenario.Name, Description = scenario.Description }; data.Add(scenarion); } readerInitEvent.Scenarios = data; readerInitEvent.IsRfidAvailable = DocumentReader.Instance().IsRFIDAvailableForUse; } else { Console.WriteLine("Initialization failed:" + error); } ScenariosObtained(this, readerInitEvent); }
public void OnCompleted(int action, DocumentReaderResults results, DocumentReaderException error) { if (action == DocReaderAction.Complete) { if (loadingDialog != null && loadingDialog.IsShowing) { loadingDialog.Dismiss(); } //Checking, if nfc chip reading should be performed if (!isStartRfid && doRfid && results != null && results.ChipPage != 0) { //setting the chip's access key - mrz on car access number string accessKey = null; if ((accessKey = results.GetTextFieldValueByType(EVisualFieldType.FtMrzStringsIcaoRfid)) != null && !String.IsNullOrEmpty(accessKey)) { accessKey = results.GetTextFieldValueByType(EVisualFieldType.FtMrzStringsIcaoRfid).Replace("^", "").Replace("\n", ""); DocumentReader.Instance().RfidScenario().Mrz = accessKey; DocumentReader.Instance().RfidScenario().PacePasswordType = ERFID_Password_Type.PptMrz; } else if ((accessKey = results.GetTextFieldValueByType(EVisualFieldType.FtMrzStrings)) != null && !String.IsNullOrEmpty(accessKey)) { accessKey = results.GetTextFieldValueByType(EVisualFieldType.FtMrzStrings).Replace("^", "").Replace("\n", ""); DocumentReader.Instance().RfidScenario().Mrz = accessKey; DocumentReader.Instance().RfidScenario().PacePasswordType = ERFID_Password_Type.PptMrz; } else if ((accessKey = results.GetTextFieldValueByType(EVisualFieldType.FtCardAccessNumber)) != null && !String.IsNullOrEmpty(accessKey)) { DocumentReader.Instance().RfidScenario().Password = accessKey; DocumentReader.Instance().RfidScenario().PacePasswordType = ERFID_Password_Type.PptCan; } //starting chip reading DocumentReader.Instance().StartRFIDReader(this, this); isStartRfid = true; } else { DisplayResults(results); isStartRfid = false; } } else { //something happened before all results were ready if (action == DocReaderAction.Cancel) { Toast.MakeText(this, "Scanning was cancelled", ToastLength.Long).Show(); isStartRfid = false; } else if (action == DocReaderAction.Error) { Toast.MakeText(this, "Error:" + error, ToastLength.Long).Show(); isStartRfid = false; } } }
protected void InitReader() { var bytes = default(byte[]); using (var streamReader = new StreamReader(Assets.Open("regula.license"))) { using var memstream = new MemoryStream(); streamReader.BaseStream.CopyTo(memstream); bytes = memstream.ToArray(); } initDialog = ShowDialog("Initializing"); DocumentReader.Instance().InitializeReader(this, new DocReaderConfig(bytes), this); }
protected void InitReader() { var bytes = default(byte[]); using (var streamReader = new StreamReader(Android.App.Application.Context.Assets.Open("regula.license"))) { using (var memstream = new MemoryStream()) { streamReader.BaseStream.CopyTo(memstream); bytes = memstream.ToArray(); } } DocumentReader.Instance().InitializeReader(Android.App.Application.Context, bytes, this); }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (resultCode == Result.Ok) { //Image browsing intent processed successfully if (requestCode == REQUEST_BROWSE_PICTURE && data.Data != null) { var selectedImage = data.Data; var bmp = GetBitmap(selectedImage, 1920, 1080); loadingDialog = showDialog("Processing image"); DocumentReader.Instance().StopScanner(this); DocumentReader.Instance().RecognizeImage(bmp, this); } } }
protected override void OnResume() { base.OnResume(); var bytes = default(byte[]); using (var streamReader = new StreamReader(Assets.Open("regula.license"))) { using (var memstream = new MemoryStream()) { streamReader.BaseStream.CopyTo(memstream); bytes = memstream.ToArray(); } } initDialog = showDialog("Initializing"); DocumentReader.Instance().InitializeReader(this, bytes, this); }
public void OnInitCompleted(bool success, DocumentReaderException error) { if (initDialog != null && initDialog.IsShowing) { initDialog.Dismiss(); } //initialization successful if (success) { showScanner.Click += delegate { СlearResults(); //starting video processing DocumentReader.Instance().StopScanner(this); DocumentReader.Instance().ShowScanner(this, this); }; recognizeImage.Click += delegate { СlearResults(); //checking for image browsing permissions if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.ReadExternalStorage) != Permission.Granted) { ActivityCompat.RequestPermissions(this, new string[] { Manifest.Permission.ReadExternalStorage }, PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); } else { //start image browsing CreateImageBrowsingRequest(); } }; if (DocumentReader.Instance().IsRFIDAvailableForUse) { doRfid = sharedPreferences.GetBoolean(DO_RFID, false); doRfidCb.Checked = doRfid; doRfidCb.CheckedChange += delegate { doRfid = doRfidCb.Checked; sharedPreferences.Edit().PutBoolean(DO_RFID, doRfid).Apply(); }; } else { doRfidCb.Visibility = ViewStates.Gone; } //getting current processing scenario and loading available scenarios to ListView var currentScenario = DocumentReader.Instance().ProcessParams().Scenario; var scenarios = new List <String>(); foreach (DocumentReaderScenario scenario in DocumentReader.Instance().AvailableScenarios) { scenarios.Add(scenario.Name); } //setting default scenario if (String.IsNullOrEmpty(currentScenario)) { currentScenario = scenarios[0]; } DocumentReader.Instance().ProcessParams().Scenario = currentScenario; ScenarioAdapter adapter = new ScenarioAdapter(this, Android.Resource.Layout.SimpleListItem1, scenarios); adapter.SelectedPosition = adapter.GetPosition(currentScenario); scenarioLv.Adapter = adapter; scenarioLv.SetSelection(adapter.SelectedPosition); scenarioLv.ItemClick += (object sender, ItemClickEventArgs e) => { DocumentReader.Instance().ProcessParams().Scenario = scenarios[e.Position]; adapter.SelectedPosition = e.Position; adapter.NotifyDataSetChanged(); }; } //Initialization was not successful else { Toast.MakeText(initDialog.Context, "Init failed:" + error, ToastLength.Long).Show(); } }
public void SelectScenario(string scenarioName) { DocumentReader.Instance().ProcessParams().Scenario = scenarioName; }
public void ShowScanner(bool IsReadRfid) { DocumentReader.Instance().ShowScanner(Forms.Context, this); this.IsReadRfid = IsReadRfid; }
public void RecognizeImage(Stream stream) { Bitmap bitmap = BitmapFactory.DecodeStream(stream); DocumentReader.Instance().RecognizeImage(bitmap, this); }
private void ReadRfid() { IsReadRfid = false; DocumentReader.Instance().RfidScenario().AutoSettings = true; DocumentReader.Instance().StartRFIDReader(Android.App.Application.Context, this); }