Ejemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //FIND
            err = m_SecuBSP.EnumerateDevice();
            m_SecuBSP.DeviceID = (Int16)DeviceID.AUTO;

            //OPEN
            err = m_SecuBSP.OpenDevice();
            if (err == BSPError.ERROR_NONE)
            {
                StatusBar.Text = "Scanner Detected";
            }

            //AUTO-ON
            if (this.Visible)
            {
                m_SecuBSP.MonitorDevice(true, this.Handle);
            }
        }
Ejemplo n.º 2
0
        private void Form2_Load(object sender, EventArgs e)
        {
            //FIND
            err = m_SecuBSP.EnumerateDevice();
            if (err == BSPError.ERROR_NONE)
            {
                m_SecuBSP.DeviceID = (Int16)DeviceID.AUTO;
            }

            //OPEN
            err = m_SecuBSP.OpenDevice();
            if (err == BSPError.ERROR_NONE)
            {
                StatusBar.Text = "(Scanner Detected)";
            }
            else
            {
                StatusBar.Text = "(No Scanner Detected)";
            }
        }
Ejemplo n.º 3
0
        private void enumerate_btn_Click(object sender, EventArgs e)
        {
            BSPError err;

            DeviceIDCombo.Items.Clear();

            DeviceIDCombo.Items.Add("0x00ff (Auto Detect)");
            err = m_SecuBSP.EnumerateDevice();
            if (err == BSPError.ERROR_NONE)
            {
                for (int i = 0; i < m_SecuBSP.DeviceNum; i++)
                {
                    Int16 device_id = m_SecuBSP.GetDeviceID(i);

                    string device_id_info;
                    device_id_info = "0x" + MakeHexaDecimal(device_id, 4) + "  ("
                                     + m_SecuBSP.GetDeviceName(device_id) + ","
                                     + m_SecuBSP.GetDeviceInstanceNum(device_id) + ")";

                    DeviceIDCombo.Items.Add(device_id_info);
                }
            }
            DisplaySecuBSPErrMsg("EnumerateDevice", err);
        }
Ejemplo n.º 4
0
        private void VerifySC_Click(object sender, EventArgs e)
        {
            err = m_SecuBSP.EnumerateDevice();
            pdf = new PdfDocument();

            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "PDF document (*.pdf)|*.pdf";
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    string pdfFile = dialog.FileName;

                    List <PdfSignature> signatures = new List <PdfSignature>();
                    //Open a pdf document and get its all signatures
                    using (PdfDocument pdf = new PdfDocument())
                    {
                        pdf.LoadFromFile(pdfFile);
                        PdfFormWidget form = pdf.Form as PdfFormWidget;
                        for (int i = 0; i < form.FieldsWidget.Count; i++)
                        {
                            PdfSignatureFieldWidget field = form.FieldsWidget[i] as PdfSignatureFieldWidget;
                            if (field != null && field.Signature != null)
                            {
                                PdfSignature signature = field.Signature;
                                signatures.Add(signature);
                            }
                        }

                        //Get the first signature
                        PdfSignature signatureOne = signatures[0];

                        //Detect if the pdf document was modified
                        bool modified = signatureOne.VerifyDocModified();

                        //FIND
                        err = m_SecuBSP.EnumerateDevice();
                        m_SecuBSP.DeviceID = (Int16)DeviceID.AUTO;

                        //OPEN
                        err = m_SecuBSP.OpenDevice();
                        if (err == BSPError.ERROR_NONE)
                        {
                            if (!modified)
                            {
                                PdfDocumentInformation docInfo = pdf.DocumentInformation;
                                err = m_SecuBSP.Capture(FIRPurpose.VERIFY);
                                if (err == BSPError.ERROR_NONE)
                                {
                                    err = m_SecuBSP.VerifyMatch(m_SecuBSP.FIRTextData, docInfo.Subject);

                                    if (err == BSPError.ERROR_NONE)
                                    {
                                        if (m_SecuBSP.IsMatched)
                                        {
                                            AutoClosingMessageBox.Show("The Document is Authentic", "", 1500);
                                        }
                                        else
                                        {
                                            AutoClosingMessageBox.Show("The Document is not Authentic", "", 1500);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                AutoClosingMessageBox.Show("The Document is not Authentic", "", 1500);
                            }
                        }
                        else
                        {
                            AutoClosingMessageBox.Show("No Scanner Detected", "Error!", 1000);
                        }
                    }
                }
                catch (Exception exe)
                {
                    MessageBox.Show("Document is not Authentic", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }