2024-07-01 16:21:03 +02:00
|
|
|
|
using bib_talk.Repository;
|
|
|
|
|
using Newtonsoft.Json;
|
2024-06-10 15:57:04 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2024-06-18 08:01:04 +02:00
|
|
|
|
using System.Diagnostics;
|
2024-06-10 15:57:04 +02:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Text;
|
2024-06-10 16:45:07 +02:00
|
|
|
|
using System.Text.RegularExpressions;
|
2024-06-10 15:57:04 +02:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
using System.Windows.Navigation;
|
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
|
|
|
|
|
namespace bib_talk
|
|
|
|
|
{
|
|
|
|
|
public partial class RegisterWindow : Window
|
|
|
|
|
{
|
|
|
|
|
public RegisterWindow()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-18 08:01:04 +02:00
|
|
|
|
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)
|
2024-06-10 15:57:04 +02:00
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DraggableArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.ButtonState == MouseButtonState.Pressed)
|
|
|
|
|
{
|
|
|
|
|
DragMove();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-06-10 16:45:07 +02:00
|
|
|
|
|
2024-06-10 15:57:04 +02:00
|
|
|
|
private void Login_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2024-06-10 16:45:07 +02:00
|
|
|
|
Login login = new Login();
|
2024-06-10 15:57:04 +02:00
|
|
|
|
login.Show();
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 16:21:03 +02:00
|
|
|
|
private async void WeiterButton_Click(object sender, RoutedEventArgs e)
|
2024-06-10 15:57:04 +02:00
|
|
|
|
{
|
|
|
|
|
if (checkboxAGB.IsChecked == true)
|
|
|
|
|
{
|
2024-06-10 16:45:07 +02:00
|
|
|
|
if (ValidateRegistration())
|
|
|
|
|
{
|
2024-07-01 16:21:03 +02:00
|
|
|
|
RegisterDatabase registerDatabase = new RegisterDatabase(this);
|
|
|
|
|
|
|
|
|
|
await registerDatabase.RegisterServer();
|
2024-06-11 10:16:22 +02:00
|
|
|
|
Login login = new Login();
|
|
|
|
|
login.Show();
|
|
|
|
|
this.Close();
|
2024-06-10 16:45:07 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Bitte akzeptieren Sie die AGB.");
|
2024-06-10 15:57:04 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-06-10 16:45:07 +02:00
|
|
|
|
|
2024-06-10 15:57:04 +02:00
|
|
|
|
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;
|
2024-06-10 16:45:07 +02:00
|
|
|
|
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;
|
2024-06-10 15:57:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-06-18 08:01:04 +02:00
|
|
|
|
}
|
2024-06-10 15:57:04 +02:00
|
|
|
|
}
|