bib-talk 23.05 v1

karlomalo
This commit is contained in:
DaddyPig
2024-06-10 15:57:04 +02:00
parent e7599c4dde
commit 892d19a91f
14 changed files with 1339 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
<Application x:Class="bib_talk.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:bib_talk"
StartupUri="Login.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace bib_talk
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

View File

@@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

130
bibtalk/bib-talk/Login.xaml Normal file
View File

@@ -0,0 +1,130 @@
<Window x:Class="bib_talk.Login"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Login"
Height="380"
Width="600"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent"
WindowStartupLocation="CenterScreen">
<Window.Resources>
<Style x:Key="InvisibleButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="NoHoverButtonStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Border CornerRadius="15" BorderThickness="20" BorderBrush="#FF282828">
<Grid Margin="-10,-10,-10,-10" Background="#FF282828">
<!-- Draggable Area -->
<Grid VerticalAlignment="Top" Height="45" Background="Transparent" MouseLeftButtonDown="DraggableArea_MouseLeftButtonDown" Margin="0,-21,0,0">
</Grid>
<!-- Close Button -->
<Button Style="{StaticResource InvisibleButtonStyle}"
Width="30"
Height="30"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Margin="0,0,0,0"
Click="CloseButton_Click">
<TextBlock Text="❌"
FontSize="20"
Foreground="White"
FontWeight="Bold"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Button>
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Left" Margin="23,29,0,0" Height="324">
<TextBlock Text="Willkommen zurück!"
FontSize="24"
Foreground="White"
HorizontalAlignment="Center"/>
<!-- Email TextBox -->
<TextBlock Text="Benutzername"
Foreground="White"
FontSize="16"
Margin="0,40,0,-30"/>
<TextBox Width="300"
x:Name="usernbox"
Height="30"
FontSize="20"
BorderBrush="Transparent"
Margin="0,30,0,0"
Background="#FF323134"
Foreground="White"
SelectionBrush="#FF6332A0"/>
<!-- Benutzername TextBox -->
<TextBlock Text="Passwort"
Foreground="White"
FontSize="16"
Margin="0,20,0,-30"/>
<PasswordBox Width="300"
x:Name="passwordbox"
PasswordChanged="passwordbox_PasswordChanged"
Height="30"
FontSize="20"
BorderBrush="Transparent"
Margin="0,30,0,0"
Background="#FF323134"
Foreground="White"
SelectionBrush="#FF6332A0"/>
<Button x:Name="weiterbutton" Content="Weiter" Foreground="Gray" Background="#FF323134" BorderThickness="0" Margin="0,30,0,0" Height="30" BorderBrush="{x:Null}" Click="WeiterButton_Click" Style="{StaticResource NoHoverButtonStyle}"/>
<TextBlock Text="Noch keinen Account?"
Foreground="White"
FontSize="12"
Width="136"
Margin="20,20,0,0"/>
<Button Style="{StaticResource InvisibleButtonStyle}" Click="Register_Click">
<TextBlock Text="Registrieren"
Foreground="#FF6332A0"
FontSize="12"
Width="66"
Margin="8,5,0,0"/>
</Button>
</StackPanel>
<Ellipse HorizontalAlignment="Left" Height="200" Margin="365,0,0,0" Fill="#FF6332A0" VerticalAlignment="Center" Width="200"/>
</Grid>
</Border>
</Window>

View File

@@ -0,0 +1,103 @@
using Newtonsoft.Json;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows;
namespace bib_talk
{
public partial class Login : Window
{
// Field to store logged in user
public static string loggedInUser;
public Login()
{
InitializeComponent();
}
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 void WeiterButton_Click(object sender, RoutedEventArgs e)
{
if (usernbox.Text != "" && passwordbox.Password != "")
{
LoginServer();
}
}
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();
}
public async Task LoginServer()
{
string username = usernbox.Text;
string password = passwordbox.Password;
var loginData = new { Username = username, Password = password, Email = "", Birthday = "", IsOnline = ""};
string json = JsonConvert.SerializeObject(loginData);
using (var client = new HttpClient())
{
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("http://daddypig.dns.navy:5114/api/users/login", content);
if (response.IsSuccessStatusCode)
{
var responseContent = await response.Content.ReadAsStringAsync();
var responseData = JsonConvert.DeserializeObject<dynamic>(responseContent);
string loggedInUsername = responseData.username;
MainWindow mainWindow = new MainWindow(loggedInUsername);
mainWindow.Show();
this.Close();
}
else
{
var responseContent = await response.Content.ReadAsStringAsync();
MessageBox.Show($"Login failed: {responseContent}");
}
}
}
}
}

