/// <summary> /// Handle "Fingerprint reading Complete" event. /// If Enrollment (registration) is under process, consider the just-read sample as a new sample for the enrollment. /// Otherwise, save the sample as the "last read sample" in order to allow user to compare it with a fingerprints list. /// </summary> /// <param name="capture">Capture instance</param> /// <param name="info"></param> /// <param name="sample">Just-read fingerprint sample</param> public void OnComplete(object capture, string info, Sample sample) { if (!_registrationInProgress) // common authentication { // Notify that reading is complete. Suscriber has to confirm authentication by using DoesTemplateMatch method. _lastSample = sample; var args = new FingerprintReaderEventArgs(FingerprintReaderEventArgs.EventTypeValue.FPReaderReadingComplete); FireEvent(args); } else { try { _regFeatures[_fingerCount] = ExtractFeatures(sample, DataPurpose.Enrollment); if (_regFeatures[_fingerCount] == null) { return; } ++_fingerCount; _createRegTemplate.AddFeatures(_regFeatures[_fingerCount - 1]); if (_fingerCount <= FingerPressRequired) { FireEvent( new FingerprintReaderEventArgs(FingerprintReaderEventArgs.EventTypeValue.FPReaderFingerPress)); } if (_createRegTemplate.TemplateStatus == Enrollment.Status.Failed) { _fingerCount = 0; _registrationInProgress = false; _createRegTemplate.Clear(); FireEvent( new FingerprintReaderEventArgs( FingerprintReaderEventArgs.EventTypeValue.FPReaderRegistrationFailure)); } else { if (_createRegTemplate.TemplateStatus != Enrollment.Status.Ready) { return; } LastTemplate = _createRegTemplate.Template; _registrationInProgress = false; _fingerCount = 0; _createRegTemplate.Clear(); FireEvent( new FingerprintReaderEventArgs( FingerprintReaderEventArgs.EventTypeValue.FPReaderRegistrationSuccess)); } } catch (DPFP.Error.SDKException sdke) { if (sdke.ErrorCode == DPFP.Error.ErrorCodes.InvalidFeatureSet) { _registrationInProgress = false; _fingerCount = 0; _createRegTemplate.Clear(); FireEvent( new FingerprintReaderEventArgs( FingerprintReaderEventArgs.EventTypeValue.FPReaderRegistrationFailure)); } } } }