@@ -83,7 +83,7 @@ public GitProperties EnabledGitProperties
83
83
( ! gitItem . StatusPropertiesInitialized && value is GitProperties . All or GitProperties . Status
84
84
|| ! gitItem . CommitPropertiesInitialized && value is GitProperties . All or GitProperties . Commit ) )
85
85
{
86
- await LoadGitPropertiesAsync ( gitItem ) ;
86
+ await LoadGitPropertiesAsync ( gitItem ) ;
87
87
}
88
88
} ) ;
89
89
}
@@ -944,136 +944,54 @@ private async Task<BitmapImage> GetShieldIcon()
944
944
private async Task LoadItemThumbnailAsync ( ListedItem item , uint thumbnailSize = 96 , IStorageItem ? matchingStorageItem = null )
945
945
{
946
946
var wasIconLoaded = false ;
947
+
948
+
947
949
if ( item . IsLibrary || item . PrimaryItemAttribute == StorageItemTypes . File || item . IsArchive )
948
950
{
949
- if ( UserSettingsService . FoldersSettingsService . ShowThumbnails &&
950
- ! item . IsShortcut && ! item . IsHiddenItem && ! FtpHelpers . IsFtpPath ( item . ItemPath ) )
951
+ var getIconOnly = UserSettingsService . FoldersSettingsService . ShowThumbnails == false ;
952
+ var iconInfo = await FileThumbnailHelper . LoadIconAndOverlayAsync ( item . ItemPath , thumbnailSize , false , getIconOnly ) ;
953
+ if ( iconInfo . IconData is not null )
951
954
{
952
- var matchingStorageFile = matchingStorageItem ? . AsBaseStorageFile ( ) ?? await GetFileFromPathAsync ( item . ItemPath ) ;
953
-
954
- if ( matchingStorageFile is not null )
955
+ await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
955
956
{
956
- // SingleItem returns image thumbnails in the correct aspect ratio for the grid layouts
957
- // ListView is used for the details and columns layout
958
- var thumbnailMode = thumbnailSize < 96 ? ThumbnailMode . ListView : ThumbnailMode . SingleItem ;
959
-
960
- using StorageItemThumbnail Thumbnail = await FilesystemTasks . Wrap ( ( ) => matchingStorageFile . GetThumbnailAsync ( thumbnailMode , thumbnailSize , ThumbnailOptions . ResizeThumbnail ) . AsTask ( ) ) ;
961
-
962
- if ( ! ( Thumbnail is null || Thumbnail . Size == 0 || Thumbnail . OriginalHeight == 0 || Thumbnail . OriginalWidth == 0 ) )
957
+ item . FileImage = await iconInfo . IconData . ToBitmapAsync ( ) ;
958
+ if ( ! string . IsNullOrEmpty ( item . FileExtension ) &&
959
+ ! item . IsShortcut && ! item . IsExecutable &&
960
+ ! ImagePreviewViewModel . ContainsExtension ( item . FileExtension . ToLowerInvariant ( ) ) )
963
961
{
964
- await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
965
- {
966
- var img = new BitmapImage ( ) ;
967
- img . DecodePixelType = DecodePixelType . Logical ;
968
- img . DecodePixelWidth = ( int ) thumbnailSize ;
969
- await img . SetSourceAsync ( Thumbnail ) ;
970
- item . FileImage = img ;
971
- if ( ! string . IsNullOrEmpty ( item . FileExtension ) &&
972
- ! item . IsShortcut && ! item . IsExecutable &&
973
- ! ImagePreviewViewModel . ContainsExtension ( item . FileExtension . ToLowerInvariant ( ) ) )
974
- {
975
- DefaultIcons . AddIfNotPresent ( item . FileExtension . ToLowerInvariant ( ) , item . FileImage ) ;
976
- }
977
- } , Microsoft . UI . Dispatching . DispatcherQueuePriority . Normal ) ;
978
- wasIconLoaded = true ;
962
+ DefaultIcons . AddIfNotPresent ( item . FileExtension . ToLowerInvariant ( ) , item . FileImage ) ;
979
963
}
980
-
981
- var overlayInfo = await FileThumbnailHelper . LoadOverlayAsync ( item . ItemPath , thumbnailSize ) ;
982
- if ( overlayInfo is not null )
983
- {
984
- await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
985
- {
986
- item . IconOverlay = await overlayInfo . ToBitmapAsync ( ) ;
987
- item . ShieldIcon = await GetShieldIcon ( ) ;
988
- } , Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
989
- }
990
- }
964
+ } , Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
991
965
}
992
966
993
- if ( ! wasIconLoaded )
967
+ if ( iconInfo . OverlayData is not null )
994
968
{
995
- var iconInfo = await FileThumbnailHelper . LoadIconAndOverlayAsync ( item . ItemPath , thumbnailSize , false ) ;
996
- if ( iconInfo . IconData is not null )
969
+ await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
997
970
{
998
- await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
999
- {
1000
- item . FileImage = await iconInfo . IconData . ToBitmapAsync ( ) ;
1001
- if ( ! string . IsNullOrEmpty ( item . FileExtension ) &&
1002
- ! item . IsShortcut && ! item . IsExecutable &&
1003
- ! ImagePreviewViewModel . ContainsExtension ( item . FileExtension . ToLowerInvariant ( ) ) )
1004
- {
1005
- DefaultIcons . AddIfNotPresent ( item . FileExtension . ToLowerInvariant ( ) , item . FileImage ) ;
1006
- }
1007
- } , Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
1008
- }
1009
-
1010
- if ( iconInfo . OverlayData is not null )
1011
- {
1012
- await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
1013
- {
1014
- item . IconOverlay = await iconInfo . OverlayData . ToBitmapAsync ( ) ;
1015
- item . ShieldIcon = await GetShieldIcon ( ) ;
1016
- } , Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
1017
- }
971
+ item . IconOverlay = await iconInfo . OverlayData . ToBitmapAsync ( ) ;
972
+ item . ShieldIcon = await GetShieldIcon ( ) ;
973
+ } , Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
1018
974
}
1019
975
}
1020
976
else
1021
977
{
1022
- if ( ! item . IsShortcut && ! item . IsHiddenItem && ! FtpHelpers . IsFtpPath ( item . ItemPath ) )
978
+ var getIconOnly = UserSettingsService . FoldersSettingsService . ShowThumbnails == false || thumbnailSize < 80 ;
979
+ var iconInfo = await FileThumbnailHelper . LoadIconAndOverlayAsync ( item . ItemPath , thumbnailSize , true , getIconOnly ) ;
980
+ if ( iconInfo . IconData is not null )
1023
981
{
1024
- var matchingStorageFolder = matchingStorageItem ? . AsBaseStorageFolder ( ) ?? await GetFolderFromPathAsync ( item . ItemPath ) ;
1025
- if ( matchingStorageFolder is not null )
982
+ await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
1026
983
{
1027
- // SingleItem returns image thumbnails in the correct aspect ratio for the grid layouts
1028
- // ListView is used for the details and columns layout
1029
- var thumbnailMode = thumbnailSize < 96 ? ThumbnailMode . ListView : ThumbnailMode . SingleItem ;
1030
-
1031
- // We use ReturnOnlyIfCached because otherwise folders thumbnails have a black background, this has the downside the folder previews don't work
1032
- using StorageItemThumbnail Thumbnail = await FilesystemTasks . Wrap ( ( ) => matchingStorageFolder . GetThumbnailAsync ( thumbnailMode , thumbnailSize , ThumbnailOptions . ReturnOnlyIfCached ) . AsTask ( ) ) ;
1033
- if ( ! ( Thumbnail is null || Thumbnail . Size == 0 || Thumbnail . OriginalHeight == 0 || Thumbnail . OriginalWidth == 0 ) )
1034
- {
1035
- await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
1036
- {
1037
- var img = new BitmapImage ( ) ;
1038
- img . DecodePixelType = DecodePixelType . Logical ;
1039
- img . DecodePixelWidth = ( int ) thumbnailSize ;
1040
- await img . SetSourceAsync ( Thumbnail ) ;
1041
- item . FileImage = img ;
1042
- } , Microsoft . UI . Dispatching . DispatcherQueuePriority . Normal ) ;
1043
- wasIconLoaded = true ;
1044
- }
1045
-
1046
- var overlayInfo = await FileThumbnailHelper . LoadOverlayAsync ( item . ItemPath , thumbnailSize ) ;
1047
- if ( overlayInfo is not null )
1048
- {
1049
- await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
1050
- {
1051
- item . IconOverlay = await overlayInfo . ToBitmapAsync ( ) ;
1052
- item . ShieldIcon = await GetShieldIcon ( ) ;
1053
- } , Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
1054
- }
1055
- }
984
+ item . FileImage = await iconInfo . IconData . ToBitmapAsync ( ) ;
985
+ } , Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
1056
986
}
1057
987
1058
- if ( ! wasIconLoaded )
988
+ if ( iconInfo . OverlayData is not null )
1059
989
{
1060
- var iconInfo = await FileThumbnailHelper . LoadIconAndOverlayAsync ( item . ItemPath , thumbnailSize , true ) ;
1061
- if ( iconInfo . IconData is not null )
990
+ await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
1062
991
{
1063
- await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
1064
- {
1065
- item . FileImage = await iconInfo . IconData . ToBitmapAsync ( ) ;
1066
- } , Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
1067
- }
1068
-
1069
- if ( iconInfo . OverlayData is not null )
1070
- {
1071
- await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
1072
- {
1073
- item . IconOverlay = await iconInfo . OverlayData . ToBitmapAsync ( ) ;
1074
- item . ShieldIcon = await GetShieldIcon ( ) ;
1075
- } , Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
1076
- }
992
+ item . IconOverlay = await iconInfo . OverlayData . ToBitmapAsync ( ) ;
993
+ item . ShieldIcon = await GetShieldIcon ( ) ;
994
+ } , Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
1077
995
}
1078
996
}
1079
997
}
@@ -1263,7 +1181,7 @@ public async Task LoadGitPropertiesAsync(GitItem gitItem)
1263
1181
{
1264
1182
var getStatus = EnabledGitProperties is GitProperties . All or GitProperties . Status && ! gitItem . StatusPropertiesInitialized ;
1265
1183
var getCommit = EnabledGitProperties is GitProperties . All or GitProperties . Commit && ! gitItem . CommitPropertiesInitialized ;
1266
-
1184
+
1267
1185
if ( ! getStatus && ! getCommit )
1268
1186
return ;
1269
1187
@@ -1331,7 +1249,7 @@ await SafetyExtensions.IgnoreExceptions(() =>
1331
1249
ImageSource ? groupImage = null ;
1332
1250
if ( item . PrimaryItemAttribute != StorageItemTypes . Folder || item . IsArchive )
1333
1251
{
1334
- var headerIconInfo = await FileThumbnailHelper . LoadIconWithoutOverlayAsync ( item . ItemPath , 64u , false ) ;
1252
+ var headerIconInfo = await FileThumbnailHelper . LoadIconWithoutOverlayAsync ( item . ItemPath , Constants . DefaultIconSizes . ExtraLarge , false , true ) ;
1335
1253
1336
1254
if ( headerIconInfo is not null && ! item . IsShortcut )
1337
1255
groupImage = await dispatcherQueue . EnqueueOrInvokeAsync ( ( ) => headerIconInfo . ToBitmapAsync ( ) , Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
0 commit comments