Zxing.Net.Mobile默认默认包含闪光灯/手电筒按钮吗?
问题描述:
我在Windows 10通用应用程序中使用Zxing.Net.Mobile软件包。我使用默认叠加层,这在我眼中是相当不错的。现在我想为我的应用程序添加Flash/Torch功能。我只找到定义一个新的customn覆盖的解决方案。是否无法激活默认叠加中的Torch按钮?我找到了一个scanner.FlashButtonText定义,所以我认为flashbutton应该可以激活,我只是不知道这个参数的名称。有人可以帮我弄这个吗?谢谢。Zxing.Net.Mobile默认默认包含闪光灯/手电筒按钮吗?
我的代码如下所示:
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);
答
虽然MobileBarcodeScanner
有FlashButtonText
财产,但根据ZXing.Net.Mobile's source code,闪光/手电筒功能未在默认覆盖现在支持。
默认覆盖由ZXingScannerControl设置,如果我们看一下它的源代码,我们会发现它确实有一个名为按钮“buttonToggleFlash”。但是这个按钮是不可见的,没有属性可以控制其可见性。
<Border Grid.Row="0" Visibility="Collapsed" VerticalAlignment="Top" HorizontalAlignment="Right" Width="120" Height="80">
<Button x:Name="buttonToggleFlash" Click="buttonToggleFlash_Click">Flash</Button>
</Border>
因此支持Flash /手电筒功能,你需要一个customn覆盖。或者您可以编辑源代码并为您的目的重建ZXing.Net.Mobile。