@@ -2365,6 +2365,8 @@ private void ToggleSwitchSupportWPS_Toggled(object sender, RoutedEventArgs e)
2365
2365
2366
2366
public static bool IsShowingRestoreHiddenSlidesWindow = false ;
2367
2367
2368
+ public static bool IsNotifyPreviousPageWindowShown = false ;
2369
+
2368
2370
private void TimerCheckPPT_Elapsed ( object sender , ElapsedEventArgs e )
2369
2371
{
2370
2372
if ( IsShowingRestoreHiddenSlidesWindow ) return ;
@@ -2420,30 +2422,31 @@ private void TimerCheckPPT_Elapsed(object sender, ElapsedEventArgs e)
2420
2422
// 跳转到上次播放页
2421
2423
if ( Settings . PowerPointSettings . IsNotifyPreviousPage )
2422
2424
Application . Current . Dispatcher . BeginInvoke ( ( ) =>
2423
- {
2424
- string defaultFolderPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyDocuments ) +
2425
- @"\Ink Canvas Strokes\Auto Saved\Presentations\" ;
2426
- string folderPath = defaultFolderPath + presentation . Name + "_" + presentation . Slides . Count ;
2427
- if ( File . Exists ( folderPath + "/Position" ) )
2428
2425
{
2429
- if ( int . TryParse ( File . ReadAllText ( folderPath + "/Position" ) , out var page ) )
2426
+ string defaultFolderPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyDocuments ) +
2427
+ @"\Ink Canvas Strokes\Auto Saved\Presentations\" ;
2428
+ string folderPath = defaultFolderPath + presentation . Name + "_" + presentation . Slides . Count ;
2429
+ if ( File . Exists ( folderPath + "/Position" ) & ! IsNotifyPreviousPageWindowShown ) //判断是否已存在NotifyPreviousPage窗口
2430
2430
{
2431
- if ( page <= 0 ) return ;
2432
- new YesOrNoNotificationWindow ( $ "上次播放到了第 { page } 页, 是否立即跳转", ( ) =>
2431
+ if ( int . TryParse ( File . ReadAllText ( folderPath + "/Position" ) , out var page ) )
2433
2432
{
2434
- if ( pptApplication . SlideShowWindows . Count >= 1 )
2433
+ IsNotifyPreviousPageWindowShown = true ;
2434
+ if ( page <= 0 ) return ;
2435
+ new YesOrNoNotificationWindow ( $ "上次播放到了第 { page } 页, 是否立即跳转", ( ) =>
2435
2436
{
2436
- // 如果已经播放了的话, 跳转
2437
- presentation . SlideShowWindow . View . GotoSlide ( page ) ;
2438
- }
2439
- else
2440
- {
2441
- presentation . Windows [ 1 ] . View . GotoSlide ( page ) ;
2442
- }
2443
- } ) . ShowDialog ( ) ;
2437
+ if ( pptApplication . SlideShowWindows . Count >= 1 )
2438
+ {
2439
+ // 如果已经播放了的话, 跳转
2440
+ presentation . SlideShowWindow . View . GotoSlide ( page ) ;
2441
+ }
2442
+ else
2443
+ {
2444
+ presentation . Windows [ 1 ] . View . GotoSlide ( page ) ;
2445
+ }
2446
+ } ) . ShowDialog ( ) ;
2447
+ }
2444
2448
}
2445
- }
2446
- } , DispatcherPriority . Normal ) ;
2449
+ } , DispatcherPriority . Normal ) ;
2447
2450
2448
2451
2449
2452
//检查是否有隐藏幻灯片
@@ -2464,7 +2467,7 @@ private void TimerCheckPPT_Elapsed(object sender, ElapsedEventArgs e)
2464
2467
if ( isHaveHiddenSlide && ! IsShowingRestoreHiddenSlidesWindow )
2465
2468
{
2466
2469
IsShowingRestoreHiddenSlidesWindow = true ;
2467
- new YesOrNoNotificationWindow ( "检测到此演示文档中包含隐藏的幻灯片 ,是否取消隐藏?" ,
2470
+ new YesOrNoNotificationWindow ( "检测到此演示文稿包含隐藏的幻灯片 ,是否取消隐藏?" ,
2468
2471
( ) =>
2469
2472
{
2470
2473
foreach ( Slide slide in slides )
@@ -2512,7 +2515,7 @@ private void PptApplication_PresentationClose(Presentation Pres)
2512
2515
timerCheckPPT . Start ( ) ;
2513
2516
Application . Current . Dispatcher . Invoke ( ( ) =>
2514
2517
{
2515
- BtnPPTSlideShow . Visibility = Visibility . Collapsed ;
2518
+ // BtnPPTSlideShow.Visibility = Visibility.Collapsed;
2516
2519
BtnPPTSlideShowEnd . Visibility = Visibility . Collapsed ;
2517
2520
} ) ;
2518
2521
}
@@ -2521,6 +2524,7 @@ private void PptApplication_PresentationClose(Presentation Pres)
2521
2524
2522
2525
2523
2526
private string pptName = null ;
2527
+ int currentShowPosition = - 1 ;
2524
2528
//bool isButtonBackgroundTransparent = true; //此变量仅用于保存用于幻灯片放映时的优化
2525
2529
private void PptApplication_SlideShowBegin ( SlideShowWindow Wn )
2526
2530
{
@@ -2581,21 +2585,24 @@ private void PptApplication_SlideShowBegin(SlideShowWindow Wn)
2581
2585
int count = 0 ;
2582
2586
foreach ( FileInfo file in files )
2583
2587
{
2584
- int i = - 1 ;
2585
- try
2586
- {
2587
- i = int . Parse ( System . IO . Path . GetFileNameWithoutExtension ( file . Name ) ) ;
2588
- //var fs = new FileStream(file.FullName, FileMode.Open, FileAccess.Read);
2589
- //MemoryStream ms = new MemoryStream(File.ReadAllBytes(file.FullName));
2590
- //new StrokeCollection(fs).Save(ms);
2591
- //ms.Position = 0;
2592
- memoryStreams [ i ] = new MemoryStream ( File . ReadAllBytes ( file . FullName ) ) ;
2593
- memoryStreams [ i ] . Position = 0 ;
2594
- count ++ ;
2595
- }
2596
- catch ( Exception ex )
2588
+ if ( file . Name != "Position" )
2597
2589
{
2598
- LogHelper . WriteLogToFile ( string . Format ( "Failed to load strokes on Slide {0}\n {1}" , i , ex . ToString ( ) ) , LogHelper . LogType . Error ) ;
2590
+ int i = - 1 ;
2591
+ try
2592
+ {
2593
+ i = int . Parse ( System . IO . Path . GetFileNameWithoutExtension ( file . Name ) ) ;
2594
+ //var fs = new FileStream(file.FullName, FileMode.Open, FileAccess.Read);
2595
+ //MemoryStream ms = new MemoryStream(File.ReadAllBytes(file.FullName));
2596
+ //new StrokeCollection(fs).Save(ms);
2597
+ //ms.Position = 0;
2598
+ memoryStreams [ i ] = new MemoryStream ( File . ReadAllBytes ( file . FullName ) ) ;
2599
+ memoryStreams [ i ] . Position = 0 ;
2600
+ count ++ ;
2601
+ }
2602
+ catch ( Exception ex )
2603
+ {
2604
+ LogHelper . WriteLogToFile ( string . Format ( "Failed to load strokes on Slide {0}\n {1}" , i , ex . ToString ( ) ) , LogHelper . LogType . Error ) ;
2605
+ }
2599
2606
}
2600
2607
}
2601
2608
LogHelper . WriteLogToFile ( string . Format ( "Loaded {0} saved strokes" , count . ToString ( ) ) ) ;
@@ -2686,6 +2693,7 @@ private void PptApplication_SlideShowBegin(SlideShowWindow Wn)
2686
2693
bool isEnteredSlideShowEndEvent = false ; //防止重复调用本函数导致墨迹保存失效
2687
2694
private void PptApplication_SlideShowEnd ( Presentation Pres )
2688
2695
{
2696
+ IsNotifyPreviousPageWindowShown = false ;
2689
2697
LogHelper . WriteLogToFile ( string . Format ( "PowerPoint Slide Show End" ) , LogHelper . LogType . Event ) ;
2690
2698
if ( isEnteredSlideShowEndEvent )
2691
2699
{
@@ -2701,7 +2709,22 @@ private void PptApplication_SlideShowEnd(Presentation Pres)
2701
2709
{
2702
2710
Directory . CreateDirectory ( folderPath ) ;
2703
2711
}
2704
- File . WriteAllText ( folderPath + "/Position" , previousSlideID . ToString ( ) ) ;
2712
+ try
2713
+ {
2714
+ File . WriteAllText ( folderPath + "/Position" , previousSlideID . ToString ( ) ) ;
2715
+ }
2716
+ catch { }
2717
+ Application . Current . Dispatcher . Invoke ( ( ) =>
2718
+ {
2719
+ try
2720
+ {
2721
+ MemoryStream ms = new MemoryStream ( ) ;
2722
+ inkCanvas . Strokes . Save ( ms ) ;
2723
+ ms . Position = 0 ;
2724
+ memoryStreams [ currentShowPosition ] = ms ;
2725
+ }
2726
+ catch { }
2727
+ } ) ;
2705
2728
for ( int i = 1 ; i <= Pres . Slides . Count ; i ++ )
2706
2729
{
2707
2730
if ( memoryStreams [ i ] != null )
@@ -2818,6 +2841,7 @@ private void PptApplication_SlideShowNextSlide(SlideShowWindow Wn)
2818
2841
{
2819
2842
inkCanvas . Strokes . Add ( new StrokeCollection ( memoryStreams [ Wn . View . CurrentShowPosition ] ) ) ;
2820
2843
}
2844
+ currentShowPosition = Wn . View . CurrentShowPosition ;
2821
2845
}
2822
2846
catch
2823
2847
{ }
@@ -2923,6 +2947,7 @@ private void BtnPPTSlideShowEnd_Click(object sender, RoutedEventArgs e)
2923
2947
ms . Position = 0 ;
2924
2948
memoryStreams [ pptApplication . SlideShowWindows [ 1 ] . View . CurrentShowPosition ] = ms ;
2925
2949
timeMachine . ClearStrokeHistory ( ) ;
2950
+ IsNotifyPreviousPageWindowShown = false ;
2926
2951
}
2927
2952
catch { }
2928
2953
} ) ;
0 commit comments