예제 #1
0
        /// <summary>
        /// ScanCode
        /// Scan a QR Code using the ZXing library
        /// </summary>
        /// <returns></returns>
        private async Task ScanCode()
        {
            Scanner.UseCustomOverlay = false;
            Scanner.TopText          = "Hold camera up to QR code";
            Scanner.BottomText       = "Camera will automatically scan QR code\r\n\rPress the 'Back' button to cancel";

            ZXing.Result result = await Scanner.Scan().ConfigureAwait(true);

            if (result == null || (string.IsNullOrEmpty(result.Text)))
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    MessageDialog dialog = new MessageDialog("An error occured while scanning the QRCode. Try again");
                    await dialog.ShowAsync();
                });
            }
            else
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    TBConnectionString.Text = result.Text;
                    TBDeviceName.Text       = CTD.ExtractDeviceIdFromConnectionString(result.Text);
                });
            }
        }