Compare commits
7 Commits
e27a6b88d4
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1b07d0e2ab | |||
| 6a08694753 | |||
| fabefabe0f | |||
| a572fdf72b | |||
| a855f0664a | |||
| f8f5140d47 | |||
| e9c7b61ced |
@@ -28,8 +28,8 @@
|
|||||||
<Label FontSize="20" Content="Planung" VerticalContentAlignment="Center" />
|
<Label FontSize="20" Content="Planung" VerticalContentAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</TabItem.Header>
|
</TabItem.Header>
|
||||||
<Grid ColumnDefinitions="*,2*">
|
<Grid ColumnDefinitions="*,2*" RowDefinitions="*,*">
|
||||||
<Button Margin="0,10,0,0" x:Name="BtnImport" VerticalAlignment="Top" Height="50" HorizontalAlignment="Stretch" Click="BtnImport_OnClick" HorizontalContentAlignment="Center">
|
<Button Grid.RowSpan="2" Margin="0,10,0,0" x:Name="BtnImport" VerticalAlignment="Top" Height="50" HorizontalAlignment="Stretch" Click="BtnImport_OnClick" HorizontalContentAlignment="Center">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<LucideIcon Kind="Import" Width="36" Height="36" />
|
<LucideIcon Kind="Import" Width="36" Height="36" />
|
||||||
<Label Content="Importieren..." VerticalContentAlignment="Center" FontSize="15"
|
<Label Content="Importieren..." VerticalContentAlignment="Center" FontSize="15"
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button Margin="0,00,0,10" x:Name="BtnCraftCourses" VerticalAlignment="Bottom" Height="50" HorizontalAlignment="Stretch" Click="BtnCraftCourses_OnClick" HorizontalContentAlignment="Center">
|
<Button Grid.RowSpan="2" Margin="0,00,0,10" x:Name="BtnCraftCourses" VerticalAlignment="Bottom" Height="50" HorizontalAlignment="Stretch" Click="BtnCraftCourses_OnClick" HorizontalContentAlignment="Center">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<LucideIcon Kind="Pickaxe" Width="36" Height="36" />
|
<LucideIcon Kind="Pickaxe" Width="36" Height="36" />
|
||||||
<Label Content="Kurse basteln" VerticalContentAlignment="Center" FontSize="15"
|
<Label Content="Kurse basteln" VerticalContentAlignment="Center" FontSize="15"
|
||||||
@@ -45,34 +45,49 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<ListBox Margin="0,70,0,70" Background="MintCream" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"></ListBox>
|
<ListBox Grid.RowSpan="2" x:Name="LbStudentsImported" SelectionChanged="LbStudentsImported_OnSelectionChanged" Margin="0,70,0,70" Background="MintCream" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"></ListBox>
|
||||||
|
|
||||||
<StackPanel Grid.Column="1" Margin="10,10,10,10" Orientation="Vertical" Spacing="10">
|
<StackPanel Grid.Column="1" Grid.Row="0" Margin="10,10,10,10" Orientation="Vertical" Spacing="10">
|
||||||
<Grid ColumnDefinitions="*,3*">
|
<Grid ColumnDefinitions="*,3*">
|
||||||
<Label Content="Name"></Label>
|
<Label Content="ID"></Label>
|
||||||
<TextBox Grid.Column="1" x:Name="TbStudentName"></TextBox>
|
<TextBox Grid.Column="1" x:Name="TbStudentID" TextChanged="TbStudentID_OnTextChanged"></TextBox>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid ColumnDefinitions="*,2*">
|
<Grid ColumnDefinitions="*,3*">
|
||||||
|
<Label Content="Name"></Label>
|
||||||
|
<TextBox Grid.Column="1" x:Name="TbStudentName" TextChanged="TbStudentName_OnTextChanged"></TextBox>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid ColumnDefinitions="*,3*">
|
||||||
<Label Content="Sport 1"></Label>
|
<Label Content="Sport 1"></Label>
|
||||||
<Label Grid.Column="1" x:Name="LblSport1"></Label>
|
<Label Grid.Column="1" x:Name="LblSport1"></Label>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid ColumnDefinitions="*,2*">
|
<Grid ColumnDefinitions="*,3*">
|
||||||
<Label Content="Sport 2"></Label>
|
<Label Content="Sport 2"></Label>
|
||||||
<Label Grid.Column="1" x:Name="LblSport2"></Label>
|
<Label Grid.Column="1" x:Name="LblSport2"></Label>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid ColumnDefinitions="*,2*">
|
<Grid ColumnDefinitions="*,3*">
|
||||||
<Label Content="Sport 3"></Label>
|
<Label Content="Sport 3"></Label>
|
||||||
<Label Grid.Column="1" x:Name="LblSport3"></Label>
|
<Label Grid.Column="1" x:Name="LblSport3"></Label>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid ColumnDefinitions="*,2*">
|
<Grid ColumnDefinitions="*,3*">
|
||||||
<Label Content="Sport 4"></Label>
|
<Label Content="Sport 4"></Label>
|
||||||
<Label Grid.Column="1" x:Name="LblSport4"></Label>
|
<Label Grid.Column="1" x:Name="LblSport4"></Label>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Column="1" Grid.Row="1" Margin="10,10,10,10" Orientation="Vertical" Spacing="10">
|
||||||
|
<Grid ColumnDefinitions="*,3*">
|
||||||
|
<Label Content="Anzahl Einträge"></Label>
|
||||||
|
<Label Grid.Column="1" x:Name="LblStudentAmount"></Label>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid ColumnDefinitions="*,3*">
|
||||||
|
<Label Content="Anzahl gewählte Kurse"></Label>
|
||||||
|
<Label Grid.Column="1" x:Name="LblSelectedAmount"></Label>
|
||||||
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Platform.Storage;
|
||||||
|
|
||||||
namespace spplus;
|
namespace spplus;
|
||||||
|
|
||||||
@@ -57,21 +59,139 @@ public partial class MainWindow : Window
|
|||||||
private void MnuAbout_OnClick(object? sender, RoutedEventArgs e)
|
private void MnuAbout_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Window w = new();
|
Window w = new();
|
||||||
|
w.WindowState = WindowState.Normal;
|
||||||
|
w.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||||
|
w.Width = 300;
|
||||||
|
w.Height = 120;
|
||||||
Grid g = new();
|
Grid g = new();
|
||||||
TextBlock tb = new();
|
TextBlock tb = new()
|
||||||
tb.Text = "Spplus v1.0.0\n(c)2026 MyPapertown, Elias Fierke";
|
{
|
||||||
|
Text = "spplus v1.0.0\n(c)2026 MyPapertown, Elias Fierke"
|
||||||
|
};
|
||||||
g.Children.Add(tb);
|
g.Children.Add(tb);
|
||||||
w.Content = g;
|
w.Content = g;
|
||||||
w.Show();
|
w.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnImport_OnClick(object? sender, RoutedEventArgs e)
|
private async void BtnImport_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// CSV Import
|
var topLevel = GetTopLevel(this);
|
||||||
|
var file = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||||
|
{
|
||||||
|
Title = "CSV-Datei auswählen",
|
||||||
|
AllowMultiple = false,
|
||||||
|
FileTypeFilter = new[]
|
||||||
|
{
|
||||||
|
new FilePickerFileType(".csv-Datei")
|
||||||
|
{
|
||||||
|
Patterns = new[] { "*.csv" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (file == null) return;
|
||||||
|
|
||||||
|
var imported_students = import.ImportStudentsFromFile(file[0].Path.LocalPath.ToString());
|
||||||
|
foreach (var s in imported_students)
|
||||||
|
{
|
||||||
|
Settings.Instance.Students.Add(s);
|
||||||
|
}
|
||||||
|
RefreshImportedStudentList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshImportedStudentList()
|
||||||
|
{
|
||||||
|
LbStudentsImported.Items.Clear();
|
||||||
|
int count_selected = 0;
|
||||||
|
foreach (var s in Settings.Instance.Students)
|
||||||
|
{
|
||||||
|
LbStudentsImported.Items.Add(s);
|
||||||
|
count_selected += s.SelectedCourseNames.Count;
|
||||||
|
}
|
||||||
|
LblStudentAmount.Content = Settings.Instance.Students.Count.ToString();
|
||||||
|
LblSelectedAmount.Content = count_selected.ToString();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnCraftCourses_OnClick(object? sender, RoutedEventArgs e)
|
private void BtnCraftCourses_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// Craft courses here / call course-crafter
|
// Craft courses here / call course-crafter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LbStudentsImported_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
Prepare();
|
||||||
|
var stud = (Student)LbStudentsImported.SelectedItem;
|
||||||
|
if (stud == null)
|
||||||
|
{
|
||||||
|
TbStudentName.Text = string.Empty;
|
||||||
|
TbStudentID.Text = string.Empty;
|
||||||
|
SetEmpty();
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
TbStudentName.Text = stud.Name;
|
||||||
|
TbStudentID.Text = stud.ID;
|
||||||
|
LblSport1.Content = stud.SelectedCourseNames[0];
|
||||||
|
LblSport2.Content = stud.SelectedCourseNames[1];
|
||||||
|
LblSport3.Content = stud.SelectedCourseNames[2];
|
||||||
|
LblSport4.Content = stud.SelectedCourseNames[3];
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
SetEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
void SetEmpty()
|
||||||
|
{
|
||||||
|
if(LblSport1.Content == "null") LblSport1.Content = "ungewählt";
|
||||||
|
if(LblSport2.Content == "null") LblSport2.Content = "ungewählt";
|
||||||
|
if(LblSport3.Content == "null") LblSport3.Content = "ungewählt";
|
||||||
|
if(LblSport4.Content == "null") LblSport4.Content = "ungewählt";
|
||||||
|
}
|
||||||
|
|
||||||
|
void Prepare()
|
||||||
|
{
|
||||||
|
LblSport1.Content = "null";
|
||||||
|
LblSport2.Content = "null";
|
||||||
|
LblSport3.Content = "null";
|
||||||
|
LblSport4.Content = "null";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TbStudentName_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
((Student)LbStudentsImported.SelectedItem).Name = TbStudentName.Text;
|
||||||
|
//int current = LbStudentsImported.SelectedIndex;
|
||||||
|
//RefreshImportedStudentList();
|
||||||
|
//LbStudentsImported.SelectedIndex = current;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void TbStudentID_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
((Student)LbStudentsImported.SelectedItem).Name = TbStudentID.Text;
|
||||||
|
//int current = LbStudentsImported.SelectedIndex;
|
||||||
|
//RefreshImportedStudentList();
|
||||||
|
//LbStudentsImported.SelectedIndex = current;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
50
import.cs
Normal file
50
import.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace spplus;
|
||||||
|
|
||||||
|
public static class import
|
||||||
|
{
|
||||||
|
public static List<Student> ImportStudentsFromFile(string path)
|
||||||
|
{
|
||||||
|
var dict = new Dictionary<string, (string Name, List<string> Courses)>();
|
||||||
|
|
||||||
|
foreach (var line in File.ReadLines(path).Skip(1)) // Header überspringen
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(line))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var parts = line.Split(',');
|
||||||
|
if (parts.Length < 3)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string nameWithId = parts[0].Trim();
|
||||||
|
string course = parts[2].Replace("(2)", "").Replace("(3)", "").Replace("(4)", "").Trim();
|
||||||
|
|
||||||
|
int open = nameWithId.LastIndexOf('(');
|
||||||
|
int close = nameWithId.LastIndexOf(')');
|
||||||
|
if (open < 0 || close < 0 || close <= open)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string name = nameWithId[..open].Trim();
|
||||||
|
string id = nameWithId[(open + 1)..close].Trim();
|
||||||
|
|
||||||
|
if (!dict.ContainsKey(id))
|
||||||
|
dict[id] = (name, new List<string>());
|
||||||
|
|
||||||
|
dict[id].Courses.Add(course);
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = new List<Student>();
|
||||||
|
|
||||||
|
foreach (var (id, data) in dict)
|
||||||
|
{
|
||||||
|
var student = new Student(id, data.Name, data.Courses);
|
||||||
|
result.Add(student);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
20
structs.cs
20
structs.cs
@@ -2,7 +2,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace spplus;
|
namespace spplus;
|
||||||
|
|
||||||
public abstract class Sport
|
public class Sport
|
||||||
{
|
{
|
||||||
public string Name { get; set; } = "Neuer Kurs"; // Kursname
|
public string Name { get; set; } = "Neuer Kurs"; // Kursname
|
||||||
public int MaxCoursesPerSemester { get; set; } = 1; // Maximale Anzahl an Kursen pro Semester
|
public int MaxCoursesPerSemester { get; set; } = 1; // Maximale Anzahl an Kursen pro Semester
|
||||||
@@ -30,21 +30,29 @@ public abstract class Sport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class Student
|
public class Student
|
||||||
{
|
{
|
||||||
public string Name { get; set; } = ""; // Name des Schülers
|
public string ID { get; set; } = ""; // ID des Schüler (z.B. NolteSeb)
|
||||||
|
public string Name { get; set; } = ""; // Name des Schülers
|
||||||
public Sport[] SelectedCourses { get; set; } = new Sport[4]; // Kurswahl
|
public Sport[] SelectedCourses { get; set; } = new Sport[4]; // Kurswahl
|
||||||
|
public List<string> SelectedCourseNames { get; set; } = new();
|
||||||
public List<string>? Result { get; set; } = null;
|
public List<string>? Result { get; set; } = null;
|
||||||
|
|
||||||
protected Student()
|
public Student()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Student(string name, Sport[] selectedCourses)
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
return $"{Name} ({ID})";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Student(string id, string name, List<string> selectedCoursesNames)
|
||||||
|
{
|
||||||
|
ID = id;
|
||||||
Name = name;
|
Name = name;
|
||||||
SelectedCourses = selectedCourses;
|
SelectedCourseNames = selectedCoursesNames;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user