Skip to content

Commit

Permalink
新增强下课提醒,更新版本号
Browse files Browse the repository at this point in the history
  • Loading branch information
STBBRD committed May 26, 2024
1 parent 82793c6 commit 154117a
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 15 deletions.
10 changes: 6 additions & 4 deletions ZongziTEK_Blackboard_Sticker/Classes/Timetable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,19 @@ public string ToCurriculums(List<Lesson> list)

public class Lesson
{
public string Subject { get; set; }
public TimeSpan StartTime { get; set; }
public TimeSpan EndTime { get; set; }
public string Subject { get; set; } = "";
public TimeSpan StartTime { get; set; } = new TimeSpan();
public TimeSpan EndTime { get; set; } = new TimeSpan();
public bool IsSplitBelow { get; set; } = false;
public bool IsStrongClassOverNotificationEnabled { get; set; } = false;

public Lesson(string subject, TimeSpan startTime, TimeSpan endTime, bool isSplitBelow)
public Lesson(string subject, TimeSpan startTime, TimeSpan endTime, bool isSplitBelow, bool isStrongClassOverNotificationEnabled)
{
Subject = subject;
StartTime = startTime;
EndTime = endTime;
IsSplitBelow = isSplitBelow;
IsStrongClassOverNotificationEnabled = isStrongClassOverNotificationEnabled;
}
}
}
11 changes: 10 additions & 1 deletion ZongziTEK_Blackboard_Sticker/Controls/TimetableEditorItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@
<ui:FontIcon Icon="{x:Static ui:FluentSystemIcons.MoreHorizontal_20_Regular}"/>
<ui:FlyoutService.Flyout>
<ui:MenuFlyout>
<MenuItem Name="MenuItemSplit" Header="在这节课下方添加空隙" IsCheckable="True" Click="MenuItemSplit_Click"/>
<MenuItem x:Name="MenuItemSplit" Header="在这节课下方添加空隙" IsCheckable="True" Click="MenuItemSplit_Click">
<MenuItem.Icon>
<ui:FontIcon Icon="{x:Static ui:FluentSystemIcons.SplitHorizontal_20_Regular}"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem x:Name="MenuItemStrongNotification" Header="启用强下课提醒" IsCheckable="True" Click="MenuItemStrongNotification_Click">
<MenuItem.Icon>
<ui:FontIcon Icon="{x:Static ui:FluentSystemIcons.Alert_20_Regular}"/>
</MenuItem.Icon>
</MenuItem>
<Separator/>
<MenuItem Header="删除" Click="MenuItemDelete_Click">
<MenuItem.Icon>
Expand Down
17 changes: 17 additions & 0 deletions ZongziTEK_Blackboard_Sticker/Controls/TimetableEditorItem.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -74,6 +75,15 @@ public bool IsSplitBelow
get { return (bool)GetValue(IsSplitBelowProperty); }
set { SetValue(IsSplitBelowProperty, value); }
}

public static readonly DependencyProperty IsStrongClassOverNotificationEnabledProperty =
DependencyProperty.Register("IsStrongClassOverNotificationEnabled", typeof(bool), typeof(TimetableEditorItem));

public bool IsStrongClassOverNotificationEnabled
{
get { return (bool)GetValue(IsStrongClassOverNotificationEnabledProperty); }
set { SetValue(IsStrongClassOverNotificationEnabledProperty, value); }
}
#endregion

#region TextBlockHint
Expand Down Expand Up @@ -151,9 +161,16 @@ private void MenuItemSplit_Click(object sender, RoutedEventArgs e)
OnLessonInfoChanged();
}

