private void WorkWithTextBox(List <string> list, EnumTextBox etb) { int i = 0; foreach (var item in list) { i++; switch (etb) { case EnumTextBox.Ncreate: NewCreateTextBox.AppendText(i.ToString() + " ) " + item + Environment.NewLine); break; case EnumTextBox.found: YFoundTextBox.AppendText(i.ToString() + " ) " + item + Environment.NewLine); break; case EnumTextBox.Nfound: NotFoundTextBox.AppendText(i.ToString() + " ) " + item + Environment.NewLine); break; default: break; } } }
private void bEnumCards_Click(object sender, EventArgs e) { EnumTextBox.Clear(); CardComboBox.Items.Clear(); BlockDataTextBox.Clear(); SelectedCardTextBox.Text = "Card not selected"; TempCardsNumber = 0; byte CardsNumber = 0; byte ListSize = 0; byte index = 0; byte[] list = new byte[44]; unsafe { status = uFCoder.EnumCards(&CardsNumber, &ListSize); TempCardsNumber = CardsNumber; if (status == 0) { EnumTextBox.AppendText("There is " + CardsNumber.ToString() + " card(s) in the reader field."); if (CardsNumber > 0) { status = uFCoder.ListCards(list, ListSize); if (status != 0) { MessageBox.Show("Unable to enumerate cards!"); } else { index = 0; EnumTextBox.AppendText("\n\nUid list of the cards in the reader field:\n"); for (byte i = 0; i < CardsNumber; i++) { EnumTextBox.AppendText("\n" + (i + 1).ToString() + ". "); EnumTextBox.AppendText(ByteArrayToString(list, (byte)(index + 1), (byte)(list[index] + index + 1))); index += 11; CardComboBox.Items.Add((i + 1).ToString()); } CardComboBox.SelectedIndex = CardComboBox.Items.IndexOf("1"); } TempUid = list.ToArray(); } } else { MessageBox.Show("Error while trying to enumerate cards!"); } } }