private bool InitReader() { // If reader is already present then fail initialize if (this.MyReader != null) { return(false); } // Create new reader, first available reader will be used. this.MyReader = new Symbol.Barcode.Reader(); // Create reader data this.MyReaderData = new Symbol.Barcode.ReaderData( Symbol.Barcode.ReaderDataTypes.Text, Symbol.Barcode.ReaderDataLengths.MaximumLabel); // Create event handler delegate this.MyEventHandler = new EventHandler(MyReader_ReadNotify); // Enable reader, with wait cursor this.MyReader.Actions.Enable(); //this.MyReader.Parameters.Feedback.Success.BeepTime = 2; // Attach to activate and deactivate events this.Activated += new EventHandler(ReaderForm_Activated); this.Deactivate += new EventHandler(ReaderForm_Deactivate); return(true); }
void InitReader2() { Symbol.Generic.Device MyDevice = Symbol.StandardForms.SelectDevice.Select( Symbol.Barcode.Device.Title, Symbol.Barcode.Device.AvailableDevices); mReader = new Symbol.Barcode.Reader(MyDevice); // Create the reader data. mReaderData = new Symbol.Barcode.ReaderData( Symbol.Barcode.ReaderDataTypes.Text, Symbol.Barcode.ReaderDataLengths.MaximumLabel); // Enable the Reader. mReader.Actions.Enable(); switch (mReader.ReaderParameters.ReaderType) { case Symbol.Barcode.READER_TYPE.READER_TYPE_IMAGER: mReader.ReaderParameters.ReaderSpecific.ImagerSpecific.AimType = Symbol.Barcode.AIM_TYPE.AIM_TYPE_TRIGGER; break; case Symbol.Barcode.READER_TYPE.READER_TYPE_LASER: mReader.ReaderParameters.ReaderSpecific.LaserSpecific.AimType = Symbol.Barcode.AIM_TYPE.AIM_TYPE_TRIGGER; break; case Symbol.Barcode.READER_TYPE.READER_TYPE_CONTACT: throw new Exception("not support READER_TYPE_CONTACT"); } mReader.Actions.SetParameters(); mReader.ReadNotify += new EventHandler(mReader_ReadNotify); }
/// <summary> /// Initialize the reader. /// </summary> private bool InitReader() { // If reader is already present, fail. if (MyReader != null) { return(false); } MyReader = new Symbol.Barcode.Reader(); // Create reader data. MyReaderData = new Symbol.Barcode.ReaderData( Symbol.Barcode.ReaderDataTypes.Text, Symbol.Barcode.ReaderDataLengths.DefaultText); // Create event handler delegate. MyEventHandler = new EventHandler(MyReader_ReadNotify); // Enable reader. MyReader.Actions.Enable(); MyReader.Parameters.Feedback.Success.BeepTime = 100; MyReader.Parameters.Feedback.Success.BeepFrequency = 3000; MyReader.Parameters.Feedback.Fail.BeepTime = 0; MyReader.Parameters.Feedback.Fail.WaveFile = "\\windows\\alarm3.wav"; return(true); }
/// <summary> /// Stop all reads on the reader /// </summary> private void StopRead() { // If we have a reader if (this.MyReader != null) { // Flush (Cancel all pending reads) this.MyReader.ReadNotify -= this.MyEventHandler; this.MyReader.Actions.Flush(); this.MyReader.Dispose(); this.MyReaderData.Dispose(); this.MyReader = null; this.MyReaderData = null; } }
/// <summary> /// Stop reading and disable/close the reader. /// </summary> public void TermReader() { // If we have a reader if (mReader != null) { try { // stop all the notifications. StopRead(); //Detach all the notification handler if the user has not done it already. DetachReadNotify(); DetachStatusNotify(); // Disable the reader. mReader.Actions.Disable(); // Free it up. mReader.Dispose(); // Make the reference null. mReader = null; } catch (Exception ex) { MessageBox.Show(ex.Message); } } // After disposing the reader, dispose the reader data. if (mReaderData != null) { try { // Free it up. mReaderData.Dispose(); // Make the reference null. mReaderData = null; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
/// <summary> /// Initialize the reader. /// </summary> public bool InitReader() { // If the reader is already initialized then fail the initialization. if (myReader != null) { return false; } else // Else initialize the reader. { try { // Get the device selected by the user. Symbol.Generic.Device MyDevice = Symbol.StandardForms.SelectDevice.Select( Symbol.Barcode.Device.Title, Symbol.Barcode.Device.AvailableDevices); //Select Device from device list Symbol.Audio.Device audioDevice = (Symbol.Audio.Device)Symbol.StandardForms.SelectDevice.Select( Symbol.Audio.Controller.Title, Symbol.Audio.Device.AvailableDevices); if (MyDevice == null) { MessageBox.Show(Resources.GetString("NoDeviceSelected"), Resources.GetString("SelectDevice")); return false; } // Create the reader, based on selected device. myReader = new Symbol.Barcode.Reader(MyDevice); // Create the reader data. myReaderData = new Symbol.Barcode.ReaderData( Symbol.Barcode.ReaderDataTypes.Text, Symbol.Barcode.ReaderDataLengths.MaximumLabel); // Enable the Reader. myReader.Actions.Enable(); // In this sample, we are setting the aim type to trigger. switch (myReader.ReaderParameters.ReaderType) { case Symbol.Barcode.READER_TYPE.READER_TYPE_IMAGER: myReader.ReaderParameters.ReaderSpecific.ImagerSpecific.AimType = Symbol.Barcode.AIM_TYPE.AIM_TYPE_TRIGGER; break; case Symbol.Barcode.READER_TYPE.READER_TYPE_LASER: myReader.ReaderParameters.ReaderSpecific.LaserSpecific.AimType = Symbol.Barcode.AIM_TYPE.AIM_TYPE_TRIGGER; break; case Symbol.Barcode.READER_TYPE.READER_TYPE_CONTACT: // AimType is not supported by the contact readers. break; } myReader.Actions.SetParameters(); //check the device type switch (audioDevice.AudioType) { //if standard device case Symbol.Audio.AudioType.StandardAudio: myAudioController = new Symbol.Audio.StandardAudio(audioDevice); break; //if simulated device case Symbol.Audio.AudioType.SimulatedAudio: myAudioController = new Symbol.Audio.SimulatedAudio(audioDevice); break; default: throw new Symbol.Exceptions.InvalidDataTypeException("Unknown Device Type"); } myAudioController.BeeperVolume = 0; } catch (Symbol.Exceptions.OperationFailureException ex) { MessageBox.Show(Resources.GetString("InitReader") + "\n" + Resources.GetString("OperationFailure") + "\n" + ex.Message + "\n" + Resources.GetString("Result") + " = " + (Symbol.Results)((uint)ex.Result) ); return false; } catch (Symbol.Exceptions.InvalidRequestException ex) { MessageBox.Show(Resources.GetString("InitReader") + "\n" + Resources.GetString("InvalidRequest") + "\n" + ex.Message); return false; } catch (Symbol.Exceptions.InvalidIndexerException ex) { MessageBox.Show(Resources.GetString("InitReader") + "\n" + Resources.GetString("InvalidIndexer") + "\n" + ex.Message); return false; }; return true; } }
/// <summary> /// Stop reading and disable/close the reader. /// </summary> public void TermReader() { // If we have a reader if (myReader != null) { try { // stop all the notifications. StopRead(); //Detach all the notification handler if the user has not done it already. DetachReadNotify(); DetachStatusNotify(); // Disable the reader. myReader.Actions.Disable(); // Free it up. myReader.Dispose(); // Make the reference null. myReader = null; myAudioController.Dispose(); myAudioController = null; } catch (Symbol.Exceptions.OperationFailureException ex) { MessageBox.Show(Resources.GetString("TermReader") + "\n" + Resources.GetString("OperationFailure") + "\n" + ex.Message + "\n" + Resources.GetString("Result") + " = " + (Symbol.Results)((uint)ex.Result) ); } catch (Symbol.Exceptions.InvalidRequestException ex) { MessageBox.Show(Resources.GetString("TermReader") + "\n" + Resources.GetString("InvalidRequest") + "\n" + ex.Message); } catch (Symbol.Exceptions.InvalidIndexerException ex) { MessageBox.Show(Resources.GetString("TermReader") + "\n" + Resources.GetString("InvalidIndexer") + "\n" + ex.Message); }; } // After disposing the reader, dispose the reader data. if (myReaderData != null) { try { // Free it up. myReaderData.Dispose(); // Make the reference null. myReaderData = null; } catch (Symbol.Exceptions.OperationFailureException ex) { MessageBox.Show(Resources.GetString("TermReader") + "\n" + Resources.GetString("OperationFailure") + "\n" + ex.Message + "\n" + Resources.GetString("Result") + " = " + (Symbol.Results)((uint)ex.Result) ); } catch (Symbol.Exceptions.InvalidRequestException ex) { MessageBox.Show(Resources.GetString("TermReader") + "\n" + Resources.GetString("InvalidRequest") + "\n" + ex.Message); } catch (Symbol.Exceptions.InvalidIndexerException ex) { MessageBox.Show(Resources.GetString("TermReader") + "\n" + Resources.GetString("InvalidIndexer") + "\n" + ex.Message); }; } }
/// <summary> /// Initialize the reader. /// </summary> public bool InitReader() { // If the reader is already initialized then fail the initialization. if (myReader != null) { return(false); } else // Else initialize the reader. { try { // Get the device selected by the user. Symbol.Generic.Device MyDevice = Symbol.StandardForms.SelectDevice.Select( Symbol.Barcode.Device.Title, Symbol.Barcode.Device.AvailableDevices); if (MyDevice == null) { MessageBox.Show("NoDeviceSelected", "SelectDevice"); return(false); } // Create the reader, based on selected device. myReader = new Symbol.Barcode.Reader(MyDevice); // Create the reader data. myReaderData = new Symbol.Barcode.ReaderData( Symbol.Barcode.ReaderDataTypes.Text, Symbol.Barcode.ReaderDataLengths.MaximumLabel); // Enable the Reader. myReader.Actions.Enable(); // In this sample, we are setting the aim type to trigger. switch (myReader.ReaderParameters.ReaderType) { case Symbol.Barcode.READER_TYPE.READER_TYPE_IMAGER: myReader.ReaderParameters.ReaderSpecific.ImagerSpecific.AimType = Symbol.Barcode.AIM_TYPE.AIM_TYPE_TRIGGER; break; case Symbol.Barcode.READER_TYPE.READER_TYPE_LASER: myReader.ReaderParameters.ReaderSpecific.LaserSpecific.AimType = Symbol.Barcode.AIM_TYPE.AIM_TYPE_TRIGGER; break; case Symbol.Barcode.READER_TYPE.READER_TYPE_CONTACT: // AimType is not supported by the contact readers. break; } myReader.Actions.SetParameters(); } catch (Symbol.Exceptions.OperationFailureException ex) { MessageBox.Show("InitReader" + "\n" + "OperationFailure" + "\n" + ex.Message + "\n" + "Result" + " = " + (Symbol.Results)((uint)ex.Result) ); return(false); } catch (Symbol.Exceptions.InvalidRequestException ex) { MessageBox.Show("InitReader" + "\n" + "InvalidRequest" + "\n" + ex.Message); return(false); } catch (Symbol.Exceptions.InvalidIndexerException ex) { MessageBox.Show("InitReader" + "\n" + "InvalidIndexer" + "\n" + ex.Message); return(false); }; return(true); } }
/// <summary> /// Stop reading and disable/close the reader. /// </summary> public void TermReader() { // If we have a reader if (myReader != null) { try { // stop all the notifications. StopRead(); //Detach all the notification handler if the user has not done it already. DetachReadNotify(); DetachStatusNotify(); // Disable the reader. myReader.Actions.Disable(); // Free it up. myReader.Dispose(); // Make the reference null. myReader = null; } catch (Symbol.Exceptions.OperationFailureException ex) { MessageBox.Show("TermReader" + "\n" + "OperationFailure" + "\n" + ex.Message + "\n" + "Result" + " = " + (Symbol.Results)((uint)ex.Result) ); } catch (Symbol.Exceptions.InvalidRequestException ex) { MessageBox.Show("TermReader" + "\n" + "InvalidRequest" + "\n" + ex.Message); } catch (Symbol.Exceptions.InvalidIndexerException ex) { MessageBox.Show("TermReader" + "\n" + "InvalidIndexer" + "\n" + ex.Message); }; } // After disposing the reader, dispose the reader data. if (myReaderData != null) { try { // Free it up. myReaderData.Dispose(); // Make the reference null. myReaderData = null; } catch (Symbol.Exceptions.OperationFailureException ex) { MessageBox.Show("TermReader" + "\n" + "OperationFailure" + "\n" + ex.Message + "\n" + "Result" + " = " + (Symbol.Results)((uint)ex.Result) ); } catch (Symbol.Exceptions.InvalidRequestException ex) { MessageBox.Show("TermReader" + "\n" + "InvalidRequest" + "\n" + ex.Message); } catch (Symbol.Exceptions.InvalidIndexerException ex) { MessageBox.Show("TermReader" + "\n" + "InvalidIndexer" + "\n" + ex.Message); }; } }
/// <summary> /// Stop reading and disable/close reader /// </summary> public static void TermReader() { // If we have a reader if (Scanning._MyReader != null) { try { // Disable the reader Scanning._MyReader.Actions.Disable(); // Free it up Scanning._MyReader.Dispose(); // Indicate we no longer have one Scanning._MyReader = null; } catch (Symbol.Exceptions.OperationFailureException ex) { MessageBox.Show("TermReader\n" + "Operation Failure\n" + ex.Message + "\n" + "Result = " + (Symbol.Results)((uint)ex.Result) ); } catch (Symbol.Exceptions.InvalidRequestException ex) { MessageBox.Show("TermReader\n" + "Invalid Request\n" + ex.Message); } catch (Symbol.Exceptions.InvalidIndexerException ex) { MessageBox.Show("TermReader\n" + "Invalid Indexer\n" + ex.Message); }; } // If we have a reader data if (Scanning._MyReaderData != null) { try { // Free it up Scanning._MyReaderData.Dispose(); // Indicate we no longer have one Scanning._MyReaderData = null; } catch (Symbol.Exceptions.OperationFailureException ex) { MessageBox.Show("TermReader\n" + "Operation Failure\n" + ex.Message + "\n" + "Result = " + (Symbol.Results)((uint)ex.Result) ); } catch (Symbol.Exceptions.InvalidRequestException ex) { MessageBox.Show("TermReader\n" + "Invalid Request\n" + ex.Message); } catch (Symbol.Exceptions.InvalidIndexerException ex) { MessageBox.Show("TermReader\n" + "Invalid Indexer\n" + ex.Message); }; } }
internal bool isBackground = false; //The flag used to track whether the application is in background or not (in foreground). /// <summary> /// Initialize the reader. /// </summary> public bool InitReader() { // If the reader is already initialized then fail the initialization. if (myReader != null) { return(false); } else // Else initialize the reader. { try { // Get the device selected by the user. Symbol.Generic.Device MyDevice = Symbol.StandardForms.SelectDevice.Select( Symbol.Barcode.Device.Title, Symbol.Barcode.Device.AvailableDevices); //Select Device from device list Symbol.Audio.Device audioDevice = (Symbol.Audio.Device)Symbol.StandardForms.SelectDevice.Select( Symbol.Audio.Controller.Title, Symbol.Audio.Device.AvailableDevices); if (MyDevice == null) { MessageBox.Show(Resources.GetString("NoDeviceSelected"), Resources.GetString("SelectDevice")); return(false); } // Create the reader, based on selected device. myReader = new Symbol.Barcode.Reader(MyDevice); // Create the reader data. myReaderData = new Symbol.Barcode.ReaderData( Symbol.Barcode.ReaderDataTypes.Text, Symbol.Barcode.ReaderDataLengths.MaximumLabel); // Enable the Reader. myReader.Actions.Enable(); // In this sample, we are setting the aim type to trigger. switch (myReader.ReaderParameters.ReaderType) { case Symbol.Barcode.READER_TYPE.READER_TYPE_IMAGER: myReader.ReaderParameters.ReaderSpecific.ImagerSpecific.AimType = Symbol.Barcode.AIM_TYPE.AIM_TYPE_TRIGGER; break; case Symbol.Barcode.READER_TYPE.READER_TYPE_LASER: myReader.ReaderParameters.ReaderSpecific.LaserSpecific.AimType = Symbol.Barcode.AIM_TYPE.AIM_TYPE_TRIGGER; break; case Symbol.Barcode.READER_TYPE.READER_TYPE_CONTACT: // AimType is not supported by the contact readers. break; } myReader.Actions.SetParameters(); //check the device type switch (audioDevice.AudioType) { //if standard device case Symbol.Audio.AudioType.StandardAudio: myAudioController = new Symbol.Audio.StandardAudio(audioDevice); break; //if simulated device case Symbol.Audio.AudioType.SimulatedAudio: myAudioController = new Symbol.Audio.SimulatedAudio(audioDevice); break; default: throw new Symbol.Exceptions.InvalidDataTypeException("Unknown Device Type"); } myAudioController.BeeperVolume = 0; } catch (Symbol.Exceptions.OperationFailureException ex) { MessageBox.Show(Resources.GetString("InitReader") + "\n" + Resources.GetString("OperationFailure") + "\n" + ex.Message + "\n" + Resources.GetString("Result") + " = " + (Symbol.Results)((uint)ex.Result) ); return(false); } catch (Symbol.Exceptions.InvalidRequestException ex) { MessageBox.Show(Resources.GetString("InitReader") + "\n" + Resources.GetString("InvalidRequest") + "\n" + ex.Message); return(false); } catch (Symbol.Exceptions.InvalidIndexerException ex) { MessageBox.Show(Resources.GetString("InitReader") + "\n" + Resources.GetString("InvalidIndexer") + "\n" + ex.Message); return(false); }; return(true); } }