From ecf3c1ad0423040f2a219eef06b882ffb7aa624a Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Thu, 1 Jan 2026 12:17:27 +0800 Subject: [PATCH] =?UTF-8?q?improve:PPT=E6=97=B6=E9=97=B4=E8=83=B6=E5=9B=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Windows/PPTTimeCapsule.xaml.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Ink Canvas/Windows/PPTTimeCapsule.xaml.cs b/Ink Canvas/Windows/PPTTimeCapsule.xaml.cs index 0f2d6143..1c206a0f 100644 --- a/Ink Canvas/Windows/PPTTimeCapsule.xaml.cs +++ b/Ink Canvas/Windows/PPTTimeCapsule.xaml.cs @@ -19,7 +19,7 @@ namespace Ink_Canvas.Windows /// /// PPT时间显示胶囊控件 /// - public partial class PPTTimeCapsule : UserControl + public partial class PPTTimeCapsule : UserControl, IDisposable { private System.Timers.Timer timeUpdateTimer; private System.Timers.Timer countdownUpdateTimer; @@ -68,15 +68,19 @@ namespace Ink_Canvas.Windows } private void PPTTimeCapsule_Unloaded(object sender, RoutedEventArgs e) + { + Dispose(); + } + + /// + /// 实现 IDisposable + /// + public void Dispose() { StopTimeUpdate(); SystemEvents.UserPreferenceChanged -= SystemEvents_UserPreferenceChanged; - - if (countdownUpdateTimer != null) - { - countdownUpdateTimer.Stop(); - countdownUpdateTimer.Dispose(); - } + timeUpdateTimer?.Dispose(); + countdownUpdateTimer?.Dispose(); } private void InitializeTimers() @@ -86,7 +90,7 @@ namespace Ink_Canvas.Windows timeUpdateTimer.Elapsed += TimeUpdateTimer_Elapsed; // 倒计时更新定时器 - countdownUpdateTimer = new System.Timers.Timer(100); + countdownUpdateTimer = new System.Timers.Timer(250); countdownUpdateTimer.Elapsed += CountdownUpdateTimer_Elapsed; }