View File

@@ -0,0 +1,117 @@
<Window x:Class="bib_talk.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="MainWindow"
Height="700"
Width="1000"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent"
WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
<Window.Resources>
<Style x:Key="InvisibleButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="NoHoverButtonStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Border CornerRadius="15" BorderThickness="20" BorderBrush="#FF282828">
<Grid Margin="-10,-10,-10,-10" Background="#FF282828">
<!-- Draggable Area -->
<Grid VerticalAlignment="Top" Height="45" Background="Transparent" MouseLeftButtonDown="DraggableArea_MouseLeftButtonDown" Margin="0,-21,0,0">
</Grid>
<!-- Close Button -->
<Button Style="{StaticResource InvisibleButtonStyle}"
Width="30"
Height="30"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Margin="0,0,0,0"
Click="CloseButton_Click">
<TextBlock Text="❌"
FontSize="20"
Foreground="White"
FontWeight="Bold"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Button>
<TextBlock HorizontalAlignment="Left" x:Name="loggedinuser" Margin="32,11,0,0" TextWrapping="Wrap" Text="xxxx" VerticalAlignment="Top" Height="22" Width="146" Foreground="White"/>
<ListBox x:Name="onlineUsersListBox" Margin="32,60,760,440" d:ItemsSource="{d:SampleData ItemCount=5}" Background="#FF323134" BorderBrush="{x:Null}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Username}" FontWeight="Bold" Margin="5" Foreground="#FF6332A0"/>
<Ellipse Width="10" Height="10" Fill="Green" Margin="5"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ListBox x:Name="chatlistbox" Margin="244,60,44,105" d:ItemsSource="{d:SampleData ItemCount=5}" Background="#FF323134" BorderBrush="{x:Null}" Foreground="#FF6332A0" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="5">
<TextBlock Text="{Binding Username}" FontWeight="Bold" FontSize="20"/>
<TextBlock Text="{Binding Timestamp, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}" Foreground="Gray"/>
<TextBlock TextWrapping="Wrap" Text="{Binding Text}" FontSize="16"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBox
x:Name="messageBOX"
Height="30"
FontSize="20"
BorderBrush="Transparent"
Margin="244,601,154,49"
Background="#FF323134"
Foreground="White"
SelectionBrush="#FF6332A0"/>
<Button x:Name="weiterbutton" Click="send_Click" Content="Weiter" Foreground="White" Background="#FF6332A0" BorderThickness="0" Margin="831,602,44,50" BorderBrush="{x:Null}" Style="{StaticResource NoHoverButtonStyle}" RenderTransformOrigin="0.279,0.633"/>
</Grid>
</Border>
</Window>

View File

