@@ -0,0 +1,52 @@
|
||||
<UserControl
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:EinmaleinsTrainer.ViewModels"
|
||||
x:Class="EinmaleinsTrainer.Views.MainView"
|
||||
x:DataType="vm:MainViewModel">
|
||||
|
||||
<Grid>
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="10" Margin="20">
|
||||
|
||||
<TextBlock FontSize="32" Text="Einmaleins Trainer"/>
|
||||
|
||||
<WrapPanel>
|
||||
<CheckBox FontSize="24" Content="1" IsChecked="{Binding IsRow1Checked}" Width="60" />
|
||||
<CheckBox FontSize="24" Content="2" IsChecked="{Binding IsRow2Checked}" Width="60" />
|
||||
<CheckBox FontSize="24" Content="3" IsChecked="{Binding IsRow3Checked}" Width="60" />
|
||||
<CheckBox FontSize="24" Content="4" IsChecked="{Binding IsRow4Checked}" Width="60" />
|
||||
<CheckBox FontSize="24" Content="5" IsChecked="{Binding IsRow5Checked}" Width="60" />
|
||||
</WrapPanel>
|
||||
|
||||
<WrapPanel>
|
||||
<CheckBox FontSize="24" Content="6" IsChecked="{Binding IsRow6Checked}" Width="60" />
|
||||
<CheckBox FontSize="24" Content="7" IsChecked="{Binding IsRow7Checked}" Width="60" />
|
||||
<CheckBox FontSize="24" Content="8" IsChecked="{Binding IsRow8Checked}" Width="60" />
|
||||
<CheckBox FontSize="24" Content="9" IsChecked="{Binding IsRow9Checked}" Width="60" />
|
||||
<CheckBox FontSize="24" Content="10" IsChecked="{Binding IsRow10Checked}" Width="60" />
|
||||
</WrapPanel>
|
||||
|
||||
<CheckBox FontSize="24" Content="Quadratzahlen" IsChecked="{Binding IncludeSquares}" />
|
||||
|
||||
<WrapPanel>
|
||||
<Grid Height="44">
|
||||
<CheckBox FontSize="24" Content="Zeitlimit" VerticalAlignment="Center"
|
||||
IsChecked="{Binding UseTimer}" Width="140"/>
|
||||
</Grid>
|
||||
|
||||
<NumericUpDown Minimum="2" Maximum="120" FontSize="24" Value="{Binding SecondsPerQuestion, Mode=TwoWay}" Width="140" FormatString="F0" ParsingNumberStyle="Integer" IsVisible="{Binding UseTimer}" />
|
||||
|
||||
<Grid Height="40">
|
||||
<TextBlock FontSize="24" Text=" s" VerticalAlignment="Center" IsVisible="{Binding UseTimer}" />
|
||||
</Grid>
|
||||
</WrapPanel>
|
||||
|
||||
<StackPanel HorizontalAlignment="Center" >
|
||||
<Button FontSize="24" Content="Start" IsDefault="True"
|
||||
Command="{Binding StartCommand}" />
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,39 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using EinmaleinsTrainer.ViewModels;
|
||||
|
||||
namespace EinmaleinsTrainer.Views;
|
||||
|
||||
public partial class MainView : UserControl
|
||||
{
|
||||
public MainView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
private void Row_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is CheckBox cb
|
||||
&& DataContext is MainViewModel vm
|
||||
&& int.TryParse(cb.Content?.ToString(), out int value))
|
||||
{
|
||||
vm.ToggleRow(value, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void Row_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is CheckBox cb
|
||||
&& DataContext is MainViewModel vm
|
||||
&& int.TryParse(cb.Content?.ToString(), out int value))
|
||||
{
|
||||
vm.ToggleRow(value, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:EinmaleinsTrainer.ViewModels"
|
||||
xmlns:views="using:EinmaleinsTrainer.Views"
|
||||
x:Class="EinmaleinsTrainer.Views.MainWindow"
|
||||
x:DataType="vm:MainWindowViewModel">
|
||||
|
||||
<Window.DataTemplates>
|
||||
<DataTemplate DataType="vm:MainViewModel">
|
||||
<views:MainView/>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="vm:QuizViewModel">
|
||||
<views:QuizView/>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="vm:ResultViewModel">
|
||||
<views:ResultView/>
|
||||
</DataTemplate>
|
||||
</Window.DataTemplates>
|
||||
|
||||
<ContentControl Content="{Binding Current}" />
|
||||
|
||||
</Window>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using EinmaleinsTrainer.ViewModels;
|
||||
|
||||
namespace EinmaleinsTrainer.Views;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new MainWindowViewModel();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<UserControl
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:EinmaleinsTrainer.ViewModels"
|
||||
x:Class="EinmaleinsTrainer.Views.QuizView"
|
||||
x:DataType="vm:QuizViewModel">
|
||||
|
||||
<Grid>
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="12" Margin="20">
|
||||
|
||||
<TextBlock FontSize="18"
|
||||
Text="{Binding QuestionNumber, StringFormat='Frage {0}'}" />
|
||||
|
||||
<TextBlock FontSize="36"
|
||||
Text="{Binding CurrentQuestionText}" />
|
||||
|
||||
<TextBox x:Name="AnswerTextBox" FontSize="24" Text="{Binding UserAnswer, Mode=TwoWay}" />
|
||||
|
||||
<Button FontSize="24" Content="OK" IsDefault="True"
|
||||
Command="{Binding SubmitCommand}" />
|
||||
|
||||
<TextBlock FontSize="12" Text="{Binding Score, StringFormat='Punkte: {0}'}" />
|
||||
|
||||
<TextBlock FontSize="18" Text="{Binding RemainingSeconds, StringFormat='Zeit: {0} s'}"
|
||||
IsVisible="{Binding UseTimer}" />
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,26 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Threading;
|
||||
|
||||
namespace EinmaleinsTrainer.Views;
|
||||
|
||||
public partial class QuizView : UserControl
|
||||
{
|
||||
public QuizView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.AttachedToVisualTree += async (_,_) =>
|
||||
{
|
||||
await Dispatcher.UIThread.InvokeAsync(() => { }, DispatcherPriority.Background);
|
||||
|
||||
var tb = this.FindControl<TextBox>("AnswerTextBox");
|
||||
tb?.Focus();
|
||||
};
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<UserControl
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:EinmaleinsTrainer.ViewModels"
|
||||
x:Class="EinmaleinsTrainer.Views.ResultView"
|
||||
x:DataType="vm:ResultViewModel">
|
||||
|
||||
<Grid>
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="12" Margin="20">
|
||||
|
||||
<StackPanel HorizontalAlignment="Center" >
|
||||
<TextBlock FontSize="36"
|
||||
Text="{Binding Text}" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel HorizontalAlignment="Center" IsVisible="{Binding ShowTimeRequired}" >
|
||||
<TextBlock FontSize="24"
|
||||
Text="{Binding TimeRequiredText}" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel HorizontalAlignment="Center" >
|
||||
<Button FontSize="36" Content="Neu starten" IsDefault="True"
|
||||
Command="{Binding RestartCommand}" />
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,18 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace EinmaleinsTrainer.Views;
|
||||
|
||||
public partial class ResultView : UserControl
|
||||
{
|
||||
public ResultView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user