Skip to content

Commit 3043116

Browse files
authored
Retrieve Better Thumbnails for Files in Properties Dialog (#1233)
1 parent f3e30c2 commit 3043116

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

Files/Dialogs/PropertiesDialog.xaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local2="using:Files.Helpers"
7-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:Windows10version1903="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 8)"
89
x:Name="PropertiesDialogMarkup"
9-
Background="Transparent"
1010
mc:Ignorable="d"
1111
RequestedTheme="{x:Bind local2:ThemeHelper.RootTheme}">
12+
<ContentDialog.Background>
13+
<AcrylicBrush
14+
Windows10version1903:TintLuminosityOpacity="0.9"
15+
AlwaysUseFallback="{x:Bind AppSettings.AcrylicEnabled, Mode=OneWay}"
16+
BackgroundSource="HostBackdrop"
17+
FallbackColor="{x:Bind AppSettings.AcrylicTheme.FallbackColor, Mode=OneWay}"
18+
TintColor="{x:Bind AppSettings.AcrylicTheme.TintColor, Mode=OneWay}"
19+
TintOpacity="{x:Bind AppSettings.AcrylicTheme.TintOpacity, Mode=OneWay}" />
20+
</ContentDialog.Background>
1221
<ContentDialog.Resources>
1322
<Thickness x:Key="ContentDialogPadding">0</Thickness>
1423
</ContentDialog.Resources>

Files/Dialogs/PropertiesDialog.xaml.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
using Windows.UI.Xaml.Controls;
1+
using Files.View_Models;
2+
using Windows.UI.Xaml.Controls;
23

34
// The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
45

56
namespace Files.Dialogs
67
{
78
public sealed partial class PropertiesDialog : ContentDialog
89
{
10+
public SettingsViewModel AppSettings => App.AppSettings;
911
public PropertiesDialog()
1012
{
1113
this.InitializeComponent();

Files/Views/Pages/Properties.xaml.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using FileAttributes = System.IO.FileAttributes;
2323
using ByteSizeLib;
2424
using static Files.Helpers.NativeFindStorageItemHelper;
25+
using Windows.UI.Xaml.Media.Imaging;
2526

2627
namespace Files
2728
{
@@ -171,6 +172,18 @@ private async void GetFileProperties(CancellationTokenSource _tokenSource)
171172
ViewModel.ItemSize = ByteSize.FromBytes(ViewModel.Item.FileSizeBytes).ToBinaryString().ConvertSizeAbbreviation()
172173
+ " (" + ByteSize.FromBytes(ViewModel.Item.FileSizeBytes).Bytes.ToString("#,##0") + " " + ResourceController.GetTranslation("ItemSizeBytes") + ")";
173174

175+
using (var Thumbnail = await file.GetThumbnailAsync(ThumbnailMode.SingleItem, 80, ThumbnailOptions.UseCurrentScale))
176+
{
177+
BitmapImage icon = new BitmapImage();
178+
if (Thumbnail != null)
179+
{
180+
ViewModel.FileIconSource = icon;
181+
await icon.SetSourceAsync(Thumbnail);
182+
ViewModel.LoadUnknownTypeGlyph = false;
183+
ViewModel.LoadFileIcon = true;
184+
}
185+
}
186+
174187
// Get file MD5 hash
175188
var hashAlgTypeName = HashAlgorithmNames.Md5;
176189
ViewModel.ItemMD5HashProgressVisibility = Visibility.Visible;

0 commit comments

Comments
 (0)