diff --git a/MainWindow.axaml b/MainWindow.axaml index 1e2e1c2..6b18d6b 100644 --- a/MainWindow.axaml +++ b/MainWindow.axaml @@ -28,8 +28,8 @@ - - + + - + - + - + - - + + - + + + + + + - + - + - + + + + + + + + + + + diff --git a/MainWindow.axaml.cs b/MainWindow.axaml.cs index 3bc4416..a76b6a8 100644 --- a/MainWindow.axaml.cs +++ b/MainWindow.axaml.cs @@ -103,14 +103,95 @@ public partial class MainWindow : Window 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) { // 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 + { + + } + } } \ No newline at end of file