Beispiel #1
0
        /// <summary>
        /// Enable the magnetic stripe reader.
        /// </summary>
        /// <returns>true if claim is successful. Otherwise returns false</returns>
        private async Task <bool> EnableReader()
        {
            await _claimedReader.EnableAsync();

            UpdateReaderStatusTextBlock("Enable Magnetic Stripe Reader succeeded.");
            return(true);
        }
Beispiel #2
0
        private async void ScenarioStartReadButton_Click(object sender, RoutedEventArgs e)
        {
            if (await CreateDefaultMagneticStripeReaderObject())
            {
                if (_reader != null)
                {
                    // after successful creation, claim the reader for exclusive use and enable it so that data reveived events are received.
                    if (await ClaimReader())
                    {
                        if (_claimedReader != null)
                        {
                            // It is always a good idea to have a release device requested event handler. If this event is not handled, there is a chance that another app can
                            // claim ownsership of the magnetic stripe reader.
                            _claimedReader.ReleaseDeviceRequested += OnReleaseDeviceRequested;

                            // after successfully claiming and enabling, attach the AamvaCardDataReceived event handler.
                            // Note: If the scanner is not enabled (i.e. EnableAsync not called), attaching the event handler will not be of any use because the API will not fire the event
                            // if the claimedScanner has not beed Enabled
                            _claimedReader.AamvaCardDataReceived += OnAamvaCardDataReceived;

                            // Ask the API to decode the data by default. By setting this, API will decode the raw data from the magnetic stripe reader
                            _claimedReader.IsDecodeDataEnabled = true;

                            await _claimedReader.EnableAsync();

                            rootPage.NotifyUser("Ready to swipe. Device ID: " + _claimedReader.DeviceId, NotifyType.StatusMessage);

                            // reset the button state
                            ScenarioEndReadButton.IsEnabled   = true;
                            ScenarioStartReadButton.IsEnabled = false;
                        }
                    }
                }
            }
        }
        //</SnippetClaimMagStripeReader>

        //<SnippetEnableMagStripeReader>
        // Enables the magnetic stripe reader to receive data
        private async Task <bool> EnableReader()
        {
            await _claimedReader.EnableAsync();

            return(true);
        }