private void MenuItemStrongNotification_Click(object sender, RoutedEventArgs e)
{
IsStrongClassOverNotificationEnabled = MenuItemStrongNotification.IsChecked;
OnLessonInfoChanged();
}

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
MenuItemSplit.IsChecked = IsSplitBelow;
MenuItemStrongNotification.IsChecked = IsStrongClassOverNotificationEnabled;
isLoaded = true;
}
#endregion
Expand Down
23 changes: 19 additions & 4 deletions ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ private void CheckTimetable(object sender, EventArgs e)
{
ShowClassOverNotification(timetableToShow, lessonIndex);
}
else ShowLastClassOverNotification();
else ShowLastClassOverNotification(timetableToShow[lessonIndex].IsStrongClassOverNotificationEnabled);
}
if (lessonIndex + 1 < timetableToShow.Count && !isInClass && currentTime == timetableToShow[lessonIndex + 1].StartTime - TimeSpan.FromSeconds(Settings.TimetableSettings.BeginNotificationPreTime)) // 有下一节课,在下一节课开始的数秒前
{
Expand Down Expand Up @@ -1299,15 +1299,30 @@ private void ShowClassOverNotification(List<Lesson> today, int index)
string title = "下一节 " + today[nextLessonIndex].Subject + "课";
string subtitle = "课堂结束,下一节课将于 " + startTimeString + " 开始";

ShowNotificationBNS(title, subtitle, Settings.TimetableSettings.OverNotificationTime, false);
if (!today[index].IsStrongClassOverNotificationEnabled)
{
ShowNotificationBNS(title, subtitle, Settings.TimetableSettings.OverNotificationTime, false);
}
else
{
title = "下一节是 " + today[nextLessonIndex].Subject + "课";
new StrongNotificationWindow(title, subtitle).Show();
}
}
}

private void ShowLastClassOverNotification()
private void ShowLastClassOverNotification(bool isStrongNotificationEnabled)
{
if (Settings.TimetableSettings.IsTimetableNotificationEnabled)
{
ShowNotificationBNS("课堂结束", "", Settings.TimetableSettings.OverNotificationTime, false);
if (!isStrongNotificationEnabled)
{
ShowNotificationBNS("课堂结束", "", Settings.TimetableSettings.OverNotificationTime, false);
}
else
{
new StrongNotificationWindow("课堂结束", "").Show();
}
}
}
#endregion
Expand Down
4 changes: 2 additions & 2 deletions ZongziTEK_Blackboard_Sticker/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.1.0.0")]
[assembly: AssemblyFileVersion("3.1.0.0")]
[assembly: AssemblyVersion("3.1.0.1")]
[assembly: AssemblyFileVersion("3.1.0.1")]
27 changes: 27 additions & 0 deletions ZongziTEK_Blackboard_Sticker/StrongNotificationWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Window x:Class="ZongziTEK_Blackboard_Sticker.StrongNotificationWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:local="clr-namespace:ZongziTEK_Blackboard_Sticker"
mc:Ignorable="d"
Title="ZongziTEK 黑板贴 - 强提醒" Height="450" Width="800" WindowStyle="None" WindowState="Maximized" AllowsTransparency="True" Topmost="True"
Loaded="Window_Loaded">
<Grid>
<Rectangle>
<Rectangle.Fill>
<LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
<GradientStop Color="#FF41C4F8"/>
<GradientStop Color="#FF037BD5" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Viewbox Name="ViewboxContent" Margin="100">
<ui:SimpleStackPanel Spacing="24">
<TextBlock Name="TextBlockTitle" HorizontalAlignment="Center" Foreground="White" FontSize="144"/>
<TextBlock Name="TextBlockSubtitle" HorizontalAlignment="Center" Opacity="0.8" Foreground="White" FontSize="64"/>
</ui:SimpleStackPanel>
</Viewbox>
</Grid>
</Window>
91 changes: 91 additions & 0 deletions ZongziTEK_Blackboard_Sticker/StrongNotificationWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Speech.Synthesis;
using ZongziTEK_Blackboard_Sticker.Helpers;
using System.Windows.Media.Animation;

