Compare commits

..

3 Commits

3 changed files with 196 additions and 14 deletions

View File

@@ -100,9 +100,97 @@
<Label FontSize="20" Content="Kurse" VerticalContentAlignment="Center" />
</StackPanel>
</TabItem.Header>
<Grid RowDefinitions="2*,*,*">
<Grid ColumnDefinitions="*,2*">
<StackPanel Grid.ColumnSpan="2" Orientation="Horizontal">
<Button Margin="0,10,0,0" x:Name="BtnImportDefaultCourses" VerticalAlignment="Top" Height="30" HorizontalAlignment="Stretch" Click="BtnImportDefaultCourses_OnClick" HorizontalContentAlignment="Center">
<StackPanel Orientation="Horizontal">
<LucideIcon Kind="Import" Width="24" Height="24" />
<Label Content="Standardkurse importieren..." VerticalContentAlignment="Center" FontSize="12"
FontWeight="Bold" />
</StackPanel>
</Button>
</StackPanel>
<ListBox Grid.Column="0" x:Name="LbSportCourses" SelectionChanged="LbSportCourses_OnSelectionChanged" Margin="0,50,0,0" />
<StackPanel Grid.Column="1" Grid.Row="0" Margin="10,10,10,10" Orientation="Vertical" Spacing="10">
<Grid ColumnDefinitions="*,3*">
<Label Content="ID"></Label>
<Label Grid.Column="1" x:Name="LblSportID"></Label>
</Grid>
<Grid ColumnDefinitions="*,3*">
<Label Content="Name"></Label>
<TextBox Grid.Column="1" x:Name="TbSportName" TextChanged="TbStudentID_OnTextChanged"></TextBox>
</Grid>
<Grid ColumnDefinitions="*,3*">
<Label Content="Maximale Schüler*innenanzahl"></Label>
<NumericUpDown Grid.Column="1" x:Name="NudSportMaxStudents"></NumericUpDown>
</Grid>
<Grid ColumnDefinitions="*,3*">
<Label Content="Minimale Schüler*innenanzahl"></Label>
<NumericUpDown Grid.Column="1" x:Name="NudSportMinStudents"></NumericUpDown>
</Grid>
<Grid ColumnDefinitions="*,3*">
<Label Content="Anzahl Angebote Semester 1"></Label>
<NumericUpDown Grid.Column="1" x:Name="NudAmountCoursesSem1"></NumericUpDown>
</Grid>
<Grid ColumnDefinitions="*,3*">
<Label Content="Anzahl Angebote Semester 2"></Label>
<NumericUpDown Grid.Column="1" x:Name="NudAmountCoursesSem2"></NumericUpDown>
</Grid>
<Grid ColumnDefinitions="*,3*">
<Label Content="Anzahl Angebote Semester 3"></Label>
<NumericUpDown Grid.Column="1" x:Name="NudAmountCoursesSem3"></NumericUpDown>
</Grid>
<Grid ColumnDefinitions="*,3*">
<Label Content="Anzahl Angebote Semester 4"></Label>
<NumericUpDown Grid.Column="1" x:Name="NudAmountCoursesSem4"></NumericUpDown>
</Grid>
<Grid ColumnDefinitions="*,3*">
<Label Content="Alternativkurse"></Label>
<StackPanel Grid.Column="1" Orientation="Vertical">
<Grid ColumnDefinitions="*,50">
<ComboBox Height="35" HorizontalAlignment="Stretch" x:Name="CbAlternativCourse"></ComboBox>
<Button Grid.Column="1" Margin="0,10,0,0" x:Name="BtnAlternativeCourseAdd" VerticalAlignment="Top" Height="35" HorizontalAlignment="Stretch" Click="BtnImportDefaultCourses_OnClick" HorizontalContentAlignment="Center">
<StackPanel Orientation="Horizontal">
<LucideIcon Kind="Plus" Width="24" Height="24" />
</StackPanel>
</Button>
</Grid>
<ListBox x:Name="LbAlternativeCourses">
<ContextMenu>
<MenuItem x:Name="MnuAlternativeCoursesDelete" Header="Entfernen"></MenuItem>
</ContextMenu>
</ListBox>
</StackPanel>
</Grid>
<Grid ColumnDefinitions="*,3*">
<Label Content="Alternativbezeichnungen"></Label>
<StackPanel Grid.Column="1" Orientation="Vertical">
<Grid ColumnDefinitions="*,50">
<TextBox Grid.Column="0" Height="35" HorizontalAlignment="Stretch" x:Name="TbSportAlternativeName" TextChanged="TbStudentID_OnTextChanged"></TextBox>
<Button Grid.Column="1" Margin="0,10,0,0" x:Name="BtnAlternativeNameAdd" VerticalAlignment="Top" Height="35" HorizontalAlignment="Stretch" Click="BtnImportDefaultCourses_OnClick" HorizontalContentAlignment="Center">
<StackPanel Orientation="Horizontal">
<LucideIcon Kind="Plus" Width="24" Height="24" />
</StackPanel>
</Button>
</Grid>
<ListBox x:Name="LbAlternativeNames">
<ContextMenu>
<MenuItem x:Name="MnuAlternativeNameDelete" Header="Entfernen"></MenuItem>
</ContextMenu>
</ListBox>
</StackPanel>
</Grid>
</StackPanel>
</Grid>
</TabItem>

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
@@ -171,9 +172,6 @@ public partial class MainWindow : Window
try
{
((Student)LbStudentsImported.SelectedItem).Name = TbStudentName.Text;
//int current = LbStudentsImported.SelectedIndex;
//RefreshImportedStudentList();
//LbStudentsImported.SelectedIndex = current;
}
catch
{
@@ -185,13 +183,54 @@ public partial class MainWindow : Window
try
{
((Student)LbStudentsImported.SelectedItem).Name = TbStudentID.Text;
//int current = LbStudentsImported.SelectedIndex;
//RefreshImportedStudentList();
//LbStudentsImported.SelectedIndex = current;
}
catch
{
}
}
private void BtnImportDefaultCourses_OnClick(object? sender, RoutedEventArgs e)
{
Settings.ImportInitial();
RefreshCoursesList();
}
private void RefreshCoursesList()
{
LbSportCourses.Items.Clear();
foreach (var sp in Settings.Instance.Sports)
{
LbSportCourses.Items.Add(sp);
}
}
private void LbSportCourses_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
if (LbSportCourses.SelectedItem != null)
{
if (LbSportCourses.SelectedItem is Sport item)
{
LblSportID.Content = item.ID;
TbSportName.Text = item.Name;
NudSportMaxStudents.Value = item.MaxStudents;
NudSportMinStudents.Value = item.MinStudents;
NudAmountCoursesSem1.Value = item.Semester[0];
NudAmountCoursesSem2.Value = item.Semester[1];
NudAmountCoursesSem3.Value = item.Semester[2];
NudAmountCoursesSem4.Value = item.Semester[3];
LbAlternativeCourses.Items.Clear();
foreach (var alternative in item.AlternativeCourses)
{
LbAlternativeCourses.Items.Add(Settings.GetSportNameFromID(alternative));
}
LbAlternativeNames.Items.Clear();
foreach (var alternative in item.AlternativeNames)
{
LbAlternativeNames.Items.Add(alternative);
}
}
}
}
}

