|
|
@ -8,6 +8,7 @@ using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Windows.Input;
|
|
|
|
using System.Windows.Input;
|
|
|
|
using ViewModels;
|
|
|
|
using ViewModels;
|
|
|
|
|
|
|
|
using ZXing;
|
|
|
|
|
|
|
|
|
|
|
|
namespace LivreLand.ViewModel
|
|
|
|
namespace LivreLand.ViewModel
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -15,26 +16,40 @@ namespace LivreLand.ViewModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#region Fields
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private CameraView cameraView;
|
|
|
|
private CameraInfo camera = null;
|
|
|
|
private CameraInfo camera = null;
|
|
|
|
private ObservableCollection<CameraInfo> cameras = new();
|
|
|
|
private ObservableCollection<CameraInfo> cameras = new();
|
|
|
|
private int camerasCount;
|
|
|
|
private int camerasCount;
|
|
|
|
|
|
|
|
private Result[] result;
|
|
|
|
private string barcodeText = "ISBN";
|
|
|
|
private string barcodeText = "ISBN";
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Properties
|
|
|
|
#region Properties
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CameraView CameraView
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
get => cameraView;
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (cameraView != value)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cameraView = value;
|
|
|
|
|
|
|
|
OnPropertyChanged(nameof(CameraView));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CameraInfo Camera
|
|
|
|
public CameraInfo Camera
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get => camera;
|
|
|
|
get => camera;
|
|
|
|
set
|
|
|
|
set
|
|
|
|
{
|
|
|
|
{
|
|
|
|
camera = value;
|
|
|
|
if (camera != value)
|
|
|
|
OnPropertyChanged(nameof(Camera));
|
|
|
|
{
|
|
|
|
AutoStartPreview = false;
|
|
|
|
camera = value;
|
|
|
|
OnPropertyChanged(nameof(AutoStartPreview));
|
|
|
|
OnPropertyChanged(nameof(Camera));
|
|
|
|
AutoStartPreview = true;
|
|
|
|
}
|
|
|
|
OnPropertyChanged(nameof(AutoStartPreview));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -63,6 +78,19 @@ namespace LivreLand.ViewModel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Result[] BarCodeResult
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
get => result;
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (result != value)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result = value;
|
|
|
|
|
|
|
|
OnPropertyChanged(nameof(BarCodeResult));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string BarcodeText
|
|
|
|
public string BarcodeText
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get => barcodeText;
|
|
|
|
get => barcodeText;
|
|
|
@ -84,12 +112,10 @@ namespace LivreLand.ViewModel
|
|
|
|
|
|
|
|
|
|
|
|
public ManagerVM Manager { get; private set; }
|
|
|
|
public ManagerVM Manager { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
public ICommand StartCameraCommand { get; private set; }
|
|
|
|
public ICommand CamerasLoadCommand { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
public ICommand BarcodeDetectCommand { get; private set; }
|
|
|
|
public ICommand BarcodeDetectCommand { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
public ICommand StartRecordingCommand { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Constructor
|
|
|
|
#region Constructor
|
|
|
@ -98,30 +124,33 @@ namespace LivreLand.ViewModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Navigator = navigatorVM;
|
|
|
|
Navigator = navigatorVM;
|
|
|
|
Manager = managerVM;
|
|
|
|
Manager = managerVM;
|
|
|
|
StartCameraCommand = new RelayCommand(() => StartCamera());
|
|
|
|
CamerasLoadCommand = new RelayCommand(() => CamerasLoad());
|
|
|
|
BarcodeDetectCommand = new RelayCommand(() => BarcodeDetect());
|
|
|
|
BarcodeDetectCommand = new RelayCommand(() => BarcodeDetect());
|
|
|
|
StartRecordingCommand = new RelayCommand(() => StartRecording());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Methods
|
|
|
|
#region Methods
|
|
|
|
|
|
|
|
|
|
|
|
private async Task StartCamera()
|
|
|
|
private async Task CamerasLoad()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AutoStartPreview = true;
|
|
|
|
if (Cameras.Count > 0)
|
|
|
|
OnPropertyChanged(nameof(AutoStartPreview));
|
|
|
|
{
|
|
|
|
|
|
|
|
Camera = Cameras.First();
|
|
|
|
|
|
|
|
MainThread.BeginInvokeOnMainThread(async () =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await CameraView.StopCameraAsync();
|
|
|
|
|
|
|
|
await CameraView.StartCameraAsync();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async Task BarcodeDetect()
|
|
|
|
private async Task BarcodeDetect()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
MainThread.BeginInvokeOnMainThread(() =>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
|
|
|
|
BarcodeText = BarCodeResult[0].Text;
|
|
|
|
private async Task StartRecording()
|
|
|
|
});
|
|
|
|
{
|
|
|
|
|
|
|
|
AutoStartRecording = true;
|
|
|
|
|
|
|
|
OnPropertyChanged(nameof(AutoStartRecording));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|