Fixed QR-Code AddServer

This commit is contained in:
TheJoKlLa 2022-06-02 20:45:18 +02:00
parent 8b818d5873
commit 7693316701
15 changed files with 123 additions and 44 deletions

View File

@ -12,7 +12,6 @@ using Borepin.PageModel.AddServerProcess;
using System;
using Borepin.Service.Storage;
using NLog;
using System.Resources;
namespace Borepin
{
@ -46,8 +45,8 @@ namespace Borepin
containerRegistry.RegisterForNavigation<MachineListPage, MachineListPageModel>();
containerRegistry.RegisterForNavigation<ServerListPage, ServerListPageModel>();
containerRegistry.RegisterForNavigation<ServerPage, ServerPageModel>();
containerRegistry.RegisterForNavigation<ScanPage, ScanPageModel>("ScanPage");
containerRegistry.RegisterForNavigation<ScanPage, ScanURNPageModel>("ScanURNPage");
containerRegistry.RegisterForNavigation<ScanPage, ScanPageModel>();
containerRegistry.RegisterForNavigation<ScanURNPage, ScanURNPageModel>();
#endregion
#region Register Sequence Navigation

View File

@ -44,10 +44,16 @@ namespace Borepin.Base
return Task.CompletedTask;
}
public virtual Task LoadFromParameters(INavigationParameters parameters)
{
return Task.CompletedTask;
}
public virtual Task<object> CreateInstance()
{
return Task.FromResult<object>(null);
}
#endregion
#region INavigationAware
@ -72,6 +78,8 @@ namespace Borepin.Base
Log.Trace("No instance");
await LoadInstance(null).ConfigureAwait(false);
}
await LoadFromParameters(parameters).ConfigureAwait(false);
}
public virtual async Task OnNavigatedFromVirtual(INavigationParameters parameters)
{

View File

@ -50,6 +50,9 @@
<Compile Update="Page\AddServerProcess\SelectServerPage.xaml.cs">
<DependentUpon>SelectServerPage.xaml</DependentUpon>
</Compile>
<Compile Update="Page\ScanURNPage.xaml.cs">
<DependentUpon>ScanURNPage.xaml</DependentUpon>
</Compile>
<Compile Update="Page\UserPage.xaml.cs">
<DependentUpon>UserPage.xaml</DependentUpon>
</Compile>
@ -71,11 +74,6 @@
<Compile Update="Page\StartPage.xaml.cs">
<DependentUpon>StartPage.xaml</DependentUpon>
</Compile>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Update="Resources\Text\TextResource.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
@ -131,10 +129,6 @@
<EmbeddedResource Update="Page\StartPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Resources\Text\TextResource.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>TextResource.Designer.cs</LastGenOutput>
@ -155,4 +149,7 @@
<ItemGroup>
<ProjectReference Include="..\..\FabAccessAPI\FabAccessAPI.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>

View File

@ -73,6 +73,7 @@ namespace Borepin.Model
CanCheck = !((CheckInterface_Proxy)_Machine.Check).IsNull;
CanManage = !((ManageInterface_Proxy)_Machine.Manage).IsNull;
CanAdmin = !((AdminInterface_Proxy)_Machine.Admin).IsNull;
CanNotUseByPermission = State == MachineState.free && CanUse == false;
}
#endregion
@ -174,6 +175,13 @@ namespace Borepin.Model
get => _CanAdmin;
set => SetProperty(ref _CanAdmin, value);
}
private bool _CanNotUseByPermission;
public bool CanNotUseByPermission
{
get => _CanNotUseByPermission;
set => SetProperty(ref _CanNotUseByPermission, value);
}
#endregion
}
}

View File

@ -22,8 +22,8 @@
<Button Text="{x:Static resource_text:TextResource.SCANQR}" Command="{Binding ScanCodeCommand}" Style="{StaticResource Style_Button_Primary}">
<Button.IsVisible>
<OnPlatform x:TypeArguments="x:Boolean"
iOS="false"
Android="true"/>
iOS="true"
Android="true"/>
</Button.IsVisible>
</Button>
<Label Text="{x:Static resource_text:TextResource.AddServerProcess_SelectServerPage_Info}"></Label>

