Search code examples
win-universal-appzxingtorchflashlight

Does default Zxing.Net.Mobile overlay contain a flash/torch button?


I am using the Zxing.Net.Mobile package within my Windows 10 universal app. I use the Default overlay, which is quite nice in my eyes. Now I want to add Flash/Torch funtionality to my application. I only found Solutions defining a new customn overlay. Is it not possible to activate a Torch button in the default overlay? I found a scanner.FlashButtonText Definition, so i think a flashbutton should somehow be activatable and i just dont know the Name of this Parameter. Can someone help me with this? Thanks.

my Code Looks like this:

            var options = new MobileBarcodeScanningOptions
            {
                AutoRotate = false,
                TryHarder = true,
                PossibleFormats = new List<ZXing.BarcodeFormat>
                {
                    ZXing.BarcodeFormat.EAN_8, ZXing.BarcodeFormat.EAN_13, ZXing.BarcodeFormat.UPC_A, ZXing.BarcodeFormat.UPC_E
                }
            };


            var scanner = new MobileBarcodeScanner(this.Dispatcher);

            scanner.UseCustomOverlay = false;
            scanner.RootFrame = MyFrame;
            scanner.TopText = "Halte die Kamera vor den Barcode";
            scanner.BottomText = "Die Kamera scannt den Barcode automatisch";
            scanner.FlashButtonText = "activate Torch";


            var result = await scanner.Scan(options);

Solution

  • Although MobileBarcodeScanner has a FlashButtonText property, but according to ZXing.Net.Mobile's source code, Flash/Torch function is not supported in the default overlay by now.

    The default overlay is set by ZXingScannerControl and if we look at its source code, we will find it does have a button named "buttonToggleFlash". However this button is invisible and there is no property can control its visibility.

    source code:

    <Border Grid.Row="0" Visibility="Collapsed" VerticalAlignment="Top" HorizontalAlignment="Right" Width="120" Height="80">
        <Button x:Name="buttonToggleFlash" Click="buttonToggleFlash_Click">Flash</Button>
    </Border> 
    

    So to support Flash/Torch function, you need a customn overlay. Or you can edit the source code and rebuild ZXing.Net.Mobile for your purpose.