private void ReadFingerprintButton_Clicked() { var dialog = new FingerprintDialog("Read Fingerprint", "Can't read fingerprint, try to place your finger flat on the sensor"); (ushort userID, UserPermission permission)userInfo = default; Task.Run(() => { if (_fingerprintSensor.TryComparison1N(out userInfo)) { dialog.Cancel(); } else { dialog.CancelAndShowError(); } }); dialog.Show(); if (userInfo != default) { MessageBox.Query("Read Fingerprint", $"Successfully read fingerprint\n\nUser ID: {userInfo.userID}\nPermissions: {userInfo.permission}\n ", "Ok"); } }
private void ReadEigenvaluesButton_Clicked() { var dialog = new FingerprintDialog("Acquire Eigenvalues", "Can't acquire eigenvalues, try to place your finger flat on the sensor"); byte[] eigenvalues = null; Task.Run(() => { if (_fingerprintSensor.TryAcquireEigenvalues(out var values)) { eigenvalues = values.ToArray(); dialog.Cancel(); } else { dialog.CancelAndShowError(); } }); dialog.Show(); if (eigenvalues != null) { var window = new DataDisplay("Eigenvalues", eigenvalues); WriteOut($"Eigenvalues:\n{Utils.ArrayDisplay(eigenvalues)}\n\n\n"); Application.Run(window); } }
private void ReadImageButton_Clicked() { var dialog = new FingerprintDialog("Acquire Image", "Can't acquire image, try to place your finger flat on the sensor"); byte[] image = null; Task.Run(() => { if (_fingerprintSensor.TryAcquireImage(out image)) { dialog.Cancel(); } else { dialog.CancelAndShowError(); } }); dialog.Show(); if (image != null) { WriteOut($"Image:\n{Utils.ArrayDisplay(image)}\n\n\n"); var window = new DataDisplay("Image", image.ToArray()); Application.Run(window); } }
private void AddFingerprintButton_Clicked() { if (new EntryDialog("User id", i => ushort.TryParse(i.ToString(), out var n), "Need to be a valid user id").TryShow(out var input)) { var dialog = new FingerprintDialog("Add Fingerprint", "Can't add fingerprint, try to place your finger flat on the sensor"); Task.Run(() => { switch (_fingerprintSensor.AddFingerprint(ushort.Parse(input.ToString()), UserPermission.Level1)) { case ResponseType.Success: dialog.Cancel(); Application.MainLoop.Invoke(() => MessageBox.Query("Add Fingerprint", "Successfully added fingerprint", "Ok")); break; case ResponseType.Full: dialog.ErrorMessage = "Sensor full, can't add more users"; dialog.CancelAndShowError(); break; case ResponseType.NoUser: dialog.ErrorMessage = "Can't add fingerprint, invalid id"; dialog.CancelAndShowError(); break; case ResponseType.FingerOccupied: dialog.ErrorMessage = "Can't add fingerprint, finger already registered"; dialog.CancelAndShowError(); break; case ResponseType.UserOccupied: dialog.ErrorMessage = "Can't add fingerprint, id already used"; dialog.CancelAndShowError(); break; default: dialog.CancelAndShowError(); break; } }); dialog.Show(); UpdateUserCount(); } }