Dateien nach "/" hochladen

This commit is contained in:
Jakob Weber 2025-09-03 09:29:34 +02:00
parent d78ca8b6db
commit 3104d62f50
5 changed files with 151 additions and 0 deletions

15
CharakterListe.xaml Normal file
View File

@ -0,0 +1,15 @@
<Window x:Class="Pen_Paper_Main.CharakterListe"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Charaktere" Height="300" Width="400" Loaded="Window_Loaded">
<!--jakob-->
<StackPanel Margin="10">
<Button Content=" Neu" Click="New_Click" Margin="0,0,0,6"/>
<ListBox x:Name="LstChars" Height="180" DisplayMemberPath="name"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,8,0,0">
<Button Content="🗑️ Löschen" Click="Delete_Click" Margin="0,0,8,0"/>
<Button Content="Schließen" Click="Close_Click"/>
</StackPanel>
</StackPanel>
</Window>

49
CharakterListe.xaml.cs Normal file
View File

@ -0,0 +1,49 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows;
namespace Pen_Paper_Main
{
public partial class CharakterListe : Window
{
public CharakterListe() { InitializeComponent(); }
private class CharVm { public string name{get;set;}=""; public string username{get;set;}=""; }
private async void Window_Loaded(object s,RoutedEventArgs e) => await LoadAsync();
private async Task LoadAsync() {
using var http=new HttpClient();
var json=await http.GetStringAsync("http://localhost/api/characters.php?action=list");
using var doc=JsonDocument.Parse(json);
var items=new List<CharVm>();
foreach(var el in doc.RootElement.GetProperty("items").EnumerateArray()) {
items.Add(new CharVm {
name=el.GetProperty("name").GetString()??"",
username=el.GetProperty("username").GetString()??""
});
}
LstChars.ItemsSource=items;
}
private void Close_Click(object s,RoutedEventArgs e)=>Close();
private async void New_Click(object s,RoutedEventArgs e) {
var dlg=new CharakterNeu(); dlg.Owner=this; dlg.ShowDialog();
await LoadAsync();
}
private async void Delete_Click(object s,RoutedEventArgs e) {
if(LstChars.SelectedItem is CharVm vm) {
using var http=new HttpClient();
var url=$"http://localhost/api/characters.php?action=delete&username={vm.username}&name={vm.name}";
var resp=await http.DeleteAsync(url);
var body=await resp.Content.ReadAsStringAsync();
MessageBox.Show(body);
await LoadAsync();
}
}
}
}

18
CharaktereNeu.xaml Normal file
View File

@ -0,0 +1,18 @@
<Window x:Class="Pen_Paper_Main.CharakterNeu"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Neuer Charakter" Height="200" Width="320">
<Border Background="White" CornerRadius="8" Padding="12">
<StackPanel>
<TextBlock Text="Benutzername" Margin="0,0,0,4"/>
<TextBox x:Name="TxtUser" Margin="0,0,0,8"/>
<TextBlock Text="Charaktername" Margin="0,0,0,4"/>
<TextBox x:Name="TxtChar" Margin="0,0,0,12"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="Speichern" Width="100" Click="Save_Click"/>
</StackPanel>
</StackPanel>
</Border>
</Window>

42
Einstellungen.xaml Normal file
View File

@ -0,0 +1,42 @@
<Window x:Class="Pen_Paper_Main.Einstellungen"
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="Einstellungen" Height="450" Width="800">
<DockPanel Background="LightBlue">
<TextBlock DockPanel.Dock="Top" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="35" FontWeight="Bold">Einstellungen</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>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" FontSize="15" HorizontalAlignment="Center"
VerticalAlignment="Center" FontWeight="Bold">ProfilBild auswählen : </TextBlock>
<TextBox Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Width="100" Height="50" Margin="15"></TextBox>
<TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="15" FontWeight="Bold">Benutzername : </TextBlock>
<TextBox Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Width="100" Height="50" Margin="15"></TextBox>
<TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="15" FontWeight="Bold">Sprache : </TextBlock>
<ScrollBar Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10"></ScrollBar>
</Grid>
</Border>
</DockPanel>
</Window>

27
Einstellungen.xaml.cs Normal file
View 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 Einstellungen.xaml
/// </summary>
public partial class Einstellungen : Window
{
public Einstellungen()
{
InitializeComponent();
}
}
}