Dateien nach "PenPaperMain" hochladen
This commit is contained in:
parent
19b2fe1b91
commit
3807764cb4
62
PenPaperMain/Anmeldung.xaml
Normal file
62
PenPaperMain/Anmeldung.xaml
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<Window x:Class="Pen_Paper_Main.Anmeldung"
|
||||||
|
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"
|
||||||
|
xmlns:local="clr-namespace:Pen_Paper_Main"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Anmeldung" Height="450" Width="800">
|
||||||
|
<Grid Background="LightBlue">
|
||||||
|
<Border Width="350" Padding="20" Background="White" CornerRadius="10"
|
||||||
|
VerticalAlignment="Center" HorizontalAlignment="Center" >
|
||||||
|
<StackPanel >
|
||||||
|
<TextBlock Text="Anmeldung"
|
||||||
|
FontSize="24"
|
||||||
|
FontWeight="Bold"
|
||||||
|
HorizontalAlignment="Center" />
|
||||||
|
|
||||||
|
|
||||||
|
<Grid Margin="10" Height="35">
|
||||||
|
<TextBox x:Name="BenutzernameInput"
|
||||||
|
Foreground="Gray"
|
||||||
|
HorizontalContentAlignment="Center"
|
||||||
|
VerticalContentAlignment="Center"
|
||||||
|
TextChanged="BenutzernameInput_TextChanged" />
|
||||||
|
|
||||||
|
<TextBlock x:Name="BenutzernamePlaceHolder"
|
||||||
|
Text="Benutzernamen eingeben"
|
||||||
|
Foreground="Gray"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
IsHitTestVisible="False"
|
||||||
|
Margin="5,0,0,0"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<Grid Margin="10" Height="35">
|
||||||
|
<PasswordBox x:Name="PasswortBox"
|
||||||
|
HorizontalContentAlignment="Center"
|
||||||
|
VerticalContentAlignment="Center"
|
||||||
|
PasswordChanged="PasswortBox_PasswordChanged"/>
|
||||||
|
|
||||||
|
<TextBlock x:Name="PasswortPlaceholder"
|
||||||
|
Text="Passwort eingeben"
|
||||||
|
Foreground="Gray"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
IsHitTestVisible="False"
|
||||||
|
Margin="5,0,0,0"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<Button Content="Anmelden"
|
||||||
|
Height="40" Background="#3B82F6"
|
||||||
|
Foreground="White"
|
||||||
|
Click="Anmelden_Click"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
69
PenPaperMain/Anmeldung.xaml.cs
Normal file
69
PenPaperMain/Anmeldung.xaml.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
using System;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace Pen_Paper_Main
|
||||||
|
{
|
||||||
|
public partial class Anmeldung : Window
|
||||||
|
{
|
||||||
|
public Anmeldung()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void Anmelden_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
string user = BenutzernameInput.Text;
|
||||||
|
string pass = PasswortBox.Password;
|
||||||
|
|
||||||
|
var result = await CallApi("login", user, pass);
|
||||||
|
|
||||||
|
if (result.ok)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Anmeldung erfolgreich");
|
||||||
|
Lobby lobby = new Lobby();
|
||||||
|
lobby.Show();
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Fehler: " + result.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<(bool ok,string msg)> CallApi(string action, string u, string p)
|
||||||
|
{
|
||||||
|
using var client = new HttpClient();
|
||||||
|
var json = JsonSerializer.Serialize(new { username = u, password = p });
|
||||||
|
var resp = await client.PostAsync($"http://localhost/api/users.php?action={action}",
|
||||||
|
new StringContent(json, Encoding.UTF8, "application/json"));
|
||||||
|
var body = await resp.Content.ReadAsStringAsync();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var doc = JsonDocument.Parse(body);
|
||||||
|
bool ok = doc.RootElement.GetProperty("ok").GetBoolean();
|
||||||
|
string msg = doc.RootElement.GetProperty("msg").GetString();
|
||||||
|
return (ok, msg);
|
||||||
|
}
|
||||||
|
catch { return (false, "invalid response"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PasswortBox_PasswordChanged(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
PasswortPlaceholder.Visibility = string.IsNullOrEmpty(PasswortBox.Password)
|
||||||
|
? Visibility.Visible
|
||||||
|
: Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BenutzernameInput_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
BenutzernamePlaceHolder.Visibility = string.IsNullOrEmpty(BenutzernameInput.Text)
|
||||||
|
? Visibility.Visible
|
||||||
|
: Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
PenPaperMain/CharaktereNeu.xaml.cs
Normal file
26
PenPaperMain/CharaktereNeu.xaml.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
|
||||||
|
//jakob
|
||||||
|
namespace Pen_Paper_Main
|
||||||
|
{
|
||||||
|
public partial class CharakterNeu : Window
|
||||||
|
{
|
||||||
|
public CharakterNeu() { InitializeComponent(); }
|
||||||
|
|
||||||
|
private async void Save_Click(object s, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var payload = new { username = TxtUser.Text, name = TxtChar.Text };
|
||||||
|
using var http = new HttpClient();
|
||||||
|
var resp = await http.PostAsync("http://localhost/api/characters.php?action=create",
|
||||||
|
new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json"));
|
||||||
|
var body = await resp.Content.ReadAsStringAsync();
|
||||||
|
MessageBox.Show(body);
|
||||||
|
DialogResult = true; Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
50
PenPaperMain/Kampange.xaml
Normal file
50
PenPaperMain/Kampange.xaml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<Window x:Class="Pen_Paper_Main.Kampange"
|
||||||
|
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"
|
||||||
|
xmlns:local="clr-namespace:Pen_Paper_Main"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Kampange" Height="450" Width="800">
|
||||||
|
<DockPanel Background="LightBlue">
|
||||||
|
<TextBlock DockPanel.Dock="Top" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="35" FontWeight="Bold">Kampangen</TextBlock>
|
||||||
|
|
||||||
|
<Border Width="Auto" Padding="20" Height="Auto" Background="White" CornerRadius="10"
|
||||||
|
VerticalAlignment="Center" HorizontalAlignment="Center" >
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Row="0" Grid.Column="0" FontSize="15" HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center" FontWeight="Bold" Margin="15">Titel :</TextBlock>
|
||||||
|
|
||||||
|
<TextBlock Grid.Row="0" Grid.Column="1" FontSize="15" HorizontalAlignment="Center" Foreground="LightGray"
|
||||||
|
VerticalAlignment="Center" Margin="15">BlaBlaBla</TextBlock>
|
||||||
|
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="0" FontSize="15" HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center" FontWeight="Bold" Margin="15">Beschreibung :</TextBlock>
|
||||||
|
|
||||||
|
<Button Grid.Row="2" Grid.Column="0" FontSize="15" HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center" Width="100" Margin="15">Bearbeiten</Button>
|
||||||
|
|
||||||
|
<TextBlock Grid.Row="1" FontSize="15" Grid.Column="1" HorizontalAlignment="Center" Foreground="LightGray"
|
||||||
|
VerticalAlignment="Center" >BlaBlaBla</TextBlock>
|
||||||
|
|
||||||
|
<Button Grid.Row="2" Grid.Column="1" FontSize="15" HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center" Width="100" Margin="15">Löschen</Button>
|
||||||
|
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</DockPanel>
|
||||||
|
</Window>
|
27
PenPaperMain/Kampange.xaml.cs
Normal file
27
PenPaperMain/Kampange.xaml.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
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.Shapes;
|
||||||
|
|
||||||
|
namespace Pen_Paper_Main
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaktionslogik für Kampange.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class Kampange : Window
|
||||||
|
{
|
||||||
|
public Kampange()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user