Skip to content

Commit 2de96ef

Browse files
committed
Extended Properties for PhotoAlbum Items
1 parent 205b31a commit 2de96ef

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

Files/App.xaml.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,17 @@ public static void Clipboard_ContentChanged(object sender, object e)
107107
{
108108
try
109109
{
110-
DataPackageView packageView = Clipboard.GetContent();
111-
if (packageView.Contains(StandardDataFormats.StorageItems) && App.CurrentInstance.CurrentPageType != typeof(YourHome))
110+
if (App.CurrentInstance != null)
112111
{
113-
App.PS.isEnabled = true;
112+
DataPackageView packageView = Clipboard.GetContent();
113+
if (packageView.Contains(StandardDataFormats.StorageItems) && App.CurrentInstance.CurrentPageType != typeof(YourHome))
114+
{
115+
App.PS.isEnabled = true;
116+
}
117+
else
118+
{
119+
App.PS.isEnabled = false;
120+
}
114121
}
115122
else
116123
{

Files/Filesystem/ItemViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ internal set
543543
}
544544
}
545545

546-
public async void LoadExtendedItemProperties(ListedItem item)
546+
public async void LoadExtendedItemProperties(ListedItem item, uint thumbnailSize = 20)
547547
{
548548
if (!item.ItemPropertiesInitialized)
549549
{
@@ -558,7 +558,7 @@ public async void LoadExtendedItemProperties(ListedItem item)
558558
{
559559
matchingItem.FileType = matchingStorageItem.DisplayType;
560560
matchingItem.FolderRelativeId = matchingStorageItem.FolderRelativeId;
561-
var Thumbnail = await matchingStorageItem.GetThumbnailAsync(ThumbnailMode.ListView, 20, ThumbnailOptions.UseCurrentScale);
561+
var Thumbnail = await matchingStorageItem.GetThumbnailAsync(ThumbnailMode.ListView, thumbnailSize, ThumbnailOptions.UseCurrentScale);
562562
if (Thumbnail != null)
563563
{
564564
matchingItem.FileImg = icon;

Files/UserControls/PhotoAlbum.xaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@
276276
<GridView.ItemTemplate>
277277
<DataTemplate x:DataType="local2:ListedItem">
278278
<Grid
279+
DataContext="{x:Bind}"
280+
EffectiveViewportChanged="Grid_EffectiveViewportChanged"
279281
Width="125"
280282
Height="Auto"
281283
Margin="0,0,0,0"
@@ -300,8 +302,8 @@
300302
Padding="12"
301303
HorizontalAlignment="Stretch"
302304
VerticalAlignment="Stretch"
303-
Visibility="{x:Bind FileIconVis}">
304-
<Image Source="{x:Bind FileImg}" Stretch="Uniform" />
305+
Visibility="{x:Bind FileIconVis, Mode=OneWay}">
306+
<Image Source="{x:Bind FileImg, Mode=OneWay}" Stretch="Uniform" />
305307
</Grid>
306308
<Image
307309
HorizontalAlignment="Stretch"
@@ -318,7 +320,7 @@
318320
<Grid
319321
HorizontalAlignment="Stretch"
320322
VerticalAlignment="Stretch"
321-
Visibility="{x:Bind EmptyImgVis}">
323+
Visibility="{x:Bind EmptyImgVis, Mode=OneWay}">
322324
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
323325
<FontIcon
324326
FontFamily="Segoe MDL2 Assets"

Files/UserControls/PhotoAlbum.xaml.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Interaction = Files.Interacts.Interaction;
77
using Windows.UI.Core;
88
using Files.Controls;
9+
using System;
910

1011
namespace Files
1112
{
@@ -160,5 +161,18 @@ protected override void Page_CharacterReceived(CoreWindow sender, CharacterRecei
160161
}
161162
}
162163
}
164+
165+
private async void Grid_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args)
166+
{
167+
if (sender.DataContext != null && (!(sender.DataContext as ListedItem).ItemPropertiesInitialized) && (args.BringIntoViewDistanceX < sender.ActualHeight))
168+
{
169+
await Window.Current.CoreWindow.Dispatcher.RunIdleAsync((e) =>
170+
{
171+
App.CurrentInstance.ViewModel.LoadExtendedItemProperties(sender.DataContext as ListedItem, 80);
172+
(sender.DataContext as ListedItem).ItemPropertiesInitialized = true;
173+
//sender.EffectiveViewportChanged -= Icon_EffectiveViewportChanged;
174+
});
175+
}
176+
}
163177
}
164178
}

0 commit comments

Comments
 (0)