Added ENI style login screen
This commit is contained in:
parent
5ca3c7a050
commit
504131c239
@ -5,5 +5,12 @@
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<ResourceDictionary Source="Resources\StringResources.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
|
||||
@ -7,4 +7,37 @@
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Remove="Resources\StringResources.xaml" />
|
||||
<Page Remove="StringResources.de.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\misc\BreCalApi.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>BreCalApi.yaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\..\misc\BreCalApi.yaml" Link="BreCalApi.yaml">
|
||||
<Generator>OpenApiCodeGenerator</Generator>
|
||||
<LastGenOutput>BreCalApi.cs</LastGenOutput>
|
||||
</None>
|
||||
<Resource Include="Resources\StringResources.de.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Resource>
|
||||
<Resource Include="Resources\StringResources.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.0" />
|
||||
<PackageReference Include="JsonSubTypes" Version="2.0.1" />
|
||||
<PackageReference Include="log4net" Version="2.0.15" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Polly" Version="7.2.3" />
|
||||
<PackageReference Include="RestSharp" Version="108.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -4,9 +4,41 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:BreCalClient"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<Grid>
|
||||
Title="{DynamicResource textApplicationTitle}" Height="450" Width="800" Loaded="Window_Loaded">
|
||||
|
||||
</Grid>
|
||||
<xctk:BusyIndicator Name="busyIndicator" IsBusy="True">
|
||||
<xctk:BusyIndicator.ProgressBarStyle>
|
||||
<Style TargetType="ProgressBar">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
</Style>
|
||||
</xctk:BusyIndicator.ProgressBarStyle>
|
||||
<xctk:BusyIndicator.BusyContent>
|
||||
<Grid Width="320">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="28" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="{DynamicResource textLoginCaption}" Grid.Row="0" Grid.ColumnSpan="2" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
|
||||
<Label Content="{DynamicResource textUsername}" Grid.Row="1" VerticalContentAlignment="Center" />
|
||||
<Label Content="{DynamicResource textPassword}" Grid.Row="2" VerticalContentAlignment="Center" />
|
||||
<TextBox Name="textUsername" Grid.Row="1" Grid.Column="1" Margin="2" VerticalContentAlignment="Center" />
|
||||
<PasswordBox Name="textPassword" Grid.Row="2" Grid.Column="1" Margin="2" VerticalContentAlignment="Center" PasswordChar="*"/>
|
||||
<Label Name="labelLoginResult" Grid.Row="3" Grid.ColumnSpan="2" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
|
||||
<Button Name="buttonLogin" Content="{DynamicResource textLogin}" Grid.Row="4" Grid.Column="0" Margin="2" Click="buttonLogin_Click" IsDefault="True" />
|
||||
<Button Name="buttonExit" Content="{DynamicResource textExit}" Grid.Row="4" Grid.Column="1" Margin="2" Click="buttonExit_Click" />
|
||||
</Grid>
|
||||
</xctk:BusyIndicator.BusyContent>
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</xctk:BusyIndicator>
|
||||
</Window>
|
||||
|
||||
@ -13,6 +13,10 @@ using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
using BreCalClient.misc.Api;
|
||||
using BreCalClient.misc.Client;
|
||||
using BreCalClient.misc.Model;
|
||||
|
||||
namespace BreCalClient
|
||||
{
|
||||
/// <summary>
|
||||
@ -20,9 +24,53 @@ namespace BreCalClient
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
DefaultApi _api;
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
_api = new DefaultApi();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private async void buttonLogin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.textPassword.Password) || string.IsNullOrEmpty(this.textUsername.Text))
|
||||
{
|
||||
this.labelLoginResult.Content = Application.Current.FindResource("textUserNamePasswordEmpty").ToString();
|
||||
return;
|
||||
}
|
||||
|
||||
Credentials credentials = new(username: textUsername.Text.Trim(),
|
||||
password: textPassword.Password.Trim());
|
||||
|
||||
try
|
||||
{
|
||||
LoginResult loginResult = await _api.LoginPostAsync(credentials);
|
||||
if(loginResult != null)
|
||||
{
|
||||
if(loginResult.Id > 0)
|
||||
{
|
||||
this.busyIndicator.IsBusy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ApiException ex)
|
||||
{
|
||||
this.labelLoginResult.Content = ex.Message;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonExit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
src/BreCalClient/Resources/StringResources.de.xaml
Normal file
10
src/BreCalClient/Resources/StringResources.de.xaml
Normal file
@ -0,0 +1,10 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<system:String x:Key="textLoginCaption">Benutzer Anmeldung</system:String>
|
||||
<system:String x:Key="textUsername">Benutzername</system:String>
|
||||
<system:String x:Key="textPassword">Passwort</system:String>
|
||||
<system:String x:Key="textLogin">Anmelden</system:String>
|
||||
<system:String x:Key="textExit">Abbrechen</system:String>
|
||||
<system:String x:Key="textUserNamePasswordEmpty">Benutzername / Password leer!</system:String>
|
||||
</ResourceDictionary>
|
||||
11
src/BreCalClient/Resources/StringResources.xaml
Normal file
11
src/BreCalClient/Resources/StringResources.xaml
Normal file
@ -0,0 +1,11 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<system:String x:Key="textLoginCaption">User login</system:String>
|
||||
<system:String x:Key="textUsername">Username</system:String>
|
||||
<system:String x:Key="textPassword">Password</system:String>
|
||||
<system:String x:Key="textLogin">Login</system:String>
|
||||
<system:String x:Key="textExit">Exit</system:String>
|
||||
<system:String x:Key="textApplicationTitle">Bremen calling</system:String>
|
||||
<system:String x:Key="textUserNamePasswordEmpty">Username and/or password empty!</system:String>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user