9
9
using Flow . Launcher . Infrastructure . Logger ;
10
10
using Flow . Launcher . Infrastructure . Storage ;
11
11
12
- namespace Wox . Infrastructure . Image
12
+ namespace Flow . Launcher . Infrastructure . Image
13
13
{
14
14
public static class ImageLoader
15
15
{
16
- private static readonly ImageCache _imageCache = new ImageCache ( ) ;
16
+ private static readonly ImageCache ImageCache = new ImageCache ( ) ;
17
17
private static readonly ConcurrentDictionary < string , string > _guidToKey = new ConcurrentDictionary < string , string > ( ) ;
18
- private static readonly bool _enableHashImage = true ;
19
-
18
+ private static readonly ConcurrentDictionary < string , string > GuidToKey = new ConcurrentDictionary < string , string > ( ) ;
20
19
private static BinaryStorage < Dictionary < string , int > > _storage ;
21
20
private static IImageHashGenerator _hashGenerator ;
21
+ private static bool EnableImageHash = true ;
22
22
23
23
private static readonly string [ ] ImageExtensions =
24
24
{
@@ -36,25 +36,25 @@ public static void Initialize()
36
36
_storage = new BinaryStorage < Dictionary < string , int > > ( "Image" ) ;
37
37
_hashGenerator = new ImageHashGenerator ( ) ;
38
38
39
- _imageCache . Usage = LoadStorageToConcurrentDictionary ( ) ;
39
+ ImageCache . Usage = LoadStorageToConcurrentDictionary ( ) ;
40
40
41
41
foreach ( var icon in new [ ] { Constant . DefaultIcon , Constant . ErrorIcon } )
42
42
{
43
43
ImageSource img = new BitmapImage ( new Uri ( icon ) ) ;
44
44
img . Freeze ( ) ;
45
- _imageCache [ icon ] = img ;
45
+ ImageCache [ icon ] = img ;
46
46
}
47
47
48
48
Task . Run ( ( ) =>
49
49
{
50
50
Stopwatch . Normal ( "|ImageLoader.Initialize|Preload images cost" , ( ) =>
51
51
{
52
- _imageCache . Usage . AsParallel ( ) . ForAll ( x =>
52
+ ImageCache . Usage . AsParallel ( ) . ForAll ( x =>
53
53
{
54
54
Load ( x . Key ) ;
55
55
} ) ;
56
56
} ) ;
57
- Log . Info ( $ "|ImageLoader.Initialize|Number of preload images is <{ _imageCache . Usage . Count } >, Images Number: { _imageCache . CacheSize ( ) } , Unique Items { _imageCache . UniqueImagesInCache ( ) } ") ;
57
+ Log . Info ( $ "|ImageLoader.Initialize|Number of preload images is <{ ImageCache . Usage . Count } >, Images Number: { ImageCache . CacheSize ( ) } , Unique Items { ImageCache . UniqueImagesInCache ( ) } ") ;
58
58
} ) ;
59
59
}
60
60
@@ -106,11 +106,11 @@ private static ImageResult LoadInternal(string path, bool loadFullImage = false)
106
106
{
107
107
if ( string . IsNullOrEmpty ( path ) )
108
108
{
109
- return new ImageResult ( _imageCache [ Constant . ErrorIcon ] , ImageType . Error ) ;
109
+ return new ImageResult ( ImageCache [ Constant . ErrorIcon ] , ImageType . Error ) ;
110
110
}
111
- if ( _imageCache . ContainsKey ( path ) )
111
+ if ( ImageCache . ContainsKey ( path ) )
112
112
{
113
- return new ImageResult ( _imageCache [ path ] , ImageType . Cache ) ;
113
+ return new ImageResult ( ImageCache [ path ] , ImageType . Cache ) ;
114
114
}
115
115
116
116
if ( path . StartsWith ( "data:" , StringComparison . OrdinalIgnoreCase ) )
@@ -139,8 +139,8 @@ private static ImageResult LoadInternal(string path, bool loadFullImage = false)
139
139
Log . Exception ( $ "|ImageLoader.Load|Failed to get thumbnail for { path } on first try", e ) ;
140
140
Log . Exception ( $ "|ImageLoader.Load|Failed to get thumbnail for { path } on second try", e2 ) ;
141
141
142
- ImageSource image = _imageCache [ Constant . ErrorIcon ] ;
143
- _imageCache [ path ] = image ;
142
+ ImageSource image = ImageCache [ Constant . ErrorIcon ] ;
143
+ ImageCache [ path ] = image ;
144
144
imageResult = new ImageResult ( image , ImageType . Error ) ;
145
145
}
146
146
}
@@ -191,7 +191,7 @@ private static ImageResult GetThumbnailResult(ref string path, bool loadFullImag
191
191
}
192
192
else
193
193
{
194
- image = _imageCache [ Constant . ErrorIcon ] ;
194
+ image = ImageCache [ Constant . ErrorIcon ] ;
195
195
path = Constant . ErrorIcon ;
196
196
}
197
197
0 commit comments