public SearchBarcodeScan(SearchBarcodeForm appForm) { InitializeComponent(); this.m_appForm = appForm; try { // Let's use the first available scanner. scanner = new Barcode2(); } catch (Exception ex) { MessageBox.Show("Barcode2 instantiation failed with " + ex.Message); this.Close(); return; } // Let's use triggers to fire up the scanner. scanner.Config.TriggerMode = TRIGGERMODES.HARD; // Register a scan event handler //scanner.OnScan += new Barcode2.OnScanHandler(barcode21_OnScan); scanner.OnScan += new Barcode2.OnScanHandler(barcode21_OnScan); scanner.OnStatus += new Barcode2.OnStatusHandler(barcode21_OnStatus); }
public void TermBarcode() { if (_myBarcode2 != null) { try { StopScan(); _myBarcode2.Dispose(); _myBarcode2 = null; } catch (OperationFailureException ex) { // MessageBox.Show(Resources.GetString("TermBarcode") + "\n" +Resources.GetString("OperationFailure") + "\n" + ex.Message +"\n" +Resources.GetString("Result") + " = " + (Results)((uint)ex.Result)); } catch (InvalidRequestException ex) { // MessageBox.Show(Resources.GetString("TermBarcode") + "\n" +Resources.GetString("InvalidRequest") + "\n" +ex.Message); } catch (InvalidIndexerException ex) { // MessageBox.Show(Resources.GetString("TermBarcode") + "\n" +Resources.GetString("InvalidIndexer") + "\n" +ex.Message); } ; } }
public bool InitBarcode() { if (_myBarcode2 != null) { return(false); } Device myDevice = Devices.SupportedDevices[0]; try { if (myDevice == null) { return(false); } _myBarcode2 = new Barcode2(myDevice); switch (_myBarcode2.Config.Reader.ReaderType) { case READER_TYPES.READER_TYPE_IMAGER: _myBarcode2.Config.Reader.ReaderSpecific.ImagerSpecific.AimType = AIM_TYPE.AIM_TYPE_TRIGGER; break; case READER_TYPES.READER_TYPE_LASER: _myBarcode2.Config.Reader.ReaderSpecific.LaserSpecific.AimType = AIM_TYPE.AIM_TYPE_TRIGGER; break; } _myBarcode2.Config.Reader.ReaderSpecific.LaserSpecific.LinearSecurityLevel = LINEAR_SECURITY_LEVEL.SECURITY_ALL_TWICE; _myBarcode2.Config.Reader.Set(); _myBarcode2.Config.Decoders.I2OF5.Enabled = true; _myBarcode2.Config.Decoders.CODE128.Enabled = true; // _myBarcode2.Config.Decoders.I2OF5.MinLength = 10; _myBarcode2.Config.Decoders.I2OF5.MaxLength = 26; _myBarcode2.Config.Decoders.I2OF5.Redundancy = true; _myBarcode2.Config.Decoders.Set(); _myBarcode2.Config.Scanner.DecodeBeepTime = 100; _myBarcode2.Config.Scanner.DecodeBeepFrequency = 4000; _myBarcode2.Config.Scanner.Set(); // _myBarcode2.Config.Reader.ReaderSpecific.ImagerSpecific. // _myBarcode2.Config.Read } catch (OperationFailureException ex) { // MessageBox.Show(Resources.GetString("InitBarcode") + "\n" +Resources.GetString("OperationFailure") + "\n" + ex.Message +"\n" +Resources.GetString("Result") + " = " + (Results)((uint)ex.Result)); return(false); } catch (InvalidRequestException ex) { // MessageBox.Show(Resources.GetString("InitBarcode") + "\n" +Resources.GetString("InvalidRequest") + "\n" +ex.Message); return(false); } catch (InvalidIndexerException ex) { // MessageBox.Show(Resources.GetString("InitBarcode") + "\n" +Resources.GetString("InvalidIndexer") + "\n" +ex.Message); return(false); } return(true); }
/// <summary> /// Attach a StatusNotify handler. /// </summary> public void AttachStatusNotify(Barcode2.OnStatusHandler StatusNotifyHandler) { // If we have a reader if( myBarcode2 != null) { // Attach status notification handler. myBarcode2.OnStatus += StatusNotifyHandler; } }
/// <summary> /// Attach a ScanNotify handler. /// </summary> public void AttachScanNotify(Barcode2.OnScanHandler ScanNotifyHandler) { // If we have a reader if( myBarcode2 != null) { // Attach the read notification handler. myBarcode2.OnScan += ScanNotifyHandler; } }
private void ScanItem_Load(object sender, EventArgs e) { try { objHelper = new Helper(); lbCust.Text += CustName; lbLocation.Text += LocationName; lbActivity.Text += ItemActivity; lbQty.Visible = false; txtQty.Visible = false; txtQty.Text = String.Empty; btnSave.Visible = false; btnCancel.Visible = false; //Demo //lbScanItem.Text = "ATO2202044-0055-4-000/NC1250"; //lbQtyNum.Visible = true; //lbQtyNum.Text = "Qty: " + "1"; //string ItemBarCode = string.Empty; //string ItemNum = string.Empty; //string BatchNum = string.Empty; //string strMasterAction = string.Empty; //string strNewItemID = string.Empty; //if (lbScanItem.Text.Substring(0, 3) == "ATO") // ItemBarCode = lbScanItem.Text.Substring(3); //else // ItemBarCode = lbScanItem.Text; //ItemNum = ItemBarCode.Substring(0, ItemBarCode.IndexOf("/")); //BatchNum = ItemBarCode.Substring(ItemBarCode.IndexOf("/") + 1); //strMasterAction = objHelper.checkScanItem(ItemNum, BatchNum, ItemActivityID); //if (strMasterAction == "E") //{ // MessageBox.Show("Invalid Item."); //} //else //{ // strNewItemID = objHelper.insertScanItem(ItemNum, BatchNum, CustName, LocationName, ItemActivityID, 1, strScannerID, UserID, strMasterAction); // strCurrentItem = strNewItemID; //} conn = new SqlCeConnection(Helper.strConn); conn.Open(); MyReader = new Barcode2(); eventHandler = new Barcode2.OnScanHandler(MyReader_OnScan); MyReader.OnScan += eventHandler; MyReader.ScanBufferStart(); } catch (Exception ex) { Helper.LogError(ex, "ScanItem_Load"); } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { if (scanner != null) { if (scanner.IsScanPending) { scanner.ScanCancel(); } scanner.Dispose(); scanner = null; } }
/// <summary> /// Inits this scanner. /// </summary> public void Init() { scanner = new Barcode2(Symbol.Barcode2.Devices.SupportedDevices[0]); scanner.Config.Reader.ReaderSpecific.LaserSpecific.AimType = AIM_TYPE.AIM_TYPE_TRIGGER; scanner.Config.Reader.Set(); scanner.OnScan += new Barcode2.OnScanHandler(scanner_OnScan); scanner.Scan(); beep = new Beeper(Symbol.Notification.Device.AvailableDevices.First(d => d.ObjectType == NotifyType.BEEPER)); beep.Duration = 500; beep.Frequency = 3000; beep.Volume = 5; beep.State = NotifyState.OFF; }
private void Location_Load(object sender, EventArgs e) { try { lbUser.Text += UserName; lbCustName.Text += CustName; lbLocationName.Text += LocationName; lbActivity.Text += ItemActivity; MyReader = new Barcode2(); eventHandler = new Barcode2.OnScanHandler(MyReader_OnScan); MyReader.OnScan += eventHandler; MyReader.ScanBufferStart(); } catch (Exception ex) { MessageBox.Show("Location_Load: " + ex.Message); } }
public static void wakeScanner(Button scanButton, TextBox textBox, bool scannerMode) { scanButton.Enabled = false; Symbol.Generic.Device MyDevice = Symbol.Barcode.Device.AvailableDevices[0]; Barcode2 MyBarcode = new Barcode2(MyDevice.ToString()); MyBarcode.Enable(); MyBarcode.Config.Reader.ReaderSpecific.LaserSpecific.AimDuration = 500; if (scannerMode) { MyBarcode.Config.TriggerMode = TRIGGERMODES.HARD; } else { MyBarcode.Config.TriggerMode = TRIGGERMODES.SOFT_ONCE; } ScanData MyData = MyBarcode.ScanWait(8000); // 5 seconds timeout if (MyData.Result == Symbol.Barcode2.Results.E_SCN_READTIMEOUT) // Barcode was not scanned within 8 secs { scanButton.Text = "No Scan Found"; textBox.Text = "No Scan Found"; MyBarcode.Dispose(); //enable add product button scanButton.Enabled = true; } if (MyData.Result == Symbol.Barcode2.Results.SUCCESS) // Barcode was scanned successfully { scanButton.Text = MyData.ToString(); textBox.Text = MyData.ToString(); MyBarcode.Dispose(); //enable add product button scanButton.Enabled = true; } }
/// <summary> /// form load /// </summary> public frmxPackage() { InitializeComponent(); //barkod Barkod = new Barcode2(); Barkod.DeviceType = Symbol.Barcode2.DEVICETYPES.FIRSTAVAILABLE; try { Barkod.EnableScanner = true; } catch (Exception) { } Barkod.OnScan += new Barcode2.OnScanEventHandler(Barkod_OnScan); //change size if (Screen.PrimaryScreen.Bounds.Height == Screen.PrimaryScreen.Bounds.Width) { int eksik = 320 - Screen.PrimaryScreen.WorkingArea.Height; panelOrta.Height -= eksik; panelAlt.Top -= eksik; } }
/// <summary> /// Stop reading and disable/close the Barcode2 object. /// </summary> public void TermBarcode() { // If we have a reader if (myBarcode2 != null) { try { // stop all the notifications. StopScan(); // Free it up. myBarcode2.Dispose(); // Make the reference null. myBarcode2 = null; } catch (OperationFailureException ex) { MessageBox.Show(Resources.GetString("TermBarcode") + "\n" + Resources.GetString("OperationFailure") + "\n" + ex.Message + "\n" + Resources.GetString("Result") + " = " + (Results)((uint)ex.Result) ); } catch (InvalidRequestException ex) { MessageBox.Show(Resources.GetString("TermBarcode") + "\n" + Resources.GetString("InvalidRequest") + "\n" + ex.Message); } catch (InvalidIndexerException ex) { MessageBox.Show(Resources.GetString("TermBarcode") + "\n" + Resources.GetString("InvalidIndexer") + "\n" + ex.Message); }; } }
/// <summary> /// 初始化设备和数据 /// </summary> public void Init() { if (Devices.SupportedDevices == null || Devices.SupportedDevices.Length == 0) { throw new Exception("没有找到系统支持的条码扫描设备!"); } barcode2 = new Barcode2(Devices.SupportedDevices[0]); switch (barcode2.Config.Reader.ReaderType) { case READER_TYPES.READER_TYPE_IMAGER: // 图像条码读取器 barcode2.Config.Reader.ReaderSpecific.ImagerSpecific.AimType = AIM_TYPE.AIM_TYPE_TRIGGER; //barcode2.Config.Reader.ReaderSpecific.ImagerSpecific.FocusMode = FOCUS_MODE.FOCUS_MODE_AUTO; //barcode2.Config.Reader.ReaderSpecific.ImagerSpecific.DPMMode = DPM_MODE.DPM_MODE_ENABLED; break; case READER_TYPES.READER_TYPE_LASER: // 激光条码读取器 barcode2.Config.Reader.ReaderSpecific.LaserSpecific.AimType = AIM_TYPE.AIM_TYPE_TRIGGER; break; } barcode2.Config.Reader.Set(); }
public FrmBarcodeScanSearch(StartAudit_Form appForm) { InitializeComponent(); this.m_appForm = appForm; status = "Connect"; this.m_UpdateReadHandler = new UpdateRead(myUpdateRead); this.m_UpdateStatusHandler = new UpdateStatus(myUpdateStatus); this.m_ReadTag = new Symbol.RFID3.TagData(); m_ReaderAPI = m_appForm.m_ReaderAPI; m_ReaderAPI = new RFIDReader("127.0.0.1", 5084, 0); this.m_AntennaInfoForm = m_appForm.m_AntennaInfoForm; this.m_AntennaConfigForm = m_appForm.m_AntennaConfigForm; this.m_PostFilterForm = m_appForm.m_PostFilterForm; this.m_AccessFilterForm = m_appForm.m_AccessFilterForm; this.m_TriggerForm = m_appForm.m_TriggerForm; this.m_ReaderMgmt = new ReaderManagement(); this.m_TagTable = new Hashtable(1023); this.m_AccessOpResult = new AccessOperationResult(); this.m_IsConnected = false; this.m_TagTotalCount = 0; this.m_ReaderInitiatedDisconnectionReceived = false; this.m_isBeepingEnabled = true; //Barcode scan start try { // Let's use the first available scanner. scanner = new Barcode2(); } catch (Exception ex) { MessageBox.Show("Barcode2 instantiation failed with " + ex.Message); this.Close(); return; } // Let's use triggers to fire up the scanner. scanner.Config.TriggerMode = TRIGGERMODES.HARD; // Register a scan event handler //scanner.OnScan += new Barcode2.OnScanHandler(barcode21_OnScan); scanner.OnScan += new Barcode2.OnScanHandler(barcode21_OnScan); // scanner.OnStatus += new Barcode2.OnStatusHandler(barcode21_OnStatus); //Barcode scan end }
/// <summary> /// Detach the ScanNotify handler. /// </summary> public void DetachScanNotify(Barcode2.OnScanHandler ScanNotifyHandler) { if (myBarcode2 != null) { // Detach the read notification handler. myBarcode2.OnScan -= ScanNotifyHandler; } }
/// <summary> /// Initialize the Barcode2 object. /// </summary> public bool InitBarcode() { // If the Barcode2 object is already initialized then fail the initialization. if (myBarcode2 != null) { return(false); } else // Else initialize the reader. { try { // Get the device selected by the user. Device MyDevice = Symbol.Barcode2.Devices.SupportedDevices[0]; // Create the reader, based on selected device. myBarcode2 = new Barcode2(MyDevice); // In this sample, we are setting the aim type to trigger. switch (myBarcode2.Config.Reader.ReaderType) { case READER_TYPES.READER_TYPE_IMAGER: myBarcode2.Config.Reader.ReaderSpecific.ImagerSpecific.AimType = AIM_TYPE.AIM_TYPE_TRIGGER; break; case READER_TYPES.READER_TYPE_LASER: myBarcode2.Config.Reader.ReaderSpecific.LaserSpecific.AimType = AIM_TYPE.AIM_TYPE_TRIGGER; break; } myBarcode2.Config.Reader.Set(); } catch (OperationFailureException ex) { MessageBox.Show(Resources.GetString("InitBarcode") + "\n" + Resources.GetString("OperationFailure") + "\n" + ex.Message + "\n" + Resources.GetString("Result") + " = " + (Results)((uint)ex.Result) ); return(false); } catch (InvalidRequestException ex) { MessageBox.Show(Resources.GetString("InitBarcode") + "\n" + Resources.GetString("InvalidRequest") + "\n" + ex.Message); return(false); } catch (InvalidIndexerException ex) { MessageBox.Show(Resources.GetString("InitBarcode") + "\n" + Resources.GetString("InvalidIndexer") + "\n" + ex.Message); return(false); }; return(true); } }
/// <summary> /// Stop reading and disable/close the Barcode2 object. /// </summary> public void TermBarcode() { // If we have a reader if (myBarcode2 != null) { try { // stop all the notifications. StopScan(); // Free it up. myBarcode2.Dispose(); // Make the reference null. myBarcode2 = null; } catch (OperationFailureException ex) { MessageBox.Show(ex.Message); } catch (InvalidRequestException ex) { MessageBox.Show(ex.Message); } catch (InvalidIndexerException ex) { MessageBox.Show(ex.Message); }; } }
/// <summary> /// Initialize the Barcode2 object. /// </summary> public bool InitBarcode() { // If the Barcode2 object is already initialized then fail the initialization. if (myBarcode2 != null) { return false; } else // Else initialize the reader. { try { // Get the device selected by the user. Device MyDevice = SelectDevice.Select( "Barcode", Symbol.Barcode2.Devices.SupportedDevices); if (MyDevice == null) { MessageBox.Show("NoDeviceSelected", "SelectDevice"); return false; } // Create the reader, based on selected device. myBarcode2 = new Barcode2(MyDevice); // In this sample, we are setting the aim type to trigger. switch (myBarcode2.Config.Reader.ReaderType) { case READER_TYPES.READER_TYPE_IMAGER: myBarcode2.Config.Reader.ReaderSpecific.ImagerSpecific.AimType = AIM_TYPE.AIM_TYPE_TRIGGER; break; case READER_TYPES.READER_TYPE_LASER: myBarcode2.Config.Reader.ReaderSpecific.LaserSpecific.AimType = AIM_TYPE.AIM_TYPE_TRIGGER; break; } myBarcode2.Config.Reader.Set(); } catch (OperationFailureException ex) { MessageBox.Show(ex.Message); return false; } catch (InvalidRequestException ex) { MessageBox.Show(ex.Message); return false; } catch (InvalidIndexerException ex) { MessageBox.Show(ex.Message); return false; }; return true; } }
/// <summary> /// Detach a StatusNotify handler. /// </summary> public void DetachStatusNotify(Barcode2.OnStatusHandler StatusNotifyHandler) { // If we have a reader registered for receiving the status notifications if (myBarcode2 != null) { // Detach the status notification handler. myBarcode2.OnStatus -= StatusNotifyHandler; } }