protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (State.ContainsKey("txtAccountName") && newPageInstance == true)
            {
                txtAccountName.Text = (string)State["txtAccountName"];
                txtSecretKey.Text   = (string)State["txtSecretKey"];
            }

            if ((App.Current as App).QRCode != null)
            {
                //QR code has been received

                BarcodeCaptureResult scan_e = new BarcodeCaptureResult();
                scan_e.State                = WP7_Barcode_Library.CaptureState.Success;
                scan_e.BarcodeText          = (App.Current as App).QRCode;
                (App.Current as App).QRCode = null;

                ScanBarcode_Completed(scan_e);
            }

            base.OnNavigatedTo(e);
        }
        public void ScanBarcode_Completed(BarcodeCaptureResult e)
        {
            if (e.State == WP7_Barcode_Library.CaptureState.Success)
            {
                string str = e.BarcodeText;
                try
                {
                    str = str.Replace("otpauth://totp/", "");
                    string[] splitString = str.Split(Convert.ToChar("?"));
                    splitString[1] = splitString[1].Replace("secret=", "");

                    txtAccountName.Text = splitString[0];
                    txtSecretKey.Text   = splitString[1];

                    return;
                }
                catch
                {
                }
            }

            MessageBox.Show("The barcode for your account could not be read. Please try again.", "Error", MessageBoxButton.OK);
        }