namespace ZongziTEK_Blackboard_Sticker
{
/// <summary>
/// StrongNotificationWindow.xaml 的交互逻辑
/// </summary>
public partial class StrongNotificationWindow : Window
{
public StrongNotificationWindow(string title, string subtitle)
{
InitializeComponent();

TextBlockTitle.Text = title;
TextBlockSubtitle.Text = subtitle;

if (subtitle == "") TextBlockSubtitle.Visibility = Visibility.Collapsed;
}

private SpeechSynthesizer synthesizer = new();

private async void Window_Loaded(object sender, RoutedEventArgs e)
{
// 设置为 ToolWindow
var hwnd = new WindowInteropHelper(this).Handle;
WindowsHelper.SetWindowStyleToolWindow(hwnd);

// 进入动画
DoubleAnimation opacityAnimationIn = new()
{
From = 0,
To = 1,
Duration = TimeSpan.FromMilliseconds(500),
EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }
};
BeginAnimation(OpacityProperty, opacityAnimationIn);

ThicknessAnimation viewboxMarginAnimationIn = new()
{
From = new Thickness(24),
To = new Thickness(100),
Duration = TimeSpan.FromMilliseconds(500),
EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }
};
ViewboxContent.BeginAnimation(MarginProperty, viewboxMarginAnimationIn);
await Task.Delay(500);

// 语音播报
synthesizer.Speak(TextBlockTitle.Text);
await Task.Delay(200);
synthesizer.Speak(TextBlockSubtitle.Text);

// 退出动画
DoubleAnimation opacityAnimationOut = new()
{
From = 1,
To = 0,
Duration = TimeSpan.FromMilliseconds(500),
EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseIn }
};
BeginAnimation(OpacityProperty, opacityAnimationOut);

ThicknessAnimation viewboxMarginAnimationOut = new()
{
From = new Thickness(100),
To = new Thickness(24),
Duration = TimeSpan.FromMilliseconds(500),
EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseIn }
};
ViewboxContent.BeginAnimation(MarginProperty, viewboxMarginAnimationOut);
await Task.Delay(600);
Close();
}
}
}
10 changes: 6 additions & 4 deletions ZongziTEK_Blackboard_Sticker/TimetableEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void Item_LessonInfoChanged(object sender, EventArgs e)

try
{
Lesson lesson = new Lesson(changedItem.Subject, TimeSpan.Parse(changedItem.StartTime), TimeSpan.Parse(changedItem.EndTime), changedItem.IsSplitBelow);
Lesson lesson = new Lesson(changedItem.Subject, TimeSpan.Parse(changedItem.StartTime), TimeSpan.Parse(changedItem.EndTime), changedItem.IsSplitBelow, changedItem.IsStrongClassOverNotificationEnabled);
GetSelectedDay()[index] = lesson;
if (lesson.IsSplitBelow)
{
Expand Down Expand Up @@ -160,11 +160,12 @@ private void ButtonInsertLesson_Click(object sender, RoutedEventArgs e)
Subject = "",
StartTime = "00:00",
EndTime = "00:00",
IsSplitBelow = false
IsSplitBelow = false,
IsStrongClassOverNotificationEnabled = false
};
item.LessonInfoChanged += Item_LessonInfoChanged;
item.LessonDeleting += Item_LessonDeleting;
GetSelectedDay().Add(new Lesson("", new TimeSpan(0, 0, 0), new TimeSpan(0, 0, 0), false));
GetSelectedDay().Add(new Lesson("", new TimeSpan(0, 0, 0), new TimeSpan(0, 0, 0), false, false));
ListStackPanel.Children.Add(item);

isEdited = true;
Expand Down Expand Up @@ -200,7 +201,8 @@ private async void LoadTimetable()
Subject = lesson.Subject,
StartTime = lesson.StartTime.ToString(@"hh\:mm"),
EndTime = lesson.EndTime.ToString(@"hh\:mm"),
IsSplitBelow = lesson.IsSplitBelow
IsSplitBelow = lesson.IsSplitBelow,
IsStrongClassOverNotificationEnabled = lesson.IsStrongClassOverNotificationEnabled
};
if (lesson.IsSplitBelow)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Speech" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
Expand Down Expand Up @@ -140,6 +141,9 @@
<Compile Include="SettingsWindow.xaml.cs">
<DependentUpon>SettingsWindow.xaml</DependentUpon>
</Compile>
<Compile Include="StrongNotificationWindow.xaml.cs">
<DependentUpon>StrongNotificationWindow.xaml</DependentUpon>
</Compile>
<Compile Include="TimetableEditor.xaml.cs">
<DependentUpon>TimetableEditor.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -222,6 +226,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="StrongNotificationWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Style\Dark.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down

0 comments on commit 154117a

Please sign in to comment.