public void print(string TagID)
        {
            //Ie KB for double print error.

            //if (nbprint != 0) return;
            //nbprint++;
            PrinterClass.MAPI_PRINTTAGUID_RETURN_TYPE respprint;
            printer = new PrinterClass();

            string arg = string.Empty;

            arg += TagID + ";";

            respprint = printer.PrintTag(printInfo.PrinterIP, 9100, printInfo.TemplateName, 1, arg);
            if (respprint == PrinterClass.MAPI_PRINTTAGUID_RETURN_TYPE.MAPI_PRINTTAGUID_RETURN_SUCCEED)
            {
                updatelabel("Print Succeed");
                System.Threading.Thread.Sleep(1000);
                BeginInvoke((MethodInvoker) delegate
                {
                    //Close();
                    Hide();
                });
            }
            else
            {
                updatelabel("Print Error :" + respprint.ToString());
                System.Threading.Thread.Sleep(1000);
            }
        }
 private bool checkPrinter(string Ip)
 {
     printInfo.bReady = false;
     if (TcpIP_class.tcpUtils.PingAddress(Ip, 2000))
     {
         try
         {
             printer = new PrinterClass();
             PrinterClass.MAPI_GETPRINTERSTATUS_TYPE resp = printer.GetStatusPrinter(Ip, 9100);
             if (resp == PrinterClass.MAPI_GETPRINTERSTATUS_TYPE.MAPI_GETPRINTERSTATUS_RETURN_PRINTER_READY)
             {
                 printInfo.bReady = true;
                 return(true);
             }
             else
             {
                 MessageBox.Show("Printer not ready : " + resp.ToString());
                 return(false);
             }
         }
         catch
         {
             MessageBox.Show("Printer not ready");
             return(false);
         }
     }
     else
     {
         MessageBox.Show("No printer detect on the IP " + Ip);
         return(false);
     }
 }
        // Function to get rfid event
        private void rfidDev_NotifyRFIDEvent(object sender, SDK_SC_RfidReader.rfidReaderArgs args)
        {
            switch (args.RN_Value)
            {
            // Event when failed to connect
            case SDK_SC_RfidReader.rfidReaderArgs.ReaderNotify.RN_FailedToConnect:
                updatelabel("Info : Failed to Connect");
                break;

            // Event when release the object
            case SDK_SC_RfidReader.rfidReaderArgs.ReaderNotify.RN_Disconnected:
                updatelabel("Info : Device Disconnected");
                break;

            //Event when device is connected
            case SDK_SC_RfidReader.rfidReaderArgs.ReaderNotify.RN_Connected:
                updatelabel("Info : Device Connected");
                break;

            // Event when scan started
            case SDK_SC_RfidReader.rfidReaderArgs.ReaderNotify.RN_ScanStarted:
                updatelabel("Info : Scan Started");
                break;

            //event when fail to start scan
            case SDK_SC_RfidReader.rfidReaderArgs.ReaderNotify.RN_ReaderFailToStartScan:
                updatelabel("Info : Failed to start scan");
                break;

            //event when a new tag is identify
            case SDK_SC_RfidReader.rfidReaderArgs.ReaderNotify.RN_TagAdded:

                break;

            // Event when scan completed
            case SDK_SC_RfidReader.rfidReaderArgs.ReaderNotify.RN_ScanCompleted:

                if (device.currentInventory.nbTagAll == 0)
                {
                    updatelabel("Info : No Tag Found");
                    // feed the printer

                    PrinterClass printer = new PrinterClass();
                    PrinterClass.MAPI_FEED_RETURN_TYPE ret = printer.FeedPrinter(printInfo.PrinterIP, 9100);
                    if (ret == PrinterClass.MAPI_FEED_RETURN_TYPE.MAPI_FEED_RETURN_SUCCEED)
                    {
                        updatelabel("Feed Succeed");
                        System.Threading.Thread.Sleep(1000);
                    }
                }
                else if (device.currentInventory.nbTagAll > 1)
                {
                    updatelabel("Info : More than one tag scanned - Please check the printer");
                }
                else
                {
                    updatelabel("Info : Scan Completed - Tag Scanned : " + device.currentInventory.listTagAll[0].ToString());
                    TagUidPrinted = device.currentInventory.listTagAll[0].ToString();
                    print(TagUidPrinted);
                }

                break;

            //error when error during scan
            case SDK_SC_RfidReader.rfidReaderArgs.ReaderNotify.RN_ReaderScanTimeout:
            case SDK_SC_RfidReader.rfidReaderArgs.ReaderNotify.RN_ErrorDuringScan:
                updatelabel("Info : Scan has error");
                break;

            case SDK_SC_RfidReader.rfidReaderArgs.ReaderNotify.RN_ScanCancelByHost:
                updatelabel("Info : Scan cancel by host");
                break;
            }
            Application.DoEvents();
        }