Skip to content

Commit

Permalink
提高上下课通知动画性能
Browse files Browse the repository at this point in the history
  • Loading branch information
STBBRD committed Oct 1, 2024
1 parent 9dd5017 commit c848184
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,8 @@ private void CheckTimetable(object sender, EventArgs e)
LoadTimetable();
}

TimeSpan currentTime = new TimeSpan(DateTime.Now.TimeOfDay.Hours, DateTime.Now.TimeOfDay.Minutes, DateTime.Now.TimeOfDay.Seconds) + TimeSpan.FromSeconds(Settings.TimetableSettings.TimeOffset);
TimeSpan currentTime = new TimeSpan
(DateTime.Now.TimeOfDay.Hours, DateTime.Now.TimeOfDay.Minutes, DateTime.Now.TimeOfDay.Seconds) + TimeSpan.FromSeconds(Settings.TimetableSettings.TimeOffset);

if (timetableToShow != null && timetableToShow.Count != 0)
{
Expand Down
11 changes: 8 additions & 3 deletions ZongziTEK_Blackboard_Sticker/TimetableNotificationWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
{
Timer_Tick(null, null);
ShowNotification();

DoubleAnimation barWidthAnimation = new()
{
From = BorderNotification.ActualWidth,
To = 0,
Duration = totalTime
};
RectangleProgressBar.BeginAnimation(WidthProperty, barWidthAnimation);
}

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
Expand All @@ -81,9 +89,6 @@ private void Timer_Tick(object sender, EventArgs e)
{
timeLeft = timeToHide - DateTime.Now.TimeOfDay;
TextTime.Text = timeLeft.TotalSeconds.ToString("00");
double barWidth = BorderNotification.ActualWidth * (timeLeft.TotalSeconds / totalTime.TotalSeconds);
if (barWidth >= 0) RectangleProgressBar.Width = barWidth;
if (barWidth == 0) timeTimer.Stop();

if (Convert.ToInt32(TextTime.Text) == 1)
{
Expand Down

0 comments on commit c848184

Please sign in to comment.