Skip to content

Commit 997b158

Browse files
authored
Minor improvements to recent files item loading (#2386)
1 parent 600aea8 commit 997b158

File tree

6 files changed

+36
-37
lines changed

6 files changed

+36
-37
lines changed

Files/UserControls/MultitaskingControl/HorizontalMultitaskingControl.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
<ResourceDictionary>
1919
<ResourceDictionary.MergedDictionaries>
2020
<ResourceDictionary>
21-
<MenuFlyout x:Key="TabFlyout" x:Name="TabItemContextMenu" Opening="TabItemContextMenu_Opening">
21+
<MenuFlyout
22+
x:Key="TabFlyout"
23+
x:Name="TabItemContextMenu"
24+
Opening="TabItemContextMenu_Opening">
2225
<MenuFlyoutItem
2326
x:Uid="HorizontalMultitaskingControlNewTab"
2427
Click="{x:Bind views:MainPage.AddNewTabAtIndex}"

Files/UserControls/StatusBarControl.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@
6363
<FontIcon FontFamily="{StaticResource FluentUIGlyphs}" Glyph="&#xEB54;" />
6464
</MenuFlyoutItem.Icon>
6565
<MenuFlyoutItem.KeyboardAccelerators>
66-
<KeyboardAccelerator Modifiers="Control" Key="A" IsEnabled="False" />
66+
<KeyboardAccelerator
67+
Key="A"
68+
IsEnabled="False"
69+
Modifiers="Control" />
6770
</MenuFlyoutItem.KeyboardAccelerators>
6871
</MenuFlyoutItem>
6972
<MenuFlyoutItem

Files/UserControls/Widgets/RecentFiles.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
x:Class="Files.RecentFiles"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
65
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7-
xmlns:list="using:Locations"
86
xmlns:local="using:Files"
97
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
108
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
@@ -51,6 +49,7 @@
5149
IsRightTapEnabled="True"
5250
ItemClick="RecentsView_ItemClick"
5351
ItemContainerStyle="{StaticResource ListViewItemContainerStyle1}"
52+
ItemContainerTransitions="{x:Null}"
5453
ItemsSource="{x:Bind recentItemsCollection}"
5554
SelectionMode="None">
5655
<ListView.ItemTemplate>

Files/UserControls/Widgets/RecentFiles.xaml.cs

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
using System.Collections.ObjectModel;
66
using System.ComponentModel;
77
using System.IO;
8+
using System.Linq;
89
using System.Runtime.CompilerServices;
910
using System.Runtime.InteropServices;
1011
using System.Threading.Tasks;
1112
using Windows.Storage;
13+
using Windows.Storage.AccessCache;
1214
using Windows.UI.Xaml;
1315
using Windows.UI.Xaml.Controls;
1416
using Windows.UI.Xaml.Media.Imaging;
@@ -55,36 +57,16 @@ private void OpenFileLocation_Click(object sender, RoutedEventArgs e)
5557

5658
public async void PopulateRecentsList()
5759
{
58-
var mostRecentlyUsed = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList;
59-
bool IsRecentsListEmpty = true;
60-
foreach (var entry in mostRecentlyUsed.Entries)
61-
{
62-
try
63-
{
64-
var item = await mostRecentlyUsed.GetItemAsync(entry.Token);
65-
if (item.IsOfType(StorageItemTypes.File))
66-
{
67-
IsRecentsListEmpty = false;
68-
}
69-
}
70-
catch (Exception) { }
71-
}
60+
var mostRecentlyUsed = StorageApplicationPermissions.MostRecentlyUsedList;
7261

73-
if (IsRecentsListEmpty)
74-
{
75-
Empty.Visibility = Visibility.Visible;
76-
}
77-
else
78-
{
79-
Empty.Visibility = Visibility.Collapsed;
80-
}
62+
Empty.Visibility = Visibility.Collapsed;
8163

82-
foreach (Windows.Storage.AccessCache.AccessListEntry entry in mostRecentlyUsed.Entries)
64+
foreach (AccessListEntry entry in mostRecentlyUsed.Entries)
8365
{
8466
string mruToken = entry.Token;
8567
try
8668
{
87-
IStorageItem item = await mostRecentlyUsed.GetItemAsync(mruToken);
69+
IStorageItem item = await mostRecentlyUsed.GetItemAsync(mruToken, AccessCacheOptions.FastLocationsOnly);
8870
await AddItemToRecentListAsync(item, entry);
8971
}
9072
catch (UnauthorizedAccessException)
@@ -138,14 +120,14 @@ private async Task AddItemToRecentListAsync(IStorageItem item, Windows.Storage.A
138120
ItemType = StorageItemTypes.File;
139121
ItemImage = new BitmapImage();
140122
StorageFile file = (StorageFile)item;
141-
var thumbnail = await file.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.SingleItem, 30, Windows.Storage.FileProperties.ThumbnailOptions.UseCurrentScale);
123+
var thumbnail = await file.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.ListView, 24, Windows.Storage.FileProperties.ThumbnailOptions.UseCurrentScale);
142124
if (thumbnail == null)
143125
{
144126
ItemEmptyImgVis = Visibility.Visible;
145127
}
146128
else
147129
{
148-
await ItemImage.SetSourceAsync(thumbnail.CloneStream());
130+
await ItemImage.SetSourceAsync(thumbnail);
149131
ItemEmptyImgVis = Visibility.Collapsed;
150132
}
151133
ItemFolderImgVis = Visibility.Collapsed;
@@ -214,7 +196,7 @@ private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
214196
{
215197
recentItemsCollection.Clear();
216198
RecentsView.ItemsSource = null;
217-
var mru = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList;
199+
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
218200
mru.Clear();
219201
Empty.Visibility = Visibility.Visible;
220202
}

Files/Views/LayoutModes/GenericFileBrowser.xaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@
149149
<FontIcon FontFamily="{StaticResource FluentUIGlyphs}" Glyph="&#xe9b2;" />
150150
</MenuFlyoutItem.Icon>
151151
<MenuFlyoutItem.KeyboardAccelerators>
152-
<KeyboardAccelerator Modifiers="Control" Key="V" IsEnabled="False" />
152+
<KeyboardAccelerator
153+
Key="V"
154+
IsEnabled="False"
155+
Modifiers="Control" />
153156
</MenuFlyoutItem.KeyboardAccelerators>
154157
</MenuFlyoutItem>
155158
<MenuFlyoutSeparator />
@@ -172,7 +175,10 @@
172175
<FontIcon FontFamily="{StaticResource FluentUIGlyphs}" Glyph="&#xe903;" />
173176
</MenuFlyoutSubItem.Icon>
174177
<MenuFlyoutSubItem.KeyboardAccelerators>
175-
<KeyboardAccelerator Modifiers="Control,Shift" Key="N" IsEnabled="False" />
178+
<KeyboardAccelerator
179+
Key="N"
180+
IsEnabled="False"
181+
Modifiers="Control,Shift" />
176182
</MenuFlyoutSubItem.KeyboardAccelerators>
177183
<MenuFlyoutItem
178184
x:Name="NewFolder"
@@ -424,7 +430,10 @@
424430
<FontIcon FontFamily="{StaticResource CustomGlyph}" Glyph="&#xF105;" />
425431
</MenuFlyoutItem.Icon>
426432
<MenuFlyoutItem.KeyboardAccelerators>
427-
<KeyboardAccelerator Modifiers="Control" Key="X" IsEnabled="False" />
433+
<KeyboardAccelerator
434+
Key="X"
435+
IsEnabled="False"
436+
Modifiers="Control" />
428437
</MenuFlyoutItem.KeyboardAccelerators>
429438
</MenuFlyoutItem>
430439
<MenuFlyoutItem
@@ -436,7 +445,10 @@
436445
<FontIcon FontFamily="{StaticResource FluentUIGlyphs}" Glyph="&#xe9d6;" />
437446
</MenuFlyoutItem.Icon>
438447
<MenuFlyoutItem.KeyboardAccelerators>
439-
<KeyboardAccelerator Modifiers="Control" Key="C" IsEnabled="False" />
448+
<KeyboardAccelerator
449+
Key="C"
450+
IsEnabled="False"
451+
Modifiers="Control" />
440452
</MenuFlyoutItem.KeyboardAccelerators>
441453
</MenuFlyoutItem>
442454
<MenuFlyoutItem

Files/Views/Pages/PropertiesGeneral.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@
362362
<CheckBox
363363
x:Uid="PropertiesDialogReadOnly"
364364
Content="Read-only"
365-
IsEnabled="{x:Bind ViewModel.IsReadOnlyEnabled, Mode=OneWay}"
366-
IsChecked="{x:Bind ViewModel.IsReadOnly, Mode=TwoWay}"/>
365+
IsChecked="{x:Bind ViewModel.IsReadOnly, Mode=TwoWay}"
366+
IsEnabled="{x:Bind ViewModel.IsReadOnlyEnabled, Mode=OneWay}" />
367367
<CheckBox
368368
x:Uid="PropertiesDialogHidden"
369369
Content="Hidden"

0 commit comments

Comments
 (0)