Compare commits

...

2 Commits

Author SHA1 Message Date
DaddyPig
3d23c510d6 Merge branch 'main' of https://git.bib.de/PBA3H22APE/bib_Talk_Chatprogramm 2024-06-10 15:57:40 +02:00
DaddyPig
892d19a91f bib-talk 23.05 v1
karlomalo
2024-06-10 15:57:04 +02:00
14 changed files with 1339 additions and 0 deletions

63
bibtalk/.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

363
bibtalk/.gitignore vendored Normal file
View File

@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

25
bibtalk/bib-talk.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bib-talk", "bib-talk\bib-talk.csproj", "{92B3214E-6FB1-4D94-B93F-6F1A9D9F2224}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{92B3214E-6FB1-4D94-B93F-6F1A9D9F2224}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{92B3214E-6FB1-4D94-B93F-6F1A9D9F2224}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92B3214E-6FB1-4D94-B93F-6F1A9D9F2224}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92B3214E-6FB1-4D94-B93F-6F1A9D9F2224}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B10C1A50-9612-42F2-9E3A-75F0E9739D01}
EndGlobalSection
EndGlobal

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>