View File

@ -28,6 +28,9 @@
<StackLayout IsVisible="{Binding MachineItem.CanUse}">
<Button Text="{x:Static resource_text:TextResource.MachinePage_Use}" Command="{Binding UseMachineCommand}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout>
<StackLayout IsVisible="{Binding MachineItem.CanNotUseByPermission}">
<Label Text="{x:Static resource_text:TextResource.MachinePage_CanNotUseByPermission}" Style="{StaticResource Style_Label_Text_Center}"/>
</StackLayout>
<StackLayout IsVisible="{Binding MachineItem.CanInUse}">
<Button Text="{x:Static resource_text:TextResource.MachinePage_GiveBack}" Command="{Binding GiveBackMachineCommand}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout>

View File

@ -7,7 +7,7 @@
<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" Options="{Binding ScanOptions}"/>
<Button Text="{x:Static resource_text:TextResource.ABORT}" Command="{Binding AbortCommand}"/>
<Button Text="{x:Static resource_text:TextResource.CANCEL}" Command="{Binding CancelCommand}"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@ -0,0 +1,13 @@
<?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"
xmlns:resource_text="clr-namespace:Borepin.Resources.Text"
x:Class="Borepin.Page.ScanURNPage">
<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" Options="{Binding ScanOptions}"/>
<Button Text="{x:Static resource_text:TextResource.CANCEL}" Command="{Binding CancelCommand}"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View 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 ScanURNPage : ContentPage
{
public ScanURNPage()
{
InitializeComponent();
}
}
}

View File

@ -39,6 +39,16 @@ namespace Borepin.PageModel.AddServerProcess
return Task.CompletedTask;
}
public override Task LoadFromParameters(INavigationParameters parameters)
{
if(parameters.ContainsKey("result") && string.Equals((string)parameters["result"], "scanned", StringComparison.Ordinal) && parameters.ContainsKey("value"))
{
Host = (string)parameters["value"];
}
return Task.CompletedTask;
}
public override Task<object> CreateInstance()
{
return Task.FromResult<object>(_ConnectionData);
@ -135,7 +145,14 @@ namespace Borepin.PageModel.AddServerProcess
}
public void ScanCodeCommandExecute()
{
Device.BeginInvokeOnMainThread(async () =>
{
INavigationResult result = await _NavigationService.NavigateAsync("ScanPage").ConfigureAwait(false);
if (result.Exception != null)
{
Log.Fatal(result.Exception, "Navigating failed");
}
});
}
private ICommand _DetectLocalServerCommand;

View File

@ -18,7 +18,7 @@ namespace Borepin.PageModel
#region Contructors
public ScanPageModel(INavigationService navigationService, IPageDialogService pageDialogService) : base(navigationService, pageDialogService)
{
AbortCommand = new DelegateCommand(async () => await AbortCommandExecute().ConfigureAwait(true));
CancelCommand = new DelegateCommand(async () => await CancelCommandExecute().ConfigureAwait(true));
ScannedCommand = new DelegateCommand(ScannedCommandExecute);
IsVisible = true;
@ -87,20 +87,20 @@ namespace Borepin.PageModel
});
}
private ICommand _AbortCommand;
public ICommand AbortCommand
private ICommand _CancelCommand;
public ICommand CancelCommand
{
get => _AbortCommand;
set => SetProperty(ref _AbortCommand, value);
get => _CancelCommand;
set => SetProperty(ref _CancelCommand, value);
}
public async Task AbortCommandExecute()
public async Task CancelCommandExecute()
{
IsScanning = false;
IsVisible = false;
INavigationParameters parameters = new NavigationParameters()
{
{ "result", "abort" },
{ "result", "canceled" },
};
await _NavigationService.GoBackAsync(parameters).ConfigureAwait(false);
}

