Tastaturnavigation auf der Login-Seite hinzugefügt
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
|
||||
Title="LogInPage">
|
||||
Title="LogInPage"
|
||||
KeyboardNavigation.DirectionalNavigation="Cycle"
|
||||
Loaded="Page_Loaded">
|
||||
|
||||
<Grid Margin="40,20">
|
||||
<Grid.RowDefinitions>
|
||||
@@ -32,14 +34,14 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Content="Email (Benutzername):" Grid.Row="0" FontWeight="SemiBold"/>
|
||||
<TextBox x:Name="BenutzernameTextBox" Grid.Row="1" Height="45" FontSize="14"/>
|
||||
<TextBox x:Name="BenutzernameTextBox" Grid.Row="1" Height="45" FontSize="14" VerticalContentAlignment="Center" TabIndex="0" PreviewKeyDown="BenutzernameTextBox_PreviewKeyDown"/>
|
||||
|
||||
<Label Content="Passwort:" Grid.Row="3" FontWeight="SemiBold"/>
|
||||
<PasswordBox x:Name="PasswortTextBox" Grid.Row="4" Height="45" FontSize="14"/>
|
||||
<PasswordBox x:Name="PasswortTextBox" Grid.Row="4" Height="45" FontSize="14" VerticalContentAlignment="Center" TabIndex="1"/>
|
||||
|
||||
<StackPanel Grid.Row="6" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,20,0,0">
|
||||
<Button Content="Login" Width="140" Height="48" Margin="0,0,20,0" Background="#FF1E88E5" Foreground="White" FontWeight="Bold" Click="LogInButton_Click"/>
|
||||
<Button Content="Registrieren" Width="140" Height="48" Background="Transparent" BorderBrush="#DDD" Foreground="#666" Click="anmeldungsButton_Click"/>
|
||||
<Button Content="Login" Width="140" Height="48" Margin="0,0,20,0" Background="#FF1E88E5" Foreground="White" FontWeight="Bold" Click="LogInButton_Click" TabIndex="2" IsDefault="True"/>
|
||||
<Button Content="Registrieren" Width="140" Height="48" Background="Transparent" BorderBrush="#DDD" Foreground="#666" Click="anmeldungsButton_Click" TabIndex="3"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Row="7" HorizontalAlignment="Center" Margin="0,20,0,0">
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using BCrypt.Net;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using MySql.Data.MySqlClient;
|
||||
using BCrypt.Net;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace SkyTeam
|
||||
{
|
||||
@@ -34,9 +35,9 @@ namespace SkyTeam
|
||||
}
|
||||
|
||||
string query = @"
|
||||
SELECT Id, Vorname, Rolle, PasswortHash
|
||||
FROM users
|
||||
WHERE Email = @email";
|
||||
SELECT Id, Vorname, Rolle, PasswortHash
|
||||
FROM users
|
||||
WHERE Email = @email";
|
||||
|
||||
try
|
||||
{
|
||||
@@ -64,14 +65,12 @@ namespace SkyTeam
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SessionManager.CurrentUserId = reader.GetInt32("Id");
|
||||
SessionManager.CurrentUserName = reader.GetString("Vorname");
|
||||
SessionManager.Role = reader.GetString("Rolle");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
((MainWindow)Application.Current.MainWindow)
|
||||
.MainFrame.Navigate(new NavigationPage());
|
||||
}
|
||||
@@ -82,12 +81,27 @@ namespace SkyTeam
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void anmeldungsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow)
|
||||
.MainFrame.Navigate(new RegistrationPage());
|
||||
}
|
||||
|
||||
private void Page_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
BenutzernameTextBox.Focus();
|
||||
}
|
||||
|
||||
private void BenutzernameTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Down || e.Key == Key.Enter)
|
||||
{
|
||||
TraversalRequest request =
|
||||
new TraversalRequest(FocusNavigationDirection.Next);
|
||||
|
||||
(sender as UIElement).MoveFocus(request);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user