11using SupernoteDesktopClient . Core . Win32Api ;
22using System . Collections . Generic ;
3- using System . Drawing ;
43using System . IO ;
54using System . Windows . Interop ;
65using System . Windows . Media ;
@@ -15,37 +14,37 @@ public static class ImageManager
1514
1615 public static ImageSource GetImageSource ( string filename )
1716 {
18- return GetImageSourceFromCache ( filename , new Size ( 24 , 24 ) , ItemType . File , ItemState . Undefined ) ;
17+ return GetImageSourceFromCache ( filename , ItemType . File , ItemState . Undefined ) ;
1918 }
2019
2120 public static ImageSource GetImageSource ( string directory , ItemState folderType )
2221 {
23- return GetImageSourceFromCache ( directory , new Size ( 24 , 24 ) , ItemType . Folder , folderType ) ;
22+ return GetImageSourceFromCache ( directory , ItemType . Folder , folderType ) ;
2423 }
2524
26- private static ImageSource GetFileImageSource ( string filename , Size size )
25+ private static ImageSource GetFileImageSource ( string filename )
2726 {
2827 using ( var icon = NativeMethods . GetIcon ( Path . GetExtension ( filename ) , ItemType . File , IconSize . Large , ItemState . Undefined ) )
2928 {
3029 return Imaging . CreateBitmapSourceFromHIcon ( icon . Handle ,
3130 System . Windows . Int32Rect . Empty ,
32- BitmapSizeOptions . FromWidthAndHeight ( size . Width , size . Height ) ) ;
31+ BitmapSizeOptions . FromEmptyOptions ( ) ) ;
3332 }
3433 }
3534
36- private static ImageSource GetDirectoryImageSource ( string directory , Size size , ItemState folderType )
35+ private static ImageSource GetDirectoryImageSource ( string directory , ItemState folderType )
3736 {
3837 using ( var icon = NativeMethods . GetIcon ( directory , ItemType . Folder , IconSize . Large , folderType ) )
3938 {
4039 return Imaging . CreateBitmapSourceFromHIcon ( icon . Handle ,
4140 System . Windows . Int32Rect . Empty ,
42- BitmapSizeOptions . FromWidthAndHeight ( size . Width , size . Height ) ) ;
41+ BitmapSizeOptions . FromEmptyOptions ( ) ) ;
4342 }
4443 }
4544
46- private static ImageSource GetImageSourceFromCache ( string itemName , Size itemSize , ItemType itemType , ItemState itemState )
45+ private static ImageSource GetImageSourceFromCache ( string itemName , ItemType itemType , ItemState itemState )
4746 {
48- string cacheKey = $ "{ ( itemType is ItemType . Folder ? ItemType . Folder : Path . GetExtension ( itemName ) ) } # { itemSize . Width } # { itemSize . Height } ";
47+ string cacheKey = $ "{ ( itemType is ItemType . Folder ? ItemType . Folder : Path . GetExtension ( itemName ) ) } ";
4948
5049 ImageSource returnValue ;
5150 _imageSourceCache . TryGetValue ( cacheKey , out returnValue ) ;
@@ -59,9 +58,9 @@ private static ImageSource GetImageSourceFromCache(string itemName, Size itemSiz
5958 if ( returnValue == null )
6059 {
6160 if ( itemType is ItemType . Folder )
62- returnValue = GetDirectoryImageSource ( itemName , itemSize , itemState ) ;
61+ returnValue = GetDirectoryImageSource ( itemName , itemState ) ;
6362 else
64- returnValue = GetFileImageSource ( itemName , itemSize ) ;
63+ returnValue = GetFileImageSource ( itemName ) ;
6564
6665 if ( returnValue != null )
6766 _imageSourceCache . Add ( cacheKey , returnValue ) ;
0 commit comments