private void RaisePcScEvent(SCRState state, string readerName) { bool doRaiseEvent = true; var eventargs = new NfcEventArgs(); eventargs.ReaderName = readerName; eventargs.Data = $"New State for {readerName}: {state.ToString()}"; switch (state) { case SCRState.Changed: eventargs.Type = NfcEventType.StatusChanged; break; case SCRState.Empty: case SCRState.Unavailable: eventargs.Type = NfcEventType.Disconnected; lastUniqueId = null; break; case SCRState.Present: eventargs.Type = NfcEventType.Connected; eventargs.UniqueCardID = state.CardIsPresent() ? GetUid(readerName) : null; if (eventargs.UniqueCardID == lastUniqueId) { doRaiseEvent = false; } break; case SCRState.Unknown: eventargs.Type = NfcEventType.Unknown; break; default: doRaiseEvent = false; break; } if (doRaiseEvent && lastEventType != eventargs.Type) { string debugText = $"PcscWrapper: {eventargs.Type.ToString()} UID: "; debugText += eventargs.UniqueCardID ?? "N/A"; Debug.WriteLine(debugText); System.Threading.Thread.Sleep(200); PcScNfcEventReceived?.Invoke(this, eventargs); lastUniqueId = eventargs.UniqueCardID; lastEventType = eventargs.Type; } }
private bool IsExclusiveState(SCRState state) { return(state.ToString().Contains(SCRState.Exclusive.ToString())); }