mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-12 23:01:52 +01:00
Added Scan QR Code in seperate Page
This commit is contained in:
parent
52d6537b4c
commit
d6ac268516
@ -11,6 +11,7 @@ using Borepin.PageModel.SetUpProcess;
|
||||
using Borepin.Page.AddServerProcess;
|
||||
using Borepin.PageModel.AddServerProcess;
|
||||
using System;
|
||||
using Prism.Navigation;
|
||||
|
||||
namespace Borepin
|
||||
{
|
||||
@ -25,6 +26,11 @@ namespace Borepin
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
INavigationParameters parameters = new NavigationParameters()
|
||||
{
|
||||
{ "instance", 0 },
|
||||
};
|
||||
|
||||
await NavigationService.NavigateAsync(new Uri("https://borepin.fab-access.org/StartPage")).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@ -41,12 +47,11 @@ namespace Borepin
|
||||
containerRegistry.RegisterForNavigation<MachineListPage, MachineListPageModel>();
|
||||
containerRegistry.RegisterForNavigation<ServerListPage, ServerListPageModel>();
|
||||
containerRegistry.RegisterForNavigation<ServerPage, ServerPageModel>();
|
||||
containerRegistry.RegisterForNavigation<ScannerPage>();
|
||||
containerRegistry.RegisterForNavigation<ScanPage, ScanPageModel>();
|
||||
#endregion
|
||||
|
||||
#region Register Sequence Navigation
|
||||
containerRegistry.RegisterForNavigation<WelcomePage, WelcomePageModel>("SetUpProcess_WelcomePage");
|
||||
//containerRegistry.RegisterForNavigation<ScanPage, ScanPageModel>("SetUpProcess_ScanPage");
|
||||
|
||||
containerRegistry.RegisterForNavigation<AuthPlainPage, AuthPlainPageModel>("AddServerProcess_AuthPlainPage");
|
||||
containerRegistry.RegisterForNavigation<SelectServerPage, SelectServerPageModel>("AddServerProcess_SelectServerPage");
|
||||
|
@ -101,7 +101,7 @@
|
||||
<EmbeddedResource Update="Page\MainPage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="Page\ScannerPage.xaml">
|
||||
<EmbeddedResource Update="Page\ScanPage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="Page\ServerListPage.xaml">
|
||||
|
12
Borepin/Borepin/Page/ScanPage.xaml
Normal file
12
Borepin/Borepin/Page/ScanPage.xaml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:zxing="clr-namespace:ZXing.Net.Mobile.Forms;assembly=ZXing.Net.Mobile.Forms"
|
||||
x:Class="Borepin.Page.ScanPage">
|
||||
<ContentPage.Content>
|
||||
<StackLayout IsVisible="{Binding IsVisible}">
|
||||
<zxing:ZXingScannerView Result="{Binding ScanResult, Mode=TwoWay}" ScanResultCommand="{Binding ScannedCommand}" IsScanning="{Binding IsScanning}" WidthRequest="300" HeightRequest="500" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand"/>
|
||||
<Button Text="Abort" Command="{Binding AbortCommand}"/>
|
||||
</StackLayout>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
20
Borepin/Borepin/Page/ScanPage.xaml.cs
Normal file
20
Borepin/Borepin/Page/ScanPage.xaml.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace Borepin.Page
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class ScanPage : ContentPage
|
||||
{
|
||||
public ScanPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<zxing:ZXingScannerPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Borepin.Page.ScannerPage"
|
||||
xmlns:zxing="clr-namespace:ZXing.Net.Mobile.Forms;assembly=ZXing.Net.Mobile.Forms"
|
||||
Title="Full screen"
|
||||
OnScanResult="Handle_OnScanResult"
|
||||
IsScanning="true">
|
||||
</zxing:ZXingScannerPage>
|
@ -1,44 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
using ZXing;
|
||||
using ZXing.Net.Mobile.Forms;
|
||||
|
||||
namespace Borepin.Page
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class ScannerPage : ZXingScannerPage
|
||||
{
|
||||
public ScannerPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void Handle_OnScanResult(Result result)
|
||||
{
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
await DisplayAlert("Scanned result", result.Text, "OK").ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
|
||||
IsScanning = true;
|
||||
}
|
||||
|
||||
protected override void OnDisappearing()
|
||||
{
|
||||
base.OnDisappearing();
|
||||
|
||||
IsScanning = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Borepin.Page.SetUpProcess.ScanPage"
|
||||
xmlns:i18n="clr-namespace:Borepin.Helpers"
|
||||
xmlns:views="clr-namespace:Borepin.View"
|
||||
Title="FabAccess">
|
||||
<ContentPage.Content>
|
||||
<ScrollView>
|
||||
<StackLayout Style="{StaticResource Style_StackLayout_Content}">
|
||||
<Label Text="{i18n:Translate SetUp_ScanPage_Text}" Style="{StaticResource Style_Label_Text_Center}"/>
|
||||
<Button Text="{i18n:Translate SetUp_ScanPage_Button}" Command="{Binding NextCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
@ -31,7 +31,7 @@ namespace Borepin.PageModel
|
||||
_DialogService = dialogService;
|
||||
|
||||
SelectInstanceCommand = new DelegateCommand<object>(SelectInstanceCommandExecute);
|
||||
ScanCodeCommand = new DelegateCommand(ScanCodeCommandExecute);
|
||||
ScanCodeCommand = new DelegateCommand(async () => await ScanCodeCommandExecute().ConfigureAwait(false));
|
||||
RefreshCommand = new DelegateCommand(async ()=> await RefreshCommandExecute().ConfigureAwait(true));
|
||||
}
|
||||
#endregion
|
||||
@ -138,38 +138,40 @@ namespace Borepin.PageModel
|
||||
get => _ScanCodeCommand;
|
||||
set => SetProperty(ref _ScanCodeCommand, value);
|
||||
}
|
||||
public void ScanCodeCommandExecute()
|
||||
public async Task ScanCodeCommandExecute()
|
||||
{
|
||||
IsBusy = true;
|
||||
|
||||
_DialogService.ShowDialog("ScanDialog", ScanCodeCommandExecute_Dialog);
|
||||
NavigationParameters parameters = new NavigationParameters()
|
||||
{
|
||||
{"intance", null },
|
||||
};
|
||||
|
||||
await _NavigationService.NavigateAsync("ScanPage", parameters).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async void ScanCodeCommandExecute_Dialog(IDialogResult result)
|
||||
public async void ScanCode_Result(string value)
|
||||
{
|
||||
if (string.Equals(result.Parameters.GetValue<string>("result"), "scanned", System.StringComparison.Ordinal))
|
||||
if (! _BFFHService.IsConnected)
|
||||
{
|
||||
if (! _BFFHService.IsConnected)
|
||||
{
|
||||
IsConnected = false;
|
||||
IsBusy = false;
|
||||
return;
|
||||
}
|
||||
|
||||
IMachineSystem machineInterface = (await _BFFHService.GetSession().ConfigureAwait(false)).MachineSystem;
|
||||
MachineSystem.IInfoInterface infoInterface = await machineInterface.Info().ConfigureAwait(false);
|
||||
|
||||
Machine machine = await infoInterface.GetMachineURN(result.Parameters.GetValue<string>("value")).ConfigureAwait(false);
|
||||
|
||||
if(machine == null)
|
||||
{
|
||||
IsBusy = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_NextMachine = machine;
|
||||
IsConnected = false;
|
||||
IsBusy = false;
|
||||
return;
|
||||
}
|
||||
|
||||
IMachineSystem machineInterface = (await _BFFHService.GetSession().ConfigureAwait(false)).MachineSystem;
|
||||
MachineSystem.IInfoInterface infoInterface = await machineInterface.Info().ConfigureAwait(false);
|
||||
|
||||
Machine machine = await infoInterface.GetMachineURN(value).ConfigureAwait(false);
|
||||
|
||||
if(machine == null)
|
||||
{
|
||||
IsBusy = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_NextMachine = machine;
|
||||
IsBusy = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -204,6 +206,16 @@ namespace Borepin.PageModel
|
||||
public override async void OnNavigatedTo(INavigationParameters parameters)
|
||||
{
|
||||
IsBusy = true;
|
||||
|
||||
if (parameters["result"] != null)
|
||||
{
|
||||
if (parameters["result"].Equals("scanned"))
|
||||
{
|
||||
string urn = (string)parameters["value"];
|
||||
ScanCode_Result(urn);
|
||||
}
|
||||
}
|
||||
|
||||
await LoadData().ConfigureAwait(false);
|
||||
}
|
||||
#endregion
|
||||
|
118
Borepin/Borepin/PageModel/ScanPageModel.cs
Normal file
118
Borepin/Borepin/PageModel/ScanPageModel.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using Borepin.Base;
|
||||
using Prism.Commands;
|
||||
using Prism.Navigation;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
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(async () => await ScannedCommandExecute().ConfigureAwait(true));
|
||||
|
||||
IsVisible = true;
|
||||
IsScanning = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Data
|
||||
public override async Task LoadData()
|
||||
{
|
||||
IsBusy = true;
|
||||
|
||||
IsBusy = false;
|
||||
}
|
||||
#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 async Task ScannedCommandExecute()
|
||||
{
|
||||
IsScanning = false;
|
||||
IsVisible = false;
|
||||
|
||||
INavigationParameters parameters = new NavigationParameters()
|
||||
{
|
||||
{ "result", "scanned" },
|
||||
{ "value", ScanResult.Text },
|
||||
{ "instance", _Instance }
|
||||
};
|
||||
|
||||
await _NavigationService.NavigateAsync("..", 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.NavigateAsync("..", parameters).ConfigureAwait(false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region INavigationService
|
||||
public override void OnNavigatedFrom(INavigationParameters parameters)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override async void OnNavigatedTo(INavigationParameters parameters)
|
||||
{
|
||||
_Instance = parameters.GetValue<object>("instance");
|
||||
await LoadData().ConfigureAwait(false);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
using Borepin.Base;
|
||||
using Prism.Commands;
|
||||
using Prism.Navigation;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Borepin.PageModel.SetUpProcess
|
||||
{
|
||||
public class ScanPageModel : PageModelBase
|
||||
{
|
||||
#region Constructors
|
||||
public ScanPageModel(INavigationService navigationService) : base(navigationService)
|
||||
{
|
||||
NextCommand = new DelegateCommand<object>(NextCommandCommandExecute);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Data
|
||||
public override Task LoadData()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
private ICommand _NextCommand;
|
||||
public ICommand NextCommand
|
||||
{
|
||||
get => _NextCommand;
|
||||
set => SetProperty(ref _NextCommand, value);
|
||||
}
|
||||
public async void NextCommandCommandExecute(object obj)
|
||||
{
|
||||
await _NavigationService.NavigateAsync("AddServerProcess_HostSelectPage").ConfigureAwait(false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region INavigationAware
|
||||
public override void OnNavigatedFrom(INavigationParameters parameters)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnNavigatedTo(INavigationParameters parameters)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user