d9976ff520
Methoden zum Bot User registrieren und einloggen hinzugefügt aber auskommentiert, weil dies nur zu Debug bzw. Test gründen benutzt wurde
179 lines
5.5 KiB
C#
179 lines
5.5 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Navigation;
|
|
using bib_talk.Business;
|
|
|
|
namespace bib_talk
|
|
{
|
|
public partial class RegisterWindow : Window
|
|
{
|
|
RegisterManager registerManager;
|
|
|
|
public RegisterWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
registerManager = new RegisterManager(this);
|
|
}
|
|
|
|
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
|
|
{
|
|
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri) { UseShellExecute = true });
|
|
e.Handled = true;
|
|
}
|
|
|
|
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void DraggableArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (e.ButtonState == MouseButtonState.Pressed)
|
|
{
|
|
DragMove();
|
|
}
|
|
}
|
|
|
|
private void Login_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Login login = new Login();
|
|
login.Show();
|
|
this.Close();
|
|
}
|
|
|
|
private async void WeiterButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (checkboxAGB.IsChecked == true)
|
|
{
|
|
if (ValidateRegistration())
|
|
{
|
|
// Business Schicht Aufruf
|
|
registerManager.RegisterServer();
|
|
|
|
Login login = new Login();
|
|
login.Show();
|
|
this.Close();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Bitte akzeptieren Sie die AGB.");
|
|
}
|
|
}
|
|
|
|
private void CheckBox_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
SolidColorBrush customBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF6332A0"));
|
|
weiterbutton.Foreground = Brushes.White;
|
|
weiterbutton.Background = customBrush;
|
|
}
|
|
|
|
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
|
|
{
|
|
SolidColorBrush customBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF323134"));
|
|
weiterbutton.Foreground = Brushes.Gray;
|
|
weiterbutton.Background = customBrush;
|
|
}
|
|
|
|
private bool ValidateRegistration()
|
|
{
|
|
string username = usernbox.Text;
|
|
string password = passwordbox.Password;
|
|
string email = emailbox.Text;
|
|
string day = bday1.Text;
|
|
string month = bday2.Text;
|
|
string year = bday3.Text;
|
|
|
|
// Benutzername validieren
|
|
if (string.IsNullOrWhiteSpace(username) || username.Length < 3)
|
|
{
|
|
MessageBox.Show("Der Benutzername muss mindestens 3 Zeichen lang sein.");
|
|
return false;
|
|
}
|
|
|
|
// Passwort validieren
|
|
if (string.IsNullOrWhiteSpace(password) || password.Length < 6 || !Regex.IsMatch(password, @"^(?=.*[A-Za-z])(?=.*\d).{6,}$"))
|
|
{
|
|
MessageBox.Show("Das Passwort muss mindestens 6 Zeichen lang sein und sowohl Buchstaben als auch Zahlen enthalten.");
|
|
return false;
|
|
}
|
|
|
|
// E-Mail validieren
|
|
if (string.IsNullOrWhiteSpace(email) || !Regex.IsMatch(email, @"^[^@\s]+@[^@\s]+\.[^@\s]+$"))
|
|
{
|
|
MessageBox.Show("Bitte geben Sie eine gültige E-Mail-Adresse ein.");
|
|
return false;
|
|
}
|
|
|
|
// Geburtsdatum validieren
|
|
if (!int.TryParse(day, out int dayInt) || !int.TryParse(month, out int monthInt) || !int.TryParse(year, out int yearInt) ||
|
|
!DateTime.TryParse($"{yearInt}-{monthInt}-{dayInt}", out DateTime birthDate) || birthDate > DateTime.Now.AddYears(-14))
|
|
{
|
|
MessageBox.Show("Bitte geben Sie ein gültiges Geburtsdatum ein. Sie müssen mindestens 18 Jahre alt sein.");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
private void emailbox_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.Key == Key.Enter)
|
|
{
|
|
usernbox.Focus();
|
|
}
|
|
}
|
|
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)
|
|
{
|
|
bday1.Focus();
|
|
}
|
|
}
|
|
private void bday1_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.Key == Key.Enter)
|
|
{
|
|
bday2.Focus();
|
|
}
|
|
}
|
|
|
|
private void bday2_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.Key == Key.Enter)
|
|
{
|
|
bday3.Focus();
|
|
}
|
|
}
|
|
|
|
|
|
// Benutzt um 100 User accounts zu erstellen
|
|
//private void RegisterNewBots(object sender, RoutedEventArgs e)
|
|
//{
|
|
// for (int i = 10; i <= 100; i++)
|
|
// {
|
|
// string name = "Bot";
|
|
// string password = "Bot123";
|
|
// string email = "bot@edu.bib.de";
|
|
// string birthday = "12.12.2000";
|
|
// registerManager.RegisterBots(name + i, password, i + email, birthday);
|
|
// Thread.Sleep(1000);
|
|
// }
|
|
//}
|
|
}
|
|
}
|