Skip to content

Commit

Permalink
完成 #8
Browse files Browse the repository at this point in the history
  • Loading branch information
STBBRD committed Nov 19, 2023
1 parent c871191 commit 0028c46
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 30 deletions.
13 changes: 10 additions & 3 deletions ZongziTEK_Blackboard_Sticker/Classes/Timetable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ public class Timetable
public string ToCurriculums(List<Lesson> list)
{
string curriculums = "";
foreach (Lesson lesson in list)
if (list.Count > 0)
{
curriculums += lesson.Subject + "\n";
foreach (Lesson lesson in list)
{
curriculums += lesson.Subject + "\n";
}
if (curriculums.Length > 0) curriculums = curriculums.Remove(curriculums.Length - 1);
}
else
{
curriculums = "无课程";
}
if (curriculums.Length > 0) curriculums = curriculums.Remove(curriculums.Length - 1);
return curriculums;
}
}
Expand Down
6 changes: 3 additions & 3 deletions ZongziTEK_Blackboard_Sticker/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@
<ScrollViewer Name="ScrollViewerShowingCurriculum" PanningMode="VerticalOnly" Margin="8">
<TextBlock x:Name="textBlockCurriculum" TextWrapping="Wrap"
Text="语文&#10;数学&#10;英语&#10;物理&#10;化学&#10;生物&#10;历史&#10;政治&#10;地理&#10;活动&#10;体育"
FontSize="28" Foreground="{DynamicResource ForegroundColor}" TextAlignment="Center"
SizeChanged="textBlockCurriculum_SizeChanged"/>
FontSize="28" Foreground="{DynamicResource ForegroundColor}" TextAlignment="Center" SizeChanged="textBlockCurriculum_SizeChanged"/>
</ScrollViewer>
</StackPanel>
<ScrollViewer x:Name="scrollViewerCurriculum" Grid.Row="0" Grid.Column="1" Visibility="Collapsed" PanningMode="VerticalOnly">
Expand Down Expand Up @@ -197,9 +196,10 @@
<GroupBox Header="课程表" Foreground="{DynamicResource ForegroundColor}">
<ui:SimpleStackPanel Spacing="12">
<ui:ToggleSwitch Name="ToggleSwitchUseTimetable" Header="使用带时间信息的课程表" OnContent="" OffContent="" IsOn="True" Toggled="ToggleSwitchUseTimetable_Toggled" Foreground="{DynamicResource ForegroundColor}"/>
<TextBlock Text="开启上面的开关后,将使用带时间信息的课程表,并且出现上下课提醒功能。关闭上面的开关后,课程表就是文本信息,方便编辑,但没有上下课提醒。"
<TextBlock Text="开启上面的开关后,将使用带时间信息的课程表,并且出现上下课提醒功能。关闭上面的开关后,课程表就是文本信息,方便编辑,但没有上下课提醒。&#10;暂不支持在不使用带时间信息的课程表时使用临时课表。"
TextWrapping="Wrap" Opacity="0.75"/>
<ui:ToggleSwitch Name="ToggleSwitchTimetableNotification" Header="启用上下课提醒" OnContent="" OffContent="" IsOn="True" Toggled="ToggleSwitchTimetableNotification_Toggled" Foreground="{DynamicResource ForegroundColor}"/>
<ui:ToggleSwitch Name="ToggleSwitchTempTimetable" Header="展示临时课表" OnContent="" OffContent="" IsOn="False" Toggled="ToggleSwitchTempTimetable_Toggled" Foreground="{DynamicResource ForegroundColor}" IsEnabled="{Binding IsOn, ElementName=ToggleSwitchUseTimetable}"/>
<ui:ToggleSwitch Name="ToggleSwitchUseDefaultBNSPath" Header="使用默认黑板通知服务路径" OnContent="" OffContent="" IsOn="True" Toggled="ToggleSwitchUseDefaultBNSPath_Toggled" Foreground="{DynamicResource ForegroundColor}"/>
<TextBlock Text="黑板通知服务路径" FontSize="14"/>
<TextBox Name="TextBoxBNSPath" TextChanged="TextBoxBNSPath_TextChanged" Foreground="{DynamicResource ForegroundColor}" IsEnabled="{Binding IsOn, ElementName=ToggleSwitchUseDefaultBNSPath,Converter={StaticResource InverseBooleanConverter}}"/>
Expand Down
56 changes: 34 additions & 22 deletions ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,11 @@ private void EditorButtonSettingUseCurriculum()
ToggleSwitchUseTimetable.IsOn = false;
}

