/// <summary> /// Click on "Step by step" button. Only available for USB devices. /// Enable lighting on all device's axises and send lighting order to each selected tag. /// </summary> /// <param name="sender">event sender</param> /// <param name="e">event args</param> private void buttonLedOn_Click(object sender, EventArgs e) { buttonLedOn.Enabled = false; Cursor.Current = Cursors.WaitCursor; if (_currentUSBDevice.get_RFID_Device.HardwareVersion.StartsWith("11")) { buttonLedOnAll_Click(null, null); return; } List <string> tags = new List <string>(); Hashtable tagLedStateTable = new Hashtable(); foreach (string item in listBoxTag.SelectedItems) { tags.Add(item); tagLedStateTable.Add(item, false); } int nbLighted = 0, totalLighted = 0, currentChannel = 0; bool userChoice = true, isLastStep = false; for (int i = 1; i < 5; ++i) { _currentUSBDevice.get_RFID_Device.StartLedOn(i); } while (userChoice && !isLastStep) // While users want to go on searching and we didn't browse all device axis { isLastStep = _currentUSBDevice.StartLightingLeds(tags, tagLedStateTable, out currentChannel, out nbLighted); if (nbLighted == 0) { continue; } totalLighted += nbLighted; if (totalLighted == tags.Count) { break; } string message = String.Format("Channel {3} : {0} / {1} found. Until now : {2} / {1} found. Continue ?", nbLighted, tags.Count, totalLighted, currentChannel); DialogResult dialogChoice = MessageBox.Show(message, "Research in progress...", MessageBoxButtons.YesNo, MessageBoxIcon.Question); userChoice = (dialogChoice != DialogResult.No); } if (totalLighted == tags.Count) { string message = String.Format("Channel {3} : {0} / {1} found. Total : {2} / {1} found.", nbLighted, tags.Count, totalLighted, currentChannel); MessageBox.Show(message, "Research over", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (isLastStep) { string message = String.Format("All axis have been browsed. {0} tags not found. Missing tags ID :", tags.Count - totalLighted); foreach (DictionaryEntry entryTag in tagLedStateTable) { if (!(bool)entryTag.Value) { message = String.Format("{0}\n{1}", message, entryTag.Key); } } MessageBox.Show(message, "Research over", MessageBoxButtons.OK, MessageBoxIcon.Information); } } _currentUSBDevice.StopLightingLeds(); Cursor.Current = Cursors.Default; buttonLedOn.Enabled = true; }