Пример #1
0
        public ScanPage(MainPage mainPage) : base()
        {
            zxing = new ZXingScannerView
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                AutomationId      = "zxingScannerView",
            };
            zxing.OnScanResult += (result) =>
            {
                zxing.Unfocus();
                zxing.IsScanning  = false;
                zxing.IsAnalyzing = false;
                Device.BeginInvokeOnMainThread(async() =>
                {
                    await Navigation.PopAsync();
                    mainPage.CheckCode(result.Text);
                });
            };

            overlay = new ZXingDefaultOverlay
            {
                //TopText = "Přiložte váš telefon ke QR kódu",
                //BottomText = "Skenování se provede automaticky",
                ShowFlashButton = zxing.HasTorch,
                AutomationId    = "zxingDefaultOverlay",
            };

            overlay.FlashButtonClicked += (sender, e) => {
                zxing.IsTorchOn = !zxing.IsTorchOn;
            };
            var grid = new Grid
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            grid.Children.Add(zxing);
            grid.Children.Add(overlay);

            // The root page of your application
            Content = grid;
        }