forked from Redth/ZXing.Net.Mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZXingScannerView.shared.cs
94 lines (76 loc) · 2.83 KB
/
ZXingScannerView.shared.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using System.Windows.Input;
using Xamarin.Forms;
using ZXing.Mobile;
namespace ZXing.Net.Mobile.Forms
{
public class ZXingScannerView : View
{
public delegate void ScanResultDelegate(Result result);
public event ScanResultDelegate OnScanResult;
public event Action<int, int> AutoFocusRequested;
public ZXingScannerView()
{
VerticalOptions = LayoutOptions.FillAndExpand;
HorizontalOptions = LayoutOptions.FillAndExpand;
}
public void RaiseScanResult(Result result)
{
Result = result;
OnScanResult?.Invoke(Result);
ScanResultCommand?.Execute(Result);
}
public void ToggleTorch()
=> IsTorchOn = !IsTorchOn;
public void AutoFocus()
=> AutoFocusRequested?.Invoke(-1, -1);
public void AutoFocus(int x, int y)
=> AutoFocusRequested?.Invoke(x, y);
public static readonly BindableProperty OptionsProperty =
BindableProperty.Create(nameof(Options), typeof(MobileBarcodeScanningOptions), typeof(ZXingScannerView), MobileBarcodeScanningOptions.Default);
public MobileBarcodeScanningOptions Options
{
get => (MobileBarcodeScanningOptions)GetValue(OptionsProperty);
set => SetValue(OptionsProperty, value);
}
public static readonly BindableProperty IsScanningProperty =
BindableProperty.Create(nameof(IsScanning), typeof(bool), typeof(ZXingScannerView), false);
public bool IsScanning
{
get => (bool)GetValue(IsScanningProperty);
set => SetValue(IsScanningProperty, value);
}
public static readonly BindableProperty IsTorchOnProperty =
BindableProperty.Create(nameof(IsTorchOn), typeof(bool), typeof(ZXingScannerView), false);
public bool IsTorchOn
{
get => (bool)GetValue(IsTorchOnProperty);
set => SetValue(IsTorchOnProperty, value);
}
public static readonly BindableProperty HasTorchProperty =
BindableProperty.Create(nameof(HasTorch), typeof(bool), typeof(ZXingScannerView), false);
public bool HasTorch
=> (bool)GetValue(HasTorchProperty);
public static readonly BindableProperty IsAnalyzingProperty =
BindableProperty.Create(nameof(IsAnalyzing), typeof(bool), typeof(ZXingScannerView), true);
public bool IsAnalyzing
{
get => (bool)GetValue(IsAnalyzingProperty);
set => SetValue(IsAnalyzingProperty, value);
}
public static readonly BindableProperty ResultProperty =
BindableProperty.Create(nameof(Result), typeof(Result), typeof(ZXingScannerView), default(Result));
public Result Result
{
get => (Result)GetValue(ResultProperty);
set => SetValue(ResultProperty, value);
}
public static readonly BindableProperty ScanResultCommandProperty =
BindableProperty.Create(nameof(ScanResultCommand), typeof(ICommand), typeof(ZXingScannerView), default(ICommand));
public ICommand ScanResultCommand
{
get => (ICommand)GetValue(ScanResultCommandProperty);
set => SetValue(ScanResultCommandProperty, value);
}
}
}