using System; using System.Collections.Generic; using System.Diagnostics; using Avalonia.Controls; using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Platform.Storage; namespace spplus; public partial class MainWindow : Window { public static MainWindow Instance { get; set; } public static string ApplicationVersion = "v1.1.17"; public MainWindow() { InitializeComponent(); Settings.ImportInitial(); Instance = this; RefreshCoursesList(); try { NudSportMaxPerSemester.Value = Settings.Instance.NumCoursesPerSemester; } catch {} } private void MnuExpSettings_OnClick(object? sender, RoutedEventArgs e) { var res = MessageBox.Show(this, "Dieses Feature ist noch nicht implementiert", "Fehlend"); } private void MnuExit_OnClick(object? sender, RoutedEventArgs e) { Environment.Exit(0); } private void MnuHelp_OnClick(object? sender, RoutedEventArgs e) { try { Process.Start(new ProcessStartInfo { FileName = "https://git.mypapercloud.de/fierke/spplus/wiki", UseShellExecute = true }); } catch (Exception ex) { Console.WriteLine($"Fehler beim Öffnen des Links: {ex.Message}"); } } private void MnuGit_OnClick(object? sender, RoutedEventArgs e) { try { Process.Start(new ProcessStartInfo { FileName = "https://git.mypapercloud.de/fierke/spplus", UseShellExecute = true }); } catch (Exception ex) { Console.WriteLine($"Fehler beim Öffnen des Links: {ex.Message}"); } } private void MnuAbout_OnClick(object? sender, RoutedEventArgs e) { Window w = new(); w.WindowState = WindowState.Normal; w.WindowStartupLocation = WindowStartupLocation.CenterScreen; w.Width = 300; w.Height = 120; Grid g = new(); TextBlock tb = new() { Text = $"spplus {MainWindow.ApplicationVersion}\n(c)2026 MyPapertown, Elias Fierke" }; g.Children.Add(tb); w.Content = g; w.Show(); } private async void BtnImport_OnClick(object? sender, RoutedEventArgs e) { 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; if (file.Count == 0) 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(); List<(Sport, List)> initial_sportlist = new(); foreach (var sp in Settings.Instance.Sports) { initial_sportlist.Add((sp, new())); } foreach (Student s in Settings.Instance.Students) { foreach (var sp in s.SelectedCourseNames) { foreach (var item in initial_sportlist) { if (item.Item1.AlternativeNames.Contains(sp)) { item.Item2.Add(s.ID); break; } } } } LblNumVoted.Content = ""; foreach (var s in initial_sportlist) { LblNumVoted.Content += $"{s.Item1.Name}: {s.Item2.Count}\n"; } } private void BtnCraftCourses_OnClick(object? sender, RoutedEventArgs e) { CourseCrafter.Craft(); RefreshResultView(); TclMainView.SelectedIndex = 2; //TbiResults.Focus(); } private void RefreshResultView() { LbResult.Items.Clear(); foreach (Student s in Settings.Instance.Students) { try { for(int i = 0; i