// L'assembly utilisé using Symbol.Barcode // Les objets utiles Reader myReader = null; ReaderData myReaderData = null; EventHandler myReadNotifyHandler = null; EventHandler myStatusNotifyHandler = null; // Faire une fnc d'init (a mettre dans une classe outil) myReader = new Reader(); // utilise le Device primaire myReaderData = new ReaderData( ReaderDataTypes.Text, ReaderDataLengths.MaximumLabel); myReader.Actions.Enable(); // Laser myReader.ReaderParameters.ReaderSpecific.LaserSpecific.AimType = AIM_TYPE.AIM_TYPE_TRIGGER; // Active les decodeurs par défaut myReader.Decoders.DEFAULT.Enabled = true; // ou active un type spécifique myReader.Decoders.SetEnabled(DecoderTypes.CODE128, true); // Rends les éventuelles modifications actives myReader.Actions.SetParameters(); // Faire une fonction StartRead public void StartRead(bool toggleSoftTrigger) { // Submit a read } // Faire un fnc StopRead public void StopRead() { } // Et faire les fnc Attach et DetachNotify public void AttachReadNotify(EventHandler ReadNotifyHandler) { } public void DetachReadNotify() { } // Enfin faire les fnc Attach et DetachStatusNotify public void AttachStatusNotify(EventHandler StatNotifyHandler) { } public void DetachStatusNotify() { } // Dans l'app. principale, suffit d'utiliser le tout // dans une méthode du style private void loadScanData(bool bActivate) { if ( bActivate ) { // Start a read operation & attach a handler. this.m_refAPI.StartRead(false); this.myReadNotifyHandler = new EventHandler(myReader_ReadNotify); this.m_refAPI.AttachReadNotify(myReadNotifyHandler); } else { this.m_refAPI.StopRead(); this.m_refAPI.DetachReadNotify(); this.myReadNotifyHandler = null; } } // this est un formulaire // m_refAPI est la classe outil qui encapsule les APIs Symbol
24 sept. 2013 à 10:31