@@ -48,6 +48,7 @@ public MainVM()
48
48
private IntPtr desktopHandle ;
49
49
private Process ffplayProcess ;
50
50
private IntPtr ffplayWindowHandle ;
51
+ private readonly string _exitWallpaper = "ExitWallpaper" ;
51
52
52
53
#endregion
53
54
@@ -237,23 +238,7 @@ public List<WallpaperItem> WallpaperArray
237
238
238
239
#endregion
239
240
240
- #region Wallpaper
241
- var wallpaersPath = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "Video" ) ;
242
- if ( Directory . Exists ( wallpaersPath ) )
243
- {
244
- var names = new List < WallpaperItem > ( ) ;
245
- var files = Directory . GetFiles ( wallpaersPath ) ;
246
- foreach ( var filePath in files )
247
- {
248
- var fileName = Path . GetFileNameWithoutExtension ( filePath ) ;
249
- names . Add ( new WallpaperItem { ItemName = fileName , VideoPath = filePath , IsSelected = ConfigHelper . WallpaperPath == filePath ? true : false } ) ;
250
- }
251
- names . Add ( new WallpaperItem { ItemName = "更多壁纸请加QQ群:929469013" } ) ;
252
- WallpaperArray = names ;
253
- if ( WallpaperArray . Count > 0 )
254
- ShowWallpaper ( ConfigHelper . WallpaperPath ) ;
255
- }
256
- #endregion
241
+ WallpaersFilePlay ( ) ;
257
242
258
243
if ( Common . ApplicationListCache == null )
259
244
{
@@ -430,8 +415,30 @@ private void ScreenCapturer_SnapCompleted(CroppedBitmap bitmap)
430
415
{
431
416
if ( obj is WallpaperItem wallpaper )
432
417
{
433
- if ( string . IsNullOrWhiteSpace ( wallpaper . VideoPath ) ) return ;
434
- ShowWallpaper ( wallpaper . VideoPath ) ;
418
+ if ( wallpaper . VideoPath == _exitWallpaper )
419
+ {
420
+ if ( ! wallpaper . IsSelected )
421
+ {
422
+ StopFFplayProcess ( ) ;
423
+ wallpaper . ItemName = "壁纸已关闭" ;
424
+ wallpaper . IsSelected = false ;
425
+ }
426
+ else
427
+ {
428
+ WallpaersFilePlay ( ) ;
429
+ wallpaper . ItemName = "壁纸已开启" ;
430
+ wallpaper . IsSelected = true ;
431
+ }
432
+ }
433
+ else
434
+ {
435
+ if ( string . IsNullOrWhiteSpace ( wallpaper . VideoPath ) ) return ;
436
+ if ( File . Exists ( wallpaper . VideoPath ) )
437
+ {
438
+ ShowWallpaper ( wallpaper . VideoPath ) ;
439
+ }
440
+
441
+ }
435
442
}
436
443
437
444
} ) ;
@@ -444,10 +451,16 @@ void ShowWallpaper(string wallpaperPath)
444
451
{
445
452
if ( string . IsNullOrWhiteSpace ( wallpaperPath ) || ! File . Exists ( wallpaperPath ) ) return ;
446
453
StopFFplayProcess ( ) ;
447
- WallpaperArray . Where ( x => x . VideoPath != wallpaperPath ) . ToList ( ) . ForEach ( x =>
454
+ WallpaperArray . Where ( x => x . VideoPath != wallpaperPath && x . VideoPath != _exitWallpaper ) . ToList ( ) . ForEach ( x =>
448
455
{
449
456
x . IsSelected = false ;
450
457
} ) ;
458
+ var wallpaper = WallpaperArray . FirstOrDefault ( x => x . VideoPath == _exitWallpaper ) ;
459
+ if ( wallpaper != null )
460
+ {
461
+ wallpaper . ItemName = "壁纸已开启" ;
462
+ wallpaper . IsSelected = true ;
463
+ }
451
464
StartFFplayProcess ( wallpaperPath ) ;
452
465
if ( ffplayWindowHandle != IntPtr . Zero )
453
466
{
@@ -509,7 +522,7 @@ private void MouseHook_MouseDown(object sender, MouseEventArgs e)
509
522
{
510
523
_timer . Stop ( ) ;
511
524
mouseHook . Stop ( ) ;
512
- if ( colorView != null )
525
+ if ( colorView != null )
513
526
colorView . Close ( ) ;
514
527
}
515
528
}
@@ -587,6 +600,29 @@ void StopFFplayProcess()
587
600
Log . Error ( $ "Error: StopFFplayProcess { ex . Message } ") ;
588
601
}
589
602
}
603
+ void WallpaersFilePlay ( )
604
+ {
605
+ WallpaperArray = null ;
606
+ #region Wallpaper
607
+ var wallpaersPath = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "Video" ) ;
608
+ if ( Directory . Exists ( wallpaersPath ) )
609
+ {
610
+ var names = new List < WallpaperItem > ( ) ;
611
+ var files = Directory . GetFiles ( wallpaersPath ) ;
612
+ foreach ( var filePath in files )
613
+ {
614
+ var fileName = Path . GetFileNameWithoutExtension ( filePath ) ;
615
+ names . Add ( new WallpaperItem { ItemName = fileName , VideoPath = filePath , IsSelected = ConfigHelper . WallpaperPath == filePath ? true : false } ) ;
616
+ }
617
+ if ( names . Count > 0 )
618
+ names . Add ( new WallpaperItem { ItemName = ConfigHelper . OpenWallpaper == true ? "壁纸已开启" : "壁纸已关闭" , VideoPath = _exitWallpaper , IsSelected = ConfigHelper . OpenWallpaper } ) ;
619
+ names . Add ( new WallpaperItem { ItemName = "更多壁纸请加QQ群:929469013" } ) ;
620
+ WallpaperArray = names ;
621
+ if ( WallpaperArray . Count > 0 )
622
+ ShowWallpaper ( ConfigHelper . WallpaperPath ) ;
623
+ }
624
+ #endregion
625
+ }
590
626
#endregion
591
627
}
592
628
}
0 commit comments