View File

@@ -1,32 +1,56 @@
using System.Collections.Generic;
using Avalonia.Data;
namespace spplus;
public class Sport
{
public int ID { get; set; } = 0;
public string Name { get; set; } = "Neuer Kurs"; // Kursname
public int MaxCoursesPerSemester { get; set; } = 1; // Maximale Anzahl an Kursen pro Semester
public int MaxStudents { get; set; } = 20; // Maximale Anzahl an Schülern pro Kurs
public int MaxStudents { get; set; } = 25; // Maximale Anzahl an Schülern pro Kurs
public int MinStudents { get; set; } = 5; // Minimale Anzahl an Schülern pro Kurs
public int[] Semester { get; set; } = [1, 2, 3, 4]; // Angebot in diesen Semestern
public int[] Semester { get; set; } = [2, 2, 2, 2]; // Maximale Anzahl an Angeboten in den jeweiligen Index-Semestern (0 => 1. Semester)
public List<string> AlternativeNames { get; set; } = new();
public List<int> AlternativeCourses { get; set; } = new();
protected Sport()
{
}
protected Sport(string name)
public Sport(string name)
{
Name = name;
}
protected Sport(string name, int maxCoursesPerSemester, int maxStudents, int minStudents, int[] semester)
public Sport(string name, int maxCoursesPerSemester, int maxStudents, int minStudents, int[] semester, List<string> alternativeNames)
{
Name = name;
MaxCoursesPerSemester = maxCoursesPerSemester;
MaxStudents = maxStudents;
MinStudents = minStudents;
Semester = semester;
AlternativeNames = alternativeNames;
}
public void AddAlternativeSport(int id)
{
AlternativeCourses.Add(id);
}
public void ClearAlternativeSport()
{
AlternativeCourses.Clear();
}
public override string ToString()
{
var alt = "";
foreach (var s in AlternativeNames)
{
alt += s + ", ";
}
return $"{Name} ({alt})";
}
}
@@ -62,6 +86,7 @@ public class Settings
public List<Student> Students { get; set; } = [];
public List<Sport> Sports { get; set; } = [];
public int NumCoursesPerSemester { get; set; } = 10;
public Settings()
{
@@ -72,4 +97,34 @@ public class Settings
{
// Hier importieren...
}
public static void ImportInitial()
{
Instance.Sports.Add(new Sport("Tischtennis"){ AlternativeNames = {"Sport_TT"}});
Instance.Sports.Add(new Sport("Badminton"){ AlternativeNames = {"Sport_BM"}});
Instance.Sports.Add(new Sport("Gynmastik/Tanz"){ AlternativeNames = {"Sport_Gym"}});
Instance.Sports.Add(new Sport("Schwimmen"){ AlternativeNames = {"Sport_SW"}, Semester = [1, 1, 1, 1], MaxStudents = 18});
Instance.Sports.Add(new Sport("Bouldern"){ AlternativeNames = {"Sport_BO"}, Semester = [1, 1, 1, 1]});
Instance.Sports.Add(new Sport("Basketball"){ AlternativeNames = {"Sport_BS"}});
Instance.Sports.Add(new Sport("Fitness"){ AlternativeNames = {"Sport_Fit"}});
Instance.Sports.Add(new Sport("Fußball"){ AlternativeNames = {"Sport_Fuß"}, Semester = [1, 0, 1, 0]});
Instance.Sports.Add(new Sport("Handball"){ AlternativeNames = {"Sport_HB"}});
Instance.Sports.Add(new Sport("Leichtathletik"){ AlternativeNames = {"Sport_LA"}, Semester = [1, 0, 1, 0], MaxStudents = 18});
Instance.Sports.Add(new Sport("Tennis"){ AlternativeNames = {"Sport_Te"}});
Instance.Sports.Add(new Sport("Turnen"){ AlternativeNames = {"Sport_Tur"}});
Instance.Sports.Add(new Sport("Volleyball"){ AlternativeNames = {"Sport_VB"}});
}
public static string? GetSportNameFromID(int id)
{
foreach (var s in Instance.Sports)
{
if (s.ID == id)
{
return s.Name;
}
}
return null;
}
}