private void button_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter      = "JPEG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png|BMP Files (*.bmp)|*.bmp|All files (*.*)|*.*";
            dlg.FilterIndex = 3;

            if (dlg.ShowDialog() == true)
            {
                BitmapImage bitmapImage = new BitmapImage(new Uri(dlg.FileName));

                SimilarFinger sf = new SimilarFinger(bitmapImage);

                db.FingerInfoes.Add(new FingerInfo()
                {
                    AccountName  = accountNameComboBox.Text,
                    FingerString = sf.GetHash()
                });

                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Beispiel #2
0
        private async void userLoginBtn_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter      = "JPEG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png|BMP Files (*.bmp)|*.bmp|All files (*.*)|*.*";
            dlg.FilterIndex = 3;

            if (dlg.ShowDialog() == true)
            {
                BitmapImage bitmapImage = new BitmapImage(new Uri(dlg.FileName));

                sf = new SimilarFinger(bitmapImage);
                var fingerInfo = await CompareFinger(sf.GetHash());

                if (fingerInfo != null)
                {
                    //TODO:
                    MessageBox.Show("已成功识别用户:" + fingerInfo.AccountName + ",指纹ID:" + fingerInfo.FingerId);
                }
                else
                {
                    MessageBox.Show("未找到匹配的用户");
                }

                image.Source = bitmapImage;
            }
        }