@@ -0,0 +1,166 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
namespace bib_talk
{
public partial class MainWindow : Window
{
private DispatcherTimer _timer;
public string loggedinUser;
private bool isFirstLoad = true;
public MainWindow()
{
InitializeComponent();
InitializeTimer();
LoadData();
}
public MainWindow(string user)
{
loggedinUser = user;
InitializeComponent();
InitializeTimer();
LoadData();
LoadMessages();
}
private void InitializeTimer()
{
_timer = new DispatcherTimer
{
Interval = TimeSpan.FromSeconds(2)
};
_timer.Tick += (sender, e) => { LoadMessages(); LoadOnlineUsers(); };
_timer.Start();
}
public void LoadData()
{
loggedinuser.Text = "Logged in as: " + loggedinUser;
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
LogoutUser();
this.Close();
}
private void DraggableArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.ButtonState == MouseButtonState.Pressed)
{
DragMove();
}
}
private async void LoadMessages()
{
using (var client = new HttpClient())
{
var response = await client.GetAsync("http://daddypig.dns.navy:5114/api/messages/get");
if (response.IsSuccessStatusCode)
{
var responseContent = await response.Content.ReadAsStringAsync();
var messages = JsonConvert.DeserializeObject<List<Message>>(responseContent);
chatlistbox.ItemsSource = messages;
if (chatlistbox.Items.Count > 0)
{
var lastItem = chatlistbox.Items[chatlistbox.Items.Count - 1];
chatlistbox.ScrollIntoView(lastItem);
}
}
}
}
private async void send_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrEmpty(messageBOX.Text))
{
var message = new MessageDto
{
Username = loggedinUser,
Message = messageBOX.Text,
Timestamp = DateTime.Now,
};
using (var client = new HttpClient())
{
var json = JsonConvert.SerializeObject(message);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("http://daddypig.dns.navy:5114/api/messages/send", content);
if (response.IsSuccessStatusCode)
{
messageBOX.Clear();
LoadMessages(); // Reload messages after sending
}
}
}
}
private async void LogoutUser()
{
using (var client = new HttpClient())
{
var logoutData = new { Username = loggedinUser, Password = "", Email = "", Birthday = "", IsOnline = "" };
var json = JsonConvert.SerializeObject(logoutData);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("http://daddypig.dns.navy:5114/api/users/logout", content);
var responseContent = await response.Content.ReadAsStringAsync();
this.Close();
}
}
private async void LoadOnlineUsers()
{
using (var client = new HttpClient())
{
var response = await client.GetAsync("http://daddypig.dns.navy:5114/api/users/online-users");
if (response.IsSuccessStatusCode)
{
var responseContent = await response.Content.ReadAsStringAsync();
var onlineUsers = JsonConvert.DeserializeObject<List<User>>(responseContent);
onlineUsersListBox.ItemsSource = onlineUsers;
}
}
}
}
public class Message
{
public int Id { get; set; }
public string Username { get; set; }
public string Text { get; set; }
public DateTime Timestamp { get; set; }
}
public class MessageDto
{
public string Username { get; set; }
public string Message { get; set; }
public DateTime Timestamp { get; set; }
}
public class User
{
public int Id { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Email { get; set; }
public string Birthday { get; set; }
public string IsOnline { get; set; }
}
}

View File

