Skip to content

Commit

Permalink
保存课程表时自动排序
Browse files Browse the repository at this point in the history
  • Loading branch information
STBBRD committed Sep 21, 2024
1 parent 674e492 commit 1626c89
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ZongziTEK_Blackboard_Sticker/Classes/Timetable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ public string ToCurriculums(List<Lesson> list)
}
return curriculums;
}

public void Sort(Timetable timetable)
{
foreach (List<Lesson> day in new[] { timetable.Monday, timetable.Tuesday, timetable.Wednesday, timetable.Thursday, timetable.Friday, timetable.Saturday, timetable.Sunday, timetable.Temp })
{
day.Sort((x, y) => x.StartTime.CompareTo(y.StartTime));
}
}
}

public class Lesson
Expand Down
2 changes: 1 addition & 1 deletion ZongziTEK_Blackboard_Sticker/TimetableEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<Button Style="{StaticResource AccentButtonStyle}" Height="32" HorizontalAlignment="Right" Click="ButtonSave_Click">
<ikw:SimpleStackPanel Orientation="Horizontal" Spacing="8">
<ui:FontIcon Icon="{x:Static ui:FluentSystemIcons.Save_20_Regular}"/>
<TextBlock Text="保存"/>
<TextBlock Text="保存并排序"/>
</ikw:SimpleStackPanel>
</Button>
</Grid>
Expand Down
4 changes: 4 additions & 0 deletions ZongziTEK_Blackboard_Sticker/TimetableEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs

private void ButtonSave_Click(object sender, RoutedEventArgs e)
{
Timetable.Sort(Timetable);

string text = JsonConvert.SerializeObject(Timetable, Formatting.Indented);
try
{
Expand All @@ -75,6 +77,8 @@ private void ButtonSave_Click(object sender, RoutedEventArgs e)
catch { }
isEdited = false;

LoadTimetable();

//isCloseWithoutWarning = true;
//Close();
}
Expand Down

0 comments on commit 1626c89

Please sign in to comment.