bib_Talk_Chatprogramm/bibtalk/bib-talk/UI/Login.xaml.cs
BlackViron ce490cf68f Enter Fuktion
Anmelden etc kann man jetzt mit enter bedienen
2024-08-22 12:19:00 +02:00

93 lines
2.6 KiB
C#

using System.Windows.Input;
using System.Windows.Media;
using System.Windows;
using bib_talk.Business;
using System.Windows.Controls;
namespace bib_talk
{
public partial class Login : Window
{
LoginManager loginManager;
// Field to store logged in user
public static string loggedInUser;
public Login()
{
InitializeComponent();
loginManager = new LoginManager(this);
}
private void DraggableArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.ButtonState == MouseButtonState.Pressed)
{
DragMove();
}
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
RegisterWindow register = new RegisterWindow();
register.Show();
this.Close();
}
private async void WeiterButton_Click(object sender, RoutedEventArgs e)
{
if (usernbox.Text != "" && passwordbox.Password != "")
{
loginManager.Login();
}
}
private void passwordbox_PasswordChanged(object sender, RoutedEventArgs e)
{
if (usernbox.Text != "" && passwordbox.Password != "")
{
SolidColorBrush customBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF6332A0"));
weiterbutton.Foreground = Brushes.White;
weiterbutton.Background = customBrush;
}
else
{
SolidColorBrush customBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF323134"));
weiterbutton.Foreground = Brushes.Gray;
weiterbutton.Background = customBrush;
}
}
private void Register_Click(object sender, RoutedEventArgs e)
{
RegisterWindow register = new RegisterWindow();
register.Show();
this.Close();
}
private void usernbox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
passwordbox.Focus();
}
}
private void passwordbox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
if (usernbox.Text != "" && passwordbox.Password != "")
{
loginManager.Login();
}
}
}
}
}