Skip to content

Commit 6465306

Browse files
committed
A rough impl to get thumbnail of the items for the root item chevron flyout
1 parent 686264e commit 6465306

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

src/Files.App/UserControls/NavigationToolbar.xaml.cs

+27-4
Original file line numberDiff line numberDiff line change
@@ -295,16 +295,39 @@ private async void BreadcrumbBar_ItemDropDownFlyoutOpening(object sender, Breadc
295295
if (storable is not IWindowsStorable windowsStorable)
296296
continue;
297297

298-
e.Flyout.Items.Add(new MenuFlyoutItem() { Text = windowsStorable.GetDisplayName(Windows.Win32.UI.Shell.SIGDN.SIGDN_PARENTRELATIVEFORUI) });
298+
var flyoutItem = new MenuFlyoutItem()
299+
{
300+
Text = windowsStorable.GetDisplayName(Windows.Win32.UI.Shell.SIGDN.SIGDN_PARENTRELATIVEFORUI),
301+
Icon = new FontIcon { Glyph = "\uE8B7" }, // Use font icon as placeholder
302+
};
303+
304+
e.Flyout.Items.Add(flyoutItem);
305+
306+
windowsStorable.TryGetThumbnail((int)(16f * App.AppModel.AppWindowDPI), Windows.Win32.UI.Shell.SIIGBF.SIIGBF_ICONONLY, out var thumbnailData);
307+
flyoutItem.Icon = new ImageIcon() { Source = await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => thumbnailData.ToBitmapAsync(), Microsoft.UI.Dispatching.DispatcherQueuePriority.Normal) };
308+
299309
windowsStorable.Dispose();
300310
}
301311

302312
e.Flyout.Items.Add(new MenuFlyoutHeaderItem() { Text = "Drives" });
303313

304-
await foreach (IWindowsStorable storable in homeFolder.GetLogicalDrivesAsync())
314+
await foreach (var storable in homeFolder.GetLogicalDrivesAsync())
305315
{
306-
e.Flyout.Items.Add(new MenuFlyoutItem() { Text = storable.GetDisplayName(Windows.Win32.UI.Shell.SIGDN.SIGDN_PARENTRELATIVEFORUI) });
307-
storable.Dispose();
316+
if (storable is not IWindowsStorable windowsStorable)
317+
continue;
318+
319+
var flyoutItem = new MenuFlyoutItem()
320+
{
321+
Text = windowsStorable.GetDisplayName(Windows.Win32.UI.Shell.SIGDN.SIGDN_PARENTRELATIVEFORUI),
322+
Icon = new FontIcon { Glyph = "\uE8B7" }, // Use font icon as placeholder
323+
};
324+
325+
e.Flyout.Items.Add(flyoutItem);
326+
327+
windowsStorable.TryGetThumbnail((int)(16f * App.AppModel.AppWindowDPI), Windows.Win32.UI.Shell.SIIGBF.SIIGBF_ICONONLY, out var thumbnailData);
328+
flyoutItem.Icon = new ImageIcon() { Source = await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => thumbnailData.ToBitmapAsync(), Microsoft.UI.Dispatching.DispatcherQueuePriority.Normal) };
329+
330+
windowsStorable.Dispose();
308331
}
309332

310333
return;

src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs

-2
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,6 @@ public async Task SetPathBoxDropDownFlyoutAsync(MenuFlyout flyout, PathBoxItem p
839839
Icon = new FontIcon { Glyph = "\uE7BA" },
840840
Text = Strings.SubDirectoryAccessDenied.GetLocalizedResource(),
841841
//Foreground = (SolidColorBrush)Application.Current.Resources["SystemControlErrorTextForegroundBrush"],
842-
FontSize = 12
843842
};
844843

845844
flyout.Items?.Add(flyoutItem);
@@ -859,7 +858,6 @@ public async Task SetPathBoxDropDownFlyoutAsync(MenuFlyout flyout, PathBoxItem p
859858
{
860859
Icon = new FontIcon { Glyph = "\uE8B7" }, // Use font icon as placeholder
861860
Text = childFolder.Item.Name,
862-
FontSize = 12,
863861
};
864862

865863
if (workingPath != childFolder.Path)

0 commit comments

Comments
 (0)