new style

This commit is contained in:
NickiCloud
2026-06-05 17:40:43 +02:00
parent 0b20a47ad1
commit 22c4f44f84
15 changed files with 81 additions and 27 deletions
+1
View File
@@ -3,6 +3,7 @@
<component name="AvaloniaProject"> <component name="AvaloniaProject">
<option name="projectPerEditor"> <option name="projectPerEditor">
<map> <map>
<entry key="ZahlenRaten/App.axaml" value="ZahlenRaten/ZahlenRaten.csproj" />
<entry key="ZahlenRaten/MainWindow.axaml" value="ZahlenRaten/ZahlenRaten.csproj" /> <entry key="ZahlenRaten/MainWindow.axaml" value="ZahlenRaten/ZahlenRaten.csproj" />
</map> </map>
</option> </option>
+1 -1
View File
@@ -1,7 +1,7 @@
<Application xmlns="https://github.com/avaloniaui" <Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ZahlenRaten.App" x:Class="ZahlenRaten.App"
RequestedThemeVariant="Default"> RequestedThemeVariant="Dark">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. --> <!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.Styles> <Application.Styles>
+50 -7
View File
@@ -4,13 +4,56 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ZahlenRaten.MainWindow" x:Class="ZahlenRaten.MainWindow"
Title="ZahlenRaten"> Title="ZahlenRaten"
Background="#1e1e1e"
Width="400" Height="500"
WindowStartupLocation="CenterScreen">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20" Spacing="10"> <Border Margin="20" Padding="20" Background="#2d2d2d" CornerRadius="12" BoxShadow="0 4 15 0 #80000000">
<TextBlock HorizontalAlignment="Center">Gib deine Zahl ein:</TextBlock> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="20">
<TextBox MaxWidth="2" HorizontalAlignment="Center" x:Name="txtInput"></TextBox> <TextBlock FontSize="24" FontWeight="Bold" HorizontalAlignment="Center" Foreground="#ffffff">Zahlen raten</TextBlock>
<TextBlock MaxHeight="60" Height="60" HorizontalAlignment="Center" x:Name="txtOutput"></TextBlock>
<Button HorizontalAlignment="Center" Click="btnRaten_OnClick" x:Name="btnRaten" >Raten</Button> <TextBlock HorizontalAlignment="Center" Foreground="#cccccc">Gib deine Zahl ein (0-9):</TextBlock>
<Button IsVisible="False" HorizontalAlignment="Center" Click="btnNeueZahl_OnClick" x:Name="btnNeueZahl" >Neues Spiel</Button>
<TextBox Width="60"
FontSize="18"
HorizontalAlignment="Center"
HorizontalContentAlignment="Center"
x:Name="txtInput"
CornerRadius="8"
BorderThickness="2"
BorderBrush="#444444"/>
<TextBlock Height="80"
TextWrapping="Wrap"
TextAlignment="Center"
HorizontalAlignment="Center"
x:Name="txtOutput"
Foreground="#3498db"
FontSize="14"/>
<Button HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
Padding="10,12"
Background="#27ae60"
Foreground="White"
Click="btnRaten_OnClick"
x:Name="btnRaten"
CornerRadius="8">
Raten
</Button>
<Button IsVisible="False"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
Padding="10,12"
Background="#2980b9"
Foreground="White"
Click="btnNeueZahl_OnClick"
x:Name="btnNeueZahl"
CornerRadius="8">
Neues Spiel
</Button>
</StackPanel> </StackPanel>
</Border>
</Window> </Window>
+27 -17
View File
@@ -1,6 +1,7 @@
using System; using System;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Media;
namespace ZahlenRaten; namespace ZahlenRaten;
@@ -25,42 +26,51 @@ public partial class MainWindow : Window
private void btnRaten_OnClick(object sender, RoutedEventArgs e) private void btnRaten_OnClick(object sender, RoutedEventArgs e)
{ {
if (_leben > 0) if (string.IsNullOrWhiteSpace(txtInput.Text)) return;
if (int.TryParse(txtInput.Text, out int input))
{ {
int input = Convert.ToInt32(txtInput.Text);
if (input == _zielZahl) if (input == _zielZahl)
{ {
txtOutput.Text = $"Du hast die Zahl erraten! Es war die Zahl: {_zielZahl}"; txtOutput.Text = $"🎉 Richtig! Es war die Zahl: {_zielZahl}";
txtOutput.Foreground = Brushes.LightGreen;
btnRaten.IsVisible = false; btnRaten.IsVisible = false;
btnNeueZahl.IsVisible = true; btnNeueZahl.IsVisible = true;
} }
else if (input > _zielZahl)
{
txtOutput.Text = $"Deine Zahl ist kleiner als die Gesuchte Zahl. \nDu hast noch {_leben} Leben. \nDeine zuletzt geratene Zahl war die {input}";
}
else else
{ {
txtOutput.Text = $"Deine Zahl ist höher als die gesuchte Zahl. \nDu hast noch {_leben} Leben. \nDeine zuletzt geratene Zahl war die {input}"; _leben--;
if (_leben > 0)
{
string richtung = input > _zielZahl ? "kleiner" : "größer";
txtOutput.Text = $"Die gesuchte Zahl ist {richtung}.\nLeben: {_leben}\nLetzter Tipp: {input}";
txtOutput.Foreground = Brushes.Orange;
}
else
{
txtOutput.Text = $"❌ Verloren! Die Zahl war: {_zielZahl}";
txtOutput.Foreground = Brushes.Salmon;
btnRaten.IsVisible = false;
btnNeueZahl.IsVisible = true;
}
} }
txtInput.Text = "";
txtInput.Focus();
_leben--;
} }
else else
{ {
txtOutput.Text = $"Du hast Verloren! Die Zahl war die {_zielZahl}"; txtOutput.Text = "Ungültige Eingabe!";
btnRaten.IsVisible = false; txtOutput.Foreground = Brushes.Yellow;
btnNeueZahl.IsVisible = true;
} }
txtInput.Text = "";
txtInput.Focus();
} }
private void btnNeueZahl_OnClick(object sender, RoutedEventArgs e) private void btnNeueZahl_OnClick(object sender, RoutedEventArgs e)
{ {
_leben = StandartLeben; _leben = StandartLeben;
txtInput.Text = ""; txtInput.Text = "";
txtOutput.Text = String.Empty; txtOutput.Text = string.Empty;
txtOutput.Foreground = new SolidColorBrush(Color.Parse("#3498db"));
_zielZahl = ZahlErstellen(); _zielZahl = ZahlErstellen();
btnRaten.IsVisible = true; btnRaten.IsVisible = true;
btnNeueZahl.IsVisible = false; btnNeueZahl.IsVisible = false;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("ZahlenRaten")] [assembly: System.Reflection.AssemblyCompanyAttribute("ZahlenRaten")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0b20a47ad1499453d8f57815037750761f0e31a2")]
[assembly: System.Reflection.AssemblyProductAttribute("ZahlenRaten")] [assembly: System.Reflection.AssemblyProductAttribute("ZahlenRaten")]
[assembly: System.Reflection.AssemblyTitleAttribute("ZahlenRaten")] [assembly: System.Reflection.AssemblyTitleAttribute("ZahlenRaten")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -1 +1 @@
f93a9366a989cb1b34fe487bdcb104c8c4f6e0edc88af14844591a28c252bd90 e2ab9cd92d5fe7380e4803bd6803a1f41bd7cb5d6818965969dc31e782b439cb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.