@@ -0,0 +1,223 @@
<Window x:Class="bib_talk.RegisterWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Register"
Height="530"
Width="400"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent"
WindowStartupLocation="CenterScreen">
<Window.Resources>
<Style x:Key="InvisibleButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="CustomCheckBoxStyle" TargetType="CheckBox">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<Grid>
<Ellipse x:Name="OuterEllipse"
Width="20"
Height="20"
Fill="#FF323134"
Margin="0,0,10,0"
StrokeThickness="1"/>
<Ellipse x:Name="InnerEllipse"
Width="14"
Height="14"
Fill="#FF323134"
StrokeThickness="0"
Margin="3,8,13,7"/>
<Path x:Name="CheckMark"
Stroke="#FF6332A0"
StrokeThickness="2"
Data="M 3,8 L 7,12 L 14,5"
Visibility="Visible" Stretch="Fill" Margin="3,10,13,9" RenderTransformOrigin="0.967,1.39"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="CheckMark" Property="Visibility" Value="Visible"/>
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="NoHoverButtonStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Border CornerRadius="15" BorderThickness="20" BorderBrush="#FF282828">
<Grid Margin="-10,-10,-10,-10" Background="#FF282828">
<!-- Draggable Area -->
<Grid VerticalAlignment="Top" Height="40" Background="Transparent" MouseLeftButtonDown="DraggableArea_MouseLeftButtonDown">
</Grid>
<!-- Close Button -->
<Button Style="{StaticResource InvisibleButtonStyle}"
Width="30"
Height="30"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Margin="0,0,0,0"
Click="CloseButton_Click">
<TextBlock Text="❌"
FontSize="20"
Foreground="White"
FontWeight="Bold"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Button>
<!-- Centered Content -->
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,40,0,0" Height="473">
<!-- Account erstellen Text -->
<TextBlock Text="Account erstellen"
FontSize="24"
Foreground="White"
HorizontalAlignment="Center"/>
<!-- Email TextBox -->
<TextBlock Text="E-Mail"
Foreground="White"
FontSize="16"
Margin="0,40,0,-30"/>
<TextBox Width="300"
Height="30"
FontSize="20"
x:Name="emailbox"
BorderBrush="Transparent"
Margin="0,30,0,0"
Background="#FF323134"
Foreground="White"
SelectionBrush="#FF6332A0"/>
<!-- Benutzername TextBox -->
<TextBlock Text="Benutzername"
Foreground="White"
FontSize="16"
Margin="0,20,0,-30"/>
<TextBox Width="300"
Height="30"
FontSize="20"
x:Name="usernbox"
BorderBrush="Transparent"
Margin="0,30,0,0"
Background="#FF323134"
Foreground="White"
SelectionBrush="#FF6332A0"/>
<!-- Passwort PasswordBox -->
<TextBlock Text="Passwort"
FontSize="16"
Foreground="White"
Margin="0,20,0,-30"/>
<PasswordBox Width="300"
Height="30"
FontSize="20"
x:Name="passwordbox"
BorderBrush="Transparent"
Margin="0,30,0,0"
Background="#FF323134"
Foreground="White"
SelectionBrush="#FF6332A0"/>
<!-- Geburtsdatum Text -->
<TextBlock Text="Geburtsdatum"
Foreground="White"
FontSize="16"
Margin="0,20,0,-30"/>
<StackPanel Orientation="Horizontal" Margin="0,30,0,0">
<TextBox Width="100"
Height="30"
FontSize="20"
x:Name="bday1"
BorderBrush="Transparent"
Background="#FF323134"
Foreground="White"
SelectionBrush="#FF6332A0"/>
<TextBox Width="100"
Height="30"
FontSize="20"
x:Name="bday2"
BorderBrush="Transparent"
Background="#FF323134"
Foreground="White"
SelectionBrush="#FF6332A0"/>
<TextBox Width="100"
Height="30"
FontSize="20"
x:Name="bday3"
BorderBrush="Transparent"
Background="#FF323134"
Foreground="White"
SelectionBrush="#FF6332A0"/>
</StackPanel>
<!-- Checkbox -->
<StackPanel Orientation="Horizontal" Margin="0,20,0,0" Height="29">
<CheckBox x:Name="checkboxAGB" Style="{StaticResource CustomCheckBoxStyle}" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked"/>
<TextBlock FontSize="9" TextWrapping="Wrap" VerticalAlignment="Center" Height="24" Width="269">
<Run Text="Ich habe die " Foreground="White"/>
<Run Text="Nutzungsbedingungen" Foreground="#FF6332A0"/>
<Run Text=" und die " Foreground="White"/>
<Run Text="Datenschutzerklärung" Foreground="#FF6332A0"/>
<Run Text=" von bib-talk gelesen und akzeptiert." Foreground="White"/>
</TextBlock>
</StackPanel>
<Button x:Name="weiterbutton" Content="Weiter" Foreground="Gray" Background="#FF323134" BorderThickness="0" Margin="0,20,0,0" Height="30" BorderBrush="{x:Null}" Click="WeiterButton_Click" Style="{StaticResource NoHoverButtonStyle}"/>
<Button Style="{StaticResource InvisibleButtonStyle}" Click="Login_Click">
<TextBlock Text="Ich habe bereits einen Account"
Foreground="#FF6332A0"
FontSize="12"
Width="167"
Margin="-130,5,0,0"/>
</Button>
</StackPanel>
</Grid>
</Border>
</Window>

View File

@@ -0,0 +1,94 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
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;
using System.Net.Http;
using Newtonsoft.Json;
namespace bib_talk
{
public partial class RegisterWindow : Window
{
public RegisterWindow()
{
InitializeComponent();
}
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 void WeiterButton_Click(object sender, RoutedEventArgs e)
{
if (checkboxAGB.IsChecked == true)
{
RegisterServer();
}
}
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;
}
public async Task RegisterServer()
{
string username = usernbox.Text;
string password = passwordbox.Password;
string email = emailbox.Text;
string birthday = bday1.Text+"."+bday2.Text+"."+bday3.Text;
var newUser = new { Username = username, Password = password, Email = email, Birthday = birthday, IsOnline = ""};
string json = JsonConvert.SerializeObject(newUser);
using (var client = new HttpClient())
{
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("http://daddypig.dns.navy:5114/api/users/register", content);
if (response.IsSuccessStatusCode)
{
MessageBox.Show("Registration Succesful");
}
else
{
MessageBox.Show("Registration failed."+ response);
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<RootNamespace>bib_talk</RootNamespace>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="Icons\" />
</ItemGroup>
</Project>