0

実際の問題: メインフォームの読み取りルーチンが 2 回以上。MainForm 内のすべてのコンポーネントとオブジェクトは空です。 例:

優れたボタンの最初の実行

私のコードを追加してください:

    namespace CheckNet
{
    /// <summary>
    /// Description of MainForm.
    /// </summary>
    delegate void Function();
    public partial class MainForm : Form
    {
        public MainForm()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
             Btn_Inicio.Click += new EventHandler (Btn_InicioClick);
            // VerificationForm += new EventHandler (VerificationForm);

            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //
        }

        private DPFP.Template Template;
        private DPFP.Template myTemplate;
    //  





        void Btn_InicioClick(object sender, EventArgs e)

        {
            // call rutine ejecutar boton primera vez
                    //  
            if (this.panelContenedor.Controls.Count > 0)
                this.panelContenedor.Controls.RemoveAt(0);
                VerificationForm hijos = new VerificationForm();
                hijos.TopLevel = false;
                hijos.FormBorderStyle = FormBorderStyle.None;
                hijos.Dock = DockStyle.Fill;
                this.panelContenedor.Controls.Add(hijos);
                this.panelContenedor.Tag = hijos;

                hijos.Show();


        }




        void Button7Click(object sender, EventArgs e)
        {
             AddFormInPanel(new Hijo2());           
        }


    private void AddFormInPanel(object formHijo)
        {
                if (this.panelContenedor.Controls.Count > 0)
                this.panelContenedor.Controls.RemoveAt(0);
                Form fh = formHijo as Form;
                fh.TopLevel = false;
                fh.FormBorderStyle = FormBorderStyle.None;
                fh.Dock = DockStyle.Fill;
                this.panelContenedor.Controls.Add(fh);
                this.panelContenedor.Tag = fh;
                fh.Show();
        } 



        void Close_bottonClick(object sender, EventArgs e)
        {
            Close();
        }
    }

}

////////// フォーム検証フォームを呼び出す

   namespace CheckNet
{
    /* NOTE: This form is inherited from the CaptureForm,
        so the VisualStudio Form Designer may not load it properly
        (at least until you build the project).
        If you want to make changes in the form layout - do it in the base CaptureForm.
        All changes in the CaptureForm will be reflected in all derived forms 
        (i.e. in the EnrollmentForm and in the VerificationForm)
    */
    public class VerificationForm : CaptureForm
    {

        public void Verify(DPFP.Template template)
        {
            Template = template;
            ShowDialog();
        }

        protected override void Init()
        {
            base.Init();
            base.Text = "Fingerprint Verification ";
            Verificator = new DPFP.Verification.Verification();     // Create a fingerprint template verificator
            UpdateStatus(0);
        }

        protected override void Process(DPFP.Sample Sample)
        {
            base.Process(Sample);

            // Process the sample and create a feature set for the enrollment purpose.
            DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification);

            // Check quality of the sample and start verification if it's good
            // TODO: move to a separate task
            template= TomarHuellaBd();
              Template=template;

            if (features != null)
            {
                // Compare the feature set with our template
                DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result();
                Verificator.Verify(features, Template, ref result);
                UpdateStatus(result.FARAchieved);
                if (result.Verified)
                {

                    MakeReport2(" ");



                }
                else
                    MakeReport("Huella no Identificado.");
            }
        }

        private void UpdateStatus(int FAR)
        {
            // Show "False accept rate" value
            SetStatus(String.Format("False Accept Rate (FAR) = {0}", FAR));
        }
                        private DPFP.Template TomarHuellaBd()
            {
                // Verifica la Huella desde una base de Datos

                bool Bandera=true;
            try { // Validar Numero
                 int idEmpleado =int.Parse(Global_ip.Globalip.ToString());
                 } catch {
                    MessageBox.Show("Error Numero de Empleado ", Global_ip.Globalip.ToString());
                    Bandera=false;
                    //

                    return null;

                    //
                }

            try
                {
                int NumEmpleado=int.Parse(Global_ip.Globalip.ToString());
                enlacedb db = new enlacedb();
                FbConnection conexion2 = new FbConnection(db.connectionString);
                conexion2.Open();
                FbCommand Frda = new FbCommand("SELECT * FROM REGHUMAN  WHERE  ID_EMPLEADO=@ID_EMPLEADO", conexion2);
                        Frda.Parameters.Add("@ID_EMPLEADO",SqlDbType.VarChar).Value =  NumEmpleado;
                        FbDataReader leerF = Frda.ExecuteReader();
                        bool fseek= leerF.Read();
                            if (fseek) { 



                            Global_Nombre.GlobalNombre= leerF.GetValue(4).ToString();



                               Byte[] imageF = new Byte[Convert.ToInt32 ((leerF.GetBytes(2, 0,null, 0, Int32.MaxValue)))];

                                leerF.GetBytes(2, 0, imageF, 0, imageF.Length);
                                MemoryStream memfpt = new MemoryStream(imageF);
                                DPFP.Template template = new DPFP.Template(memfpt);
                                return template;
                                }
                        else
                        {
                        return null;
                        }
                }
                catch (Exception err2) {
                                MessageBox.Show(err2.ToString());
                        }
            return null;
            }



        private DPFP.Template Template;
        private DPFP.Template template;
        private DPFP.Verification.Verification Verificator;

    }
}

ユーザーが同じボタンの 2 回目の実行を要求した場合

VerificationForm ルーチンとレジデントは CaptureForm Digital Persona デバイスであり、指紋を読み取れません

プロシージャまたはルーチン (MainForm、VerificationForm、および CaptureForm) を空にするまたはリセットする方法 ありがとうございます。

4

1 に答える 1

0

解決策は次のとおりです。

program.cs を変更します。

private static void Main (string [] args)
{
Application.EnableVisualStyles ();
Application.SetCompatibleTextRenderingDefault (false);

             Fm1 MainForm = new MainForm ();
             Application.Run (fm1);

             if (fm1.ToRestart)
                 Application.Restart ();
         }

ToRestart public bool = false; を開始します。

void Btn_InicioClick  (object sender, EventArgs e)
{

ToRestart = true;
             this.Close ();

}

指紋リーダーと winform コントロールをリセットするには

感謝

于 2013-08-07T06:09:11.697 に答える