Beispiel #1
0
        // Button create device
        private void button1_Click(object sender, EventArgs e)
        {
            // release previous object if not connected
            if (device != null)
            {
                if (device.ConnectionStatus != ConnectionStatus.CS_Connected)
                {
                    device.ReleaseDevice();
                }
            }
            //Create a new object
            device = new RFID_Device();
            toolStripStatusLabelInfo.Text = "Info RFID : In Connection ";
            buttonCreate.Enabled          = false;
            //subscribe the event
            device.NotifyRFIDEvent += new NotifyHandlerRFIDDelegate(rfidDev_NotifyRFIDEvent);
            device.NotifyFPEvent   += new NotifyHandlerFPDelegate(rfidDev_NotifyFPEvent);
            //Create a DSB device
            //As the function search on all the serial port of the PC, this connection can
            //take some time and is under a thread pool to avoid freeze of the GUI
            ThreadPool.QueueUserWorkItem(
                delegate
            {
                switch (arrayOfPluggedDevice[selectedDevice].deviceType)
                {
                case DeviceType.DT_DSB:
                case DeviceType.DT_SBX:
                case DeviceType.DT_JSC:

                    //  Use create with portcom parameter for speed connection (doesn't search again the reader at is is previouly done;
                    //  recover guid FP in devFParray
                    //  bLoadTemplateFromDB mandatory to false
                    device.Create_1FP_Device(arrayOfPluggedDevice[selectedDevice].SerialRFID, arrayOfPluggedDevice[selectedDevice].portCom, fpDevArray[selectedFP], false);

                    break;

                default:
                    MessageBox.Show("Device not created - Only device with fingerprint allowed \r\n\t\tDevice Detected : " + arrayOfPluggedDevice[selectedDevice].deviceType.ToString());
                    break;
                }
            });
        }