private void ToggleSwitchTempTimetable_Toggled(object sender, RoutedEventArgs e)
{
LoadTimetableorCurriculum();
}

#region Curriculum
public static Curriculums Curriculums = new Curriculums();
public static string curriculumsFileName = "Curriculums.json";
Expand Down Expand Up @@ -824,29 +829,36 @@ private void LoadTimetable()

string day = DateTime.Today.DayOfWeek.ToString();

switch (day)
if (!ToggleSwitchTempTimetable.IsOn)
{
case "Monday":
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Monday);
break;
case "Tuesday":
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Tuesday);
break;
case "Wednesday":
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Wednesday);
break;
case "Thursday":
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Thursday);
break;
case "Friday":
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Friday);
break;
case "Saturday":
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Saturday);
break;
case "Sunday":
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Sunday);
break;
switch (day)
{
case "Monday":
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Monday);
break;
case "Tuesday":
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Tuesday);
break;
case "Wednesday":
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Wednesday);
break;
case "Thursday":
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Thursday);
break;
case "Friday":
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Friday);
break;
case "Saturday":
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Saturday);
break;
case "Sunday":
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Sunday);
break;
}
}
else
{
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Temp);
}
}
private int lessonIndex = -1;
Expand Down
1 change: 1 addition & 0 deletions ZongziTEK_Blackboard_Sticker/TimetableEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<TextBlock Text="当前编辑的是: " FontSize="16"/>
<TextBlock FontSize="16" Text="{Binding SelectedItem.Content, ElementName=ComboBoxDay}"/>
<TextBlock Text="课表" FontSize="16"/>
<TextBlock Name="TextBlockHintTempTimetable" Text=",如需展示临时课表,请前往 设置→课程表" FontSize="16" Visibility="Collapsed"/>
</StackPanel>
<Border Height="48" Background="#FFFBFBFB" CornerRadius="2" BorderBrush="#FFE1E6EA" BorderThickness="1" Grid.Row="1">
<Grid>
Expand Down
12 changes: 10 additions & 2 deletions ZongziTEK_Blackboard_Sticker/TimetableEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ private void ButtonUseCurriculum_Click(object sender, RoutedEventArgs e)
private void ComboBoxDay_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
LoadTimetable();
if (ComboBoxDay.SelectedIndex == 7)
{
TextBlockHintTempTimetable.Visibility = Visibility.Visible;
}
else
{
TextBlockHintTempTimetable.Visibility = Visibility.Collapsed;
}
}

private void Item_LessonInfoChanged(object sender, EventArgs e)
Expand All @@ -100,7 +108,7 @@ private void Item_LessonInfoChanged(object sender, EventArgs e)

private void Item_LessonDeleting(object sender, EventArgs e)
{
if(sender is TimetableEditorItem)
if (sender is TimetableEditorItem)
{
TimetableEditorItem itemToDelete = sender as TimetableEditorItem;
int index = ListStackPanel.Children.IndexOf(itemToDelete);
Expand All @@ -115,7 +123,7 @@ private void ButtonInsertLesson_Click(object sender, RoutedEventArgs e)
TimetableEditorItem item = new TimetableEditorItem();
item.LessonInfoChanged += Item_LessonInfoChanged;
item.LessonDeleting += Item_LessonDeleting;
GetSelectedDay().Add(new Lesson("",new TimeSpan(0,0,0),new TimeSpan(0,0,0)));
GetSelectedDay().Add(new Lesson("", new TimeSpan(0, 0, 0), new TimeSpan(0, 0, 0)));
ListStackPanel.Children.Add(item);
}
#endregion
Expand Down

0 comments on commit 0028c46

Please sign in to comment.