mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-13 15:21:45 +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.Page.AddServerProcess;
|
||||||
using Borepin.PageModel.AddServerProcess;
|
using Borepin.PageModel.AddServerProcess;
|
||||||
using System;
|
using System;
|
||||||
|
using Prism.Navigation;
|
||||||
|
|
||||||
namespace Borepin
|
namespace Borepin
|
||||||
{
|
{
|
||||||
@ -25,6 +26,11 @@ namespace Borepin
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
INavigationParameters parameters = new NavigationParameters()
|
||||||
|
{
|
||||||
|
{ "instance", 0 },
|
||||||
|
};
|
||||||
|
|
||||||
await NavigationService.NavigateAsync(new Uri("https://borepin.fab-access.org/StartPage")).ConfigureAwait(false);
|
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<MachineListPage, MachineListPageModel>();
|
||||||
containerRegistry.RegisterForNavigation<ServerListPage, ServerListPageModel>();
|
containerRegistry.RegisterForNavigation<ServerListPage, ServerListPageModel>();
|
||||||
containerRegistry.RegisterForNavigation<ServerPage, ServerPageModel>();
|
containerRegistry.RegisterForNavigation<ServerPage, ServerPageModel>();
|
||||||
containerRegistry.RegisterForNavigation<ScannerPage>();
|
containerRegistry.RegisterForNavigation<ScanPage, ScanPageModel>();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Register Sequence Navigation
|
#region Register Sequence Navigation
|
||||||
containerRegistry.RegisterForNavigation<WelcomePage, WelcomePageModel>("SetUpProcess_WelcomePage");
|
containerRegistry.RegisterForNavigation<WelcomePage, WelcomePageModel>("SetUpProcess_WelcomePage");
|
||||||
//containerRegistry.RegisterForNavigation<ScanPage, ScanPageModel>("SetUpProcess_ScanPage");
|
|
||||||
|
|
||||||
containerRegistry.RegisterForNavigation<AuthPlainPage, AuthPlainPageModel>("AddServerProcess_AuthPlainPage");
|
containerRegistry.RegisterForNavigation<AuthPlainPage, AuthPlainPageModel>("AddServerProcess_AuthPlainPage");
|
||||||
containerRegistry.RegisterForNavigation<SelectServerPage, SelectServerPageModel>("AddServerProcess_SelectServerPage");
|
containerRegistry.RegisterForNavigation<SelectServerPage, SelectServerPageModel>("AddServerProcess_SelectServerPage");
|
||||||
|
@ -101,7 +101,7 @@
|
|||||||
<EmbeddedResource Update="Page\MainPage.xaml">
|
<EmbeddedResource Update="Page\MainPage.xaml">
|
||||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Update="Page\ScannerPage.xaml">
|
<EmbeddedResource Update="Page\ScanPage.xaml">
|
||||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Update="Page\ServerListPage.xaml">
|
<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;
|
_DialogService = dialogService;
|
||||||
|
|
||||||
SelectInstanceCommand = new DelegateCommand<object>(SelectInstanceCommandExecute);
|
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));
|
RefreshCommand = new DelegateCommand(async ()=> await RefreshCommandExecute().ConfigureAwait(true));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -138,16 +138,19 @@ namespace Borepin.PageModel
|
|||||||
get => _ScanCodeCommand;
|
get => _ScanCodeCommand;
|
||||||
set => SetProperty(ref _ScanCodeCommand, value);
|
set => SetProperty(ref _ScanCodeCommand, value);
|
||||||
}
|
}
|
||||||
public void ScanCodeCommandExecute()
|
public async Task ScanCodeCommandExecute()
|
||||||
{
|
{
|
||||||
IsBusy = true;
|
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)
|
||||||
{
|
{
|
||||||
@ -159,7 +162,7 @@ namespace Borepin.PageModel
|
|||||||
IMachineSystem machineInterface = (await _BFFHService.GetSession().ConfigureAwait(false)).MachineSystem;
|
IMachineSystem machineInterface = (await _BFFHService.GetSession().ConfigureAwait(false)).MachineSystem;
|
||||||
MachineSystem.IInfoInterface infoInterface = await machineInterface.Info().ConfigureAwait(false);
|
MachineSystem.IInfoInterface infoInterface = await machineInterface.Info().ConfigureAwait(false);
|
||||||
|
|
||||||
Machine machine = await infoInterface.GetMachineURN(result.Parameters.GetValue<string>("value")).ConfigureAwait(false);
|
Machine machine = await infoInterface.GetMachineURN(value).ConfigureAwait(false);
|
||||||
|
|
||||||
if(machine == null)
|
if(machine == null)
|
||||||
{
|
{
|
||||||
@ -170,7 +173,6 @@ namespace Borepin.PageModel
|
|||||||
_NextMachine = machine;
|
_NextMachine = machine;
|
||||||
IsBusy = false;
|
IsBusy = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IPageLifecycleAware
|
#region IPageLifecycleAware
|
||||||
@ -204,6 +206,16 @@ namespace Borepin.PageModel
|
|||||||
public override async void OnNavigatedTo(INavigationParameters parameters)
|
public override async void OnNavigatedTo(INavigationParameters parameters)
|
||||||
{
|
{
|
||||||
IsBusy = true;
|
IsBusy = true;
|
||||||
|
|
||||||
|
if (parameters["result"] != null)
|
||||||
|
{
|
||||||
|
if (parameters["result"].Equals("scanned"))
|
||||||
|
{
|
||||||
|
string urn = (string)parameters["value"];
|
||||||
|
ScanCode_Result(urn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await LoadData().ConfigureAwait(false);
|
await LoadData().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
#endregion
|
#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