From b3e8c7ee5e7013c7f242e91d7a5d46c49dbd7847 Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Fri, 27 Feb 2026 11:07:13 +0100 Subject: [PATCH] [chore:] implemented button handlers for course view and gui refresh functions --- MainWindow.axaml.cs | 51 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/MainWindow.axaml.cs b/MainWindow.axaml.cs index a76b6a8..efe4d9e 100644 --- a/MainWindow.axaml.cs +++ b/MainWindow.axaml.cs @@ -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); + } + } + } + } } \ No newline at end of file