void SelectReader() { if ((ReaderList != null) || (Reader != null)) { if (!UserWantsToClose()) { return; } CloseDevice(); } ReaderSelectForm f = new ReaderSelectForm(); bool rc = (f.ShowDialog(this) == DialogResult.OK); if (rc) { string ReaderName = f.SelectedReader; ReaderList = new SCardReaderList(); if (ReaderList != null) { Reader = ReaderList.GetReader(ReaderName); if (Reader != null) { DisplayReaderPresent(); Reader.StartMonitor(new SCardReader.StatusChangeCallback(ReaderStatusChanged)); return; } else { MessageBox.Show(this, "Failed to connect to the PC/SC reader. Please click the 'Reader' link to select another reader.", Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } ReaderList = null; } else { MessageBox.Show(this, "The PC/SC subsystem doesn't seem to be running. Please check your system's configuration.", Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
void SelectReader() { if ((ReaderList != null) || (Reader != null)) { if (!UserWantsToClose()) { return; } CloseDevice(); } ReaderSelectAnyForm f = new ReaderSelectAnyForm(); bool rc = (f.ShowDialog(this) == DialogResult.OK); if (rc) { if (f.Mode == "pc/sc") { string ReaderName; f.GetPCSCParameters(out ReaderName); ReaderList = new SCardReaderList(); if (ReaderList != null) { Reader = ReaderList.GetReader(ReaderName); if (Reader != null) { DisplayReaderPresent(); Reader.StartMonitor(new SCardReader.StatusChangeCallback(ReaderStatusChanged)); } else { MessageBox.Show(this, "Failed to connect to the PC/SC reader. Please click the 'Reader' link to select another reader.", Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show(this, "The PC/SC subsystem doesn't seem to be running. Please check your system's configuration.", Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else if (f.Mode == "serial") { string PortName; bool UseNotifications; bool UseLpcdPolling; f.GetSerialParameters(out PortName, out UseNotifications, out UseLpcdPolling); SCardReaderList_CcidOverSerial.BackgroundInstantiate( new SCardReaderList_CcidOverSerial.BackgroundInstantiateCallback(OnSerialReaderListInstantiated), PortName, UseNotifications, UseLpcdPolling); } else if (f.Mode == "network") { string Address; ushort Port; f.GetNetworkParameters(out Address, out Port); SCardReaderList_CcidOverNetwork.BackgroundInstantiate( new SCardReaderList_CcidOverNetwork.BackgroundInstantiateCallback(OnNetworkReaderListInstantiated), Address, Port); } } }