mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-12 14:51:44 +01:00
121 lines
3.2 KiB
C#
121 lines
3.2 KiB
C#
using Borepin.Base;
|
|
using Prism.Commands;
|
|
using Prism.Navigation;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Input;
|
|
using Xamarin.Forms;
|
|
using ZXing;
|
|
|
|
namespace Borepin.PageModel
|
|
{
|
|
class ScanPageModel : PageModelBase
|
|
{
|
|
#region Private Fields
|
|
private object _Instance;
|
|
private readonly INavigationService _NavigationService;
|
|
#endregion
|
|
|
|
#region Contructors
|
|
public ScanPageModel(INavigationService navigationService) : base(navigationService)
|
|
{
|
|
_NavigationService = navigationService;
|
|
|
|
AbortCommand = new DelegateCommand(async () => await AbortCommandExecute().ConfigureAwait(true));
|
|
ScannedCommand = new DelegateCommand(ScannedCommandExecute);
|
|
|
|
IsVisible = true;
|
|
IsScanning = true;
|
|
}
|
|
#endregion
|
|
|
|
#region Data
|
|
public override async Task LoadData()
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Fields
|
|
private Result _ScanResult;
|
|
public Result ScanResult
|
|
{
|
|
get => _ScanResult;
|
|
set => SetProperty(ref _ScanResult, value);
|
|
}
|
|
|
|
private bool _IsScanning;
|
|
public bool IsScanning
|
|
{
|
|
get => _IsScanning;
|
|
set => SetProperty(ref _IsScanning, value);
|
|
}
|
|
|
|
private bool _IsVisible;
|
|
public bool IsVisible
|
|
{
|
|
get => _IsVisible;
|
|
set => SetProperty(ref _IsVisible, value);
|
|
}
|
|
#endregion
|
|
|
|
#region Commands
|
|
private ICommand _ScannedCommand;
|
|
|
|
public ICommand ScannedCommand
|
|
{
|
|
get => _ScannedCommand;
|
|
set => SetProperty(ref _ScannedCommand, value);
|
|
}
|
|
public void ScannedCommandExecute()
|
|
{
|
|
IsScanning = false;
|
|
IsVisible = false;
|
|
|
|
INavigationParameters parameters = new NavigationParameters()
|
|
{
|
|
{ "result", "scanned" },
|
|
{ "value", ScanResult.Text },
|
|
{ "instance", _Instance }
|
|
};
|
|
|
|
Device.BeginInvokeOnMainThread(async () =>
|
|
{
|
|
INavigationResult result = await _NavigationService.GoBackAsync(parameters).ConfigureAwait(false);
|
|
});
|
|
}
|
|
|
|
private ICommand _AbortCommand;
|
|
public ICommand AbortCommand
|
|
{
|
|
get => _AbortCommand;
|
|
set => SetProperty(ref _AbortCommand, value);
|
|
}
|
|
public async Task AbortCommandExecute()
|
|
{
|
|
IsScanning = false;
|
|
IsVisible = false;
|
|
|
|
INavigationParameters parameters = new NavigationParameters()
|
|
{
|
|
{ "result", "abort" },
|
|
{ "instance", _Instance }
|
|
};
|
|
await _NavigationService.GoBackAsync(parameters).ConfigureAwait(false);
|
|
}
|
|
#endregion
|
|
|
|
#region INavigationService
|
|
public override void OnNavigatedFrom(INavigationParameters parameters)
|
|
{
|
|
|
|
}
|
|
|
|
public override void OnNavigatedTo(INavigationParameters parameters)
|
|
{
|
|
_Instance = parameters.GetValue<object>("instance");
|
|
}
|
|
#endregion
|
|
}
|
|
}
|