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 System;
using Borepin.Service.Storage; using Borepin.Service.Storage;
using NLog; using NLog;
using System.Resources;
namespace Borepin namespace Borepin
{ {
@ -46,8 +45,8 @@ 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<ScanPage, ScanPageModel>("ScanPage"); containerRegistry.RegisterForNavigation<ScanPage, ScanPageModel>();
containerRegistry.RegisterForNavigation<ScanPage, ScanURNPageModel>("ScanURNPage"); containerRegistry.RegisterForNavigation<ScanURNPage, ScanURNPageModel>();
#endregion #endregion
#region Register Sequence Navigation #region Register Sequence Navigation

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@
<ContentPage.Content> <ContentPage.Content>
<StackLayout IsVisible="{Binding IsVisible}"> <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}"/> <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> </StackLayout>
</ContentPage.Content> </ContentPage.Content>
</ContentPage> </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; 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() public override Task<object> CreateInstance()
{ {
return Task.FromResult<object>(_ConnectionData); return Task.FromResult<object>(_ConnectionData);
@ -135,7 +145,14 @@ namespace Borepin.PageModel.AddServerProcess
} }
public void ScanCodeCommandExecute() 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; private ICommand _DetectLocalServerCommand;

View File

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

View File

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

View File

@ -1,7 +1,6 @@
using Borepin.ViewModel; using Borepin.ViewModel;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Linq;
using System.Windows.Input; using System.Windows.Input;
using Prism.Commands; using Prism.Commands;
using Prism.Navigation; using Prism.Navigation;
@ -49,13 +48,15 @@ namespace Borepin.PageModel
HasActiveConnection = false; HasActiveConnection = false;
} }
ServerListItemViewModel_List = new List<ServerListItemViewModel>(); List<ServerListItemViewModel> serverListItemViewModel_List = new List<ServerListItemViewModel>();
foreach (ConnectionData connectionData in list) foreach (ConnectionData connectionData in list)
{ {
ServerListItemViewModel serverListItemViewModel = new ServerListItemViewModel(_NavigationService, _PageDialogService); ServerListItemViewModel serverListItemViewModel = new ServerListItemViewModel(_NavigationService, _PageDialogService);
await serverListItemViewModel.LoadInstance(connectionData).ConfigureAwait(false); await serverListItemViewModel.LoadInstance(connectionData).ConfigureAwait(false);
ServerListItemViewModel_List.Add(serverListItemViewModel); serverListItemViewModel_List.Add(serverListItemViewModel);
} }
ServerListItemViewModel_List = serverListItemViewModel_List;
IsBusy = false; 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> /// <summary>
/// Looks up a localized string similar to Login. /// Looks up a localized string similar to Login.
/// </summary> /// </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> /// <summary>
/// Looks up a localized string similar to Delete. /// Looks up a localized string similar to Delete.
/// </summary> /// </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> /// <summary>
/// Looks up a localized string similar to Current User:. /// Looks up a localized string similar to Current User:.
/// </summary> /// </summary>

View File

@ -117,9 +117,6 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="ABORT" xml:space="preserve">
<value>Abort</value>
</data>
<data name="AddServerProcess_AuthPlainPage_Login" xml:space="preserve"> <data name="AddServerProcess_AuthPlainPage_Login" xml:space="preserve">
<value>Login</value> <value>Login</value>
</data> </data>
@ -145,12 +142,19 @@
<value>PLACEHOLDER</value> <value>PLACEHOLDER</value>
<comment>Server Struktur erklären, auf QR-Code hinweisen, ansonsten im Space fragen</comment> <comment>Server Struktur erklären, auf QR-Code hinweisen, ansonsten im Space fragen</comment>
</data> </data>
<data name="CANCEL" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="DELETE" xml:space="preserve"> <data name="DELETE" xml:space="preserve">
<value>Delete</value> <value>Delete</value>
</data> </data>
<data name="HOST" xml:space="preserve"> <data name="HOST" xml:space="preserve">
<value>Host</value> <value>Host</value>
</data> </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"> <data name="MachinePage_CurrentUser" xml:space="preserve">
<value>Current User:</value> <value>Current User:</value>
</data> </data>