View File

@ -18,7 +18,7 @@ namespace Borepin.PageModel
#region Contructors
public ScanURNPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService) : base(navigationService, pageDialogService, apiService)
{
AbortCommand = new DelegateCommand(async () => await AbortCommandExecute().ConfigureAwait(true));
CancelCommand = new DelegateCommand(async () => await CancelCommandExecute().ConfigureAwait(true));
ScannedCommand = new DelegateCommand(async () => await ScannedCommandExecuteAsync().ConfigureAwait(false));
IsVisible = true;
@ -137,13 +137,13 @@ namespace Borepin.PageModel
}
}
private ICommand _AbortCommand;
public ICommand AbortCommand
private ICommand _CancelCommand;
public ICommand CancelCommand
{
get => _AbortCommand;
set => SetProperty(ref _AbortCommand, value);
get => _CancelCommand;
set => SetProperty(ref _CancelCommand, value);
}
public async Task AbortCommandExecute()
public async Task CancelCommandExecute()
{
IsScanning = false;
IsVisible = false;

View File

@ -1,7 +1,6 @@
using Borepin.ViewModel;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using System.Windows.Input;
using Prism.Commands;
using Prism.Navigation;
@ -49,13 +48,15 @@ namespace Borepin.PageModel
HasActiveConnection = false;
}
ServerListItemViewModel_List = new List<ServerListItemViewModel>();
List<ServerListItemViewModel> serverListItemViewModel_List = new List<ServerListItemViewModel>();
foreach (ConnectionData connectionData in list)
{
ServerListItemViewModel serverListItemViewModel = new ServerListItemViewModel(_NavigationService, _PageDialogService);
await serverListItemViewModel.LoadInstance(connectionData).ConfigureAwait(false);
ServerListItemViewModel_List.Add(serverListItemViewModel);
serverListItemViewModel_List.Add(serverListItemViewModel);
}
ServerListItemViewModel_List = serverListItemViewModel_List;
IsBusy = false;
}

View File

@ -60,15 +60,6 @@ namespace Borepin.Resources.Text {
}
}
/// <summary>
/// Looks up a localized string similar to Abort.
/// </summary>
internal static string ABORT {
get {
return ResourceManager.GetString("ABORT", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Login.
/// </summary>
@ -141,6 +132,15 @@ namespace Borepin.Resources.Text {
}
}
/// <summary>
/// Looks up a localized string similar to Cancel.
/// </summary>
internal static string CANCEL {
get {
return ResourceManager.GetString("CANCEL", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Delete.
/// </summary>
@ -159,6 +159,15 @@ namespace Borepin.Resources.Text {
}
}
/// <summary>
/// Looks up a localized string similar to PLACEHOLDER.
/// </summary>
internal static string MachinePage_CanNotUseByPermission {
get {
return ResourceManager.GetString("MachinePage_CanNotUseByPermission", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Current User:.
/// </summary>

View File

@ -117,9 +117,6 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ABORT" xml:space="preserve">
<value>Abort</value>
</data>
<data name="AddServerProcess_AuthPlainPage_Login" xml:space="preserve">
<value>Login</value>
</data>
@ -145,12 +142,19 @@
<value>PLACEHOLDER</value>
<comment>Server Struktur erklären, auf QR-Code hinweisen, ansonsten im Space fragen</comment>
</data>
<data name="CANCEL" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="DELETE" xml:space="preserve">
<value>Delete</value>
</data>
<data name="HOST" xml:space="preserve">
<value>Host</value>
</data>
<data name="MachinePage_CanNotUseByPermission" xml:space="preserve">
<value>PLACEHOLDER</value>
<comment>Nutzer darf die Maschine nicht nutzten, dass sollte erklärt werden, also beim Admin nachfragen</comment>
</data>
<data name="MachinePage_CurrentUser" xml:space="preserve">
<value>Current User:</value>
</data>