Skip to content

Commit

Permalink
Timetable已经可用,完成上下课提醒功能设置项
Browse files Browse the repository at this point in the history
  • Loading branch information
STBBRD committed Nov 12, 2023
1 parent 00cffff commit 4cb5a59
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 25 deletions.
4 changes: 2 additions & 2 deletions ZongziTEK_Blackboard_Sticker/Classes/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class Look

public class TimetableSettings
{
public bool useTimetable { get; set; } = true;
public bool enableTimetableNotification { get; set; } = true;
public bool isTimetableEnabled { get; set; } = true;
public bool isTimetableNotificationEnabled { get; set; } = true;
public bool useDefaultBNSPath = true;
public string BNSPath { get; set; } = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
}
Expand Down
69 changes: 46 additions & 23 deletions ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ protected override void DrawCore(DrawingContext drawingContext,
#region Timetable & Curriculum
private void LoadTimetableorCurriculum()
{
if (Settings.TimetableSettings.useTimetable)
if (Settings.TimetableSettings.isTimetableEnabled)
{
LoadTimetable();
}
Expand Down Expand Up @@ -774,7 +774,7 @@ private void LoadCurriculum()

private void editCurriculumButton_Click(object sender, RoutedEventArgs e)
{
if (Settings.TimetableSettings.useTimetable)
if (Settings.TimetableSettings.isTimetableEnabled)
{
new TimetableEditor().ShowDialog();
LoadTimetableorCurriculum();
Expand Down Expand Up @@ -910,32 +910,41 @@ private void CheckTimetable(object sender, EventArgs e)

private void ShowClassBeginPreNotification(List<Lesson> today, int index)
{
int nextLessonIndex = index + 1;
if (Settings.TimetableSettings.isTimetableNotificationEnabled)
{
int nextLessonIndex = index + 1;

string startTimeString = today[nextLessonIndex].StartTime.ToString(@"hh\:mm");
string endTimeString = today[nextLessonIndex].EndTime.ToString(@"hh\:mm");
string startTimeString = today[nextLessonIndex].StartTime.ToString(@"hh\:mm");
string endTimeString = today[nextLessonIndex].EndTime.ToString(@"hh\:mm");

string title = today[nextLessonIndex].Subject + "课 即将开始";
string subtitle = "此课程将从 " + startTimeString + " 开始,到 " + endTimeString + " 结束";
string title = today[nextLessonIndex].Subject + "课 即将开始";
string subtitle = "此课程将从 " + startTimeString + " 开始,到 " + endTimeString + " 结束";

ShowNotificationBNS(title, subtitle, 3, false);
ShowNotificationBNS(title, subtitle, 3, false);
}
}

private void ShowClassOverNotification(List<Lesson> today, int index)
{
int nextLessonIndex = index + 1;
if (Settings.TimetableSettings.isTimetableNotificationEnabled)
{
int nextLessonIndex = index + 1;

string startTimeString = today[nextLessonIndex].StartTime.ToString(@"hh\:mm");
string startTimeString = today[nextLessonIndex].StartTime.ToString(@"hh\:mm");

string title = "下一节 " + today[nextLessonIndex].Subject + "课";
string subtitle = "课堂结束,下一节课将于 " + startTimeString + " 开始";
string title = "下一节 " + today[nextLessonIndex].Subject + "课";
string subtitle = "课堂结束,下一节课将于 " + startTimeString + " 开始";

ShowNotificationBNS(title, subtitle, 3, false);
ShowNotificationBNS(title, subtitle, 3, false);
}
}

private void ShowLastClassOverNotification()
{
ShowNotificationBNS("课堂结束", "这是最后一节课", 2, false);
if (Settings.TimetableSettings.isTimetableNotificationEnabled)
{
ShowNotificationBNS("课堂结束", "这是最后一节课", 3, false);
}
}
#endregion
#endregion
Expand Down Expand Up @@ -1216,28 +1225,31 @@ private void ButtonDataLocation_Click(object sender, RoutedEventArgs e)
private void ToggleSwitchUseTimetable_Toggled(object sender, RoutedEventArgs e)
{
if (!isSettingsLoaded) return;
Settings.TimetableSettings.useTimetable = ToggleSwitchUseTimetable.IsOn;
Settings.TimetableSettings.isTimetableEnabled = ToggleSwitchUseTimetable.IsOn;
LoadTimetableorCurriculum();
SaveSettings();
}

private void ToggleSwitchTimetableNotification_Toggled(object sender, RoutedEventArgs e)
{
/*if (!isSettingsLoaded) return;
Settings.TimetableSettings.enableTimetableNotification = ToggleSwitchTimetableNotification.IsOn;
SaveSettings();*/
if (!isSettingsLoaded) return;
Settings.TimetableSettings.isTimetableNotificationEnabled = ToggleSwitchTimetableNotification.IsOn;
SaveSettings();
}

private void ToggleSwitchUseDefaultBNSPath_Toggled(object sender, RoutedEventArgs e)
{
if (!isSettingsLoaded) return;
Settings.TimetableSettings.useDefaultBNSPath = ToggleSwitchUseDefaultBNSPath.IsOn;
TextBoxBNSPath.Text = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
SaveSettings();
}

private void TextBoxBNSPath_TextChanged(object sender, TextChangedEventArgs e)
{

if(!isSettingsLoaded) return;
Settings.TimetableSettings.BNSPath = TextBoxBNSPath.Text;
SaveSettings();
}

#endregion
Expand Down Expand Up @@ -1289,7 +1301,13 @@ private void LoadSettings()

TextBoxDataLocation.Text = Settings.Storage.dataPath;

ToggleSwitchUseTimetable.IsOn = Settings.TimetableSettings.useTimetable;
ToggleSwitchUseTimetable.IsOn = Settings.TimetableSettings.isTimetableEnabled;

ToggleSwitchTimetableNotification.IsOn = Settings.TimetableSettings.isTimetableNotificationEnabled;

ToggleSwitchUseDefaultBNSPath.IsOn = Settings.TimetableSettings.useDefaultBNSPath;

TextBoxBNSPath.Text = Settings.TimetableSettings.BNSPath;
}
public static Settings Settings = new Settings();
public static string settingsFileName = "Settings.json";
Expand Down Expand Up @@ -1493,12 +1511,17 @@ public static bool StartAutomaticallyDel(string exeName)

private void ShowNotificationBNS(string title, string subtitle, int time, bool isBottom)
{
string bnsPath = "D:\\bns.exe";

string timeString = time.ToString();

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = bnsPath;
if (Settings.TimetableSettings.BNSPath.EndsWith("\\"))
{
startInfo.FileName = Settings.TimetableSettings.BNSPath + "bns.exe";
}
else
{
startInfo.FileName = Settings.TimetableSettings.BNSPath + "\\bns.exe";
}
startInfo.Arguments = "\"" + title + "\"" + " \"" + subtitle + "\" -t " + timeString;
if (isBottom) startInfo.Arguments += " -bottom";

Expand Down

0 comments on commit 4cb5a59

Please sign in to comment.