2
2
using System . Collections . Generic ;
3
3
using System . IO ;
4
4
using System . Linq ;
5
+ using System . Threading ;
5
6
using System . Windows ;
6
7
using System . Windows . Media ;
7
8
using System . Windows . Media . Imaging ;
@@ -16,7 +17,7 @@ public static class WallpaperPathRetrieval
16
17
17
18
private const int MaxCacheSize = 3 ;
18
19
private static readonly Dictionary < ( string , DateTime ) , ImageBrush > WallpaperCache = new ( ) ;
19
- private static readonly object CacheLock = new ( ) ;
20
+ private static readonly Lock CacheLock = new ( ) ;
20
21
21
22
public static Brush GetWallpaperBrush ( )
22
23
{
@@ -56,7 +57,7 @@ public static Brush GetWallpaperBrush()
56
57
57
58
if ( originalWidth == 0 || originalHeight == 0 )
58
59
{
59
- App . API . LogInfo ( ClassName , $ "Failed to load bitmap: Width={ originalWidth } , Height={ originalHeight } ") ;
60
+ App . API . LogError ( ClassName , $ "Failed to load bitmap: Width={ originalWidth } , Height={ originalHeight } ") ;
60
61
return new SolidColorBrush ( Colors . Transparent ) ;
61
62
}
62
63
@@ -104,13 +105,13 @@ public static Brush GetWallpaperBrush()
104
105
105
106
private static Color GetWallpaperColor ( )
106
107
{
107
- RegistryKey key = Registry . CurrentUser . OpenSubKey ( @"Control Panel\Colors" , false ) ;
108
+ using var key = Registry . CurrentUser . OpenSubKey ( @"Control Panel\Colors" , false ) ;
108
109
var result = key ? . GetValue ( "Background" , null ) ;
109
110
if ( result is string strResult )
110
111
{
111
112
try
112
113
{
113
- var parts = strResult . Trim ( ) . Split ( new [ ] { ' ' } , 3 ) . Select ( byte . Parse ) . ToList ( ) ;
114
+ var parts = strResult . Trim ( ) . Split ( [ ' ' ] , 3 ) . Select ( byte . Parse ) . ToList ( ) ;
114
115
return Color . FromRgb ( parts [ 0 ] , parts [ 1 ] , parts [ 2 ] ) ;
115
116
}
116
117
catch ( Exception ex )
0 commit comments