void _fpScanner_OnFingerprintsDetected(List <Fingerprint> fingerprints)
        {
            #region GUI - Display Fingerprints
            xamlStackPanelFingerprints.Children.Clear();
            int imageWidth = (int)xamlStackPanelFingerprints.RenderSize.Width / fingerprints.Count;
            foreach (Fingerprint fingerprint in fingerprints)
            {
                System.Windows.Controls.Image img = new System.Windows.Controls.Image();
                Bitmap bmp = new Bitmap(fingerprint.Image);
                img.Source = Utils.BitmapToBitmapSource(bmp);

                TextBlock tbNFIQ = new TextBlock();
                tbNFIQ.Text              = "NFIQ: " + fingerprint.NFIQ;
                tbNFIQ.FontSize          = 80;
                tbNFIQ.TextAlignment     = TextAlignment.Center;
                tbNFIQ.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
                tbNFIQ.Foreground        = Utils.GetBrushFromNFIQ(fingerprint.NFIQ);

                Grid          grid     = new Grid();
                RowDefinition gridRow1 = new RowDefinition();
                gridRow1.Height = new GridLength(1, GridUnitType.Star);
                RowDefinition gridRow2 = new RowDefinition();
                gridRow2.Height = new GridLength(1, GridUnitType.Star);
                grid.RowDefinitions.Add(gridRow1);
                grid.RowDefinitions.Add(gridRow2);

                img.SetValue(Grid.RowProperty, 0);
                tbNFIQ.SetValue(Grid.RowProperty, 1);

                grid.Children.Add(img);
                grid.Children.Add(tbNFIQ);

                grid.Margin = new Thickness(30, 0, 30, 0);

                xamlStackPanelFingerprints.Children.Add(grid);
            }
            #endregion

            if (_selectedUser != null)
            {
                try
                {
                    //Verify User
                    DisplayMessage("Verifying Templates");
                    AFISVerificationResult result = _afis.VerifyUser(_selectedUser.ID, fingerprints, Properties.Settings.Default.VerificationThreshold);
                    String scoreString            = String.Format("{0:0.00}", result.Score);

                    if (result.Hit)
                    {
                        displayMessage(String.Format("User verified ({0})", scoreString), Utils.COLOR_DERMALOG_GREEN);
                    }
                    else
                    {
                        displayMessage(String.Format("User not verified ({0})", scoreString), Utils.COLOR_DERMALOG_RED);
                    }
                }
                catch (Exception e)
                {
                    DisplayError(e.Message);
                }
            }

            //dispose allocated fingerprint templates
            foreach (Fingerprint fingerprint in fingerprints)
            {
                fingerprint.Dispose();
            }

            _fpScanner.Freeze(false);
        }
Beispiel #2
0
        void _fpScanner_OnFingerprintsDetected_new(List <Fingerprint> fingerprints)
        {
            #region GUI - Display Fingerprints
            fingerprints_new = fingerprints;


            #endregion


            Dictionary <long, LocalUser> userList = _afis.GetUserList();
            xamlListBoxUsers.Items.Clear();
            foreach (LocalUser user in userList.Values)
            {
                //xamlListBoxUsers.Items.Add(user);
                // }

                _selectedUser = user;


                // xamlStackPanelFingerprints.Controls.Add(fl);
                if (_selectedUser != null)
                {
                    try
                    {
                        //Verify User
                        DisplayMessage("Verifying Templates");
                        AFISVerificationResult result = _afis.VerifyUser(_selectedUser.ID, fingerprints, Properties.Settings.Default.VerificationThreshold);
                        String scoreString            = String.Format("{0:0.00}", result.Score);

                        if (result.Score > maxMatch)
                        {
                            maxMatch = result.Score;
                        }

                        if (result.Hit)
                        {
                            displayMessage(String.Format("User verified ({0})", scoreString), Utils.COLOR_DERMALOG_GREEN);
                            //label2.Text = String.Format("User verified ({0}%)", scoreString);
                            //aGauge1.Value = (float)result.Score;

                            break;
                        }
                        else
                        {
                            displayMessage(String.Format("User not verified ({0})", scoreString), Utils.COLOR_DERMALOG_RED);
                            //label2.Text = String.Format("User verified ({0}%)", scoreString);
                            //aGauge1.Value = (float)result.Score;
                        }
                        String bestscoreString = String.Format("{0:0.00}", maxMatch);
                        label2.Text   = String.Format("Best User verified ({0}%) username= {1}", bestscoreString, _selectedUser.Name);
                        aGauge1.Value = (float)maxMatch;

                        showAnimation(aGauge1);
                        //StopCapturing();
                        //NewMethod();
                    }
                    catch (Exception e)
                    {
                        DisplayError(e.Message);
                        //StopCapturing();
                    }
                }

                {
                    //this.BeginInvoke((MethodInvoker)delegate ()
                    //{
                    //    NewMethod();

                    //    Label l = new Label(); l.Location = new Point(12, 10);
                    //    l.Text = "Some Text";
                    //    this.Controls.Add(l);
                    //}
                    //);

                    //var resp;
                    //Task.Factory.StartNew(()=>NewMethod_new()).
                }
            }

            //dispose allocated fingerprint templates
            foreach (Fingerprint fingerprint in fingerprints)
            {
                fingerprint.Dispose();
            }

            _fpScanner.Freeze(false);
        }