|
1 | 1 | using Files.DataModels;
|
2 | 2 | using Files.DataModels.NavigationControlItems;
|
| 3 | +using Files.Extensions; |
3 | 4 | using Files.Filesystem;
|
4 | 5 | using Files.Filesystem.StorageItems;
|
5 | 6 | using Files.Helpers;
|
@@ -374,6 +375,12 @@ private void NavigationViewLocationItem_RightTapped(object sender, RightTappedRo
|
374 | 375 | RightClickedItem = item;
|
375 | 376 | var menuItems = GetLocationItemMenuItems();
|
376 | 377 | var (_, secondaryElements) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(menuItems);
|
| 378 | + |
| 379 | + if (!App.AppSettings.MoveOverflowMenuItemsToSubMenu) |
| 380 | + { |
| 381 | + secondaryElements.OfType<FrameworkElement>().ForEach(i => i.MinWidth = 250); // Set menu min width if the overflow menu setting is disabled |
| 382 | + } |
| 383 | + |
377 | 384 | secondaryElements.ForEach(i => itemContextMenuFlyout.SecondaryCommands.Add(i));
|
378 | 385 | itemContextMenuFlyout.ShowAt(sidebarItem, new Windows.UI.Xaml.Controls.Primitives.FlyoutShowOptions() { Position = e.GetPosition(sidebarItem) });
|
379 | 386 |
|
@@ -420,6 +427,12 @@ private void NavigationViewDriveItem_RightTapped(object sender, RightTappedRoute
|
420 | 427 | RightClickedItem = item;
|
421 | 428 | var menuItems = GetLocationItemMenuItems();
|
422 | 429 | var (_, secondaryElements) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(menuItems);
|
| 430 | + |
| 431 | + if (!App.AppSettings.MoveOverflowMenuItemsToSubMenu) |
| 432 | + { |
| 433 | + secondaryElements.OfType<FrameworkElement>().ForEach(i => i.MinWidth = 250); // Set menu min width if the overflow menu setting is disabled |
| 434 | + } |
| 435 | + |
423 | 436 | secondaryElements.ForEach(i => itemContextMenuFlyout.SecondaryCommands.Add(i));
|
424 | 437 | itemContextMenuFlyout.ShowAt(sidebarItem, new Windows.UI.Xaml.Controls.Primitives.FlyoutShowOptions() { Position = e.GetPosition(sidebarItem) });
|
425 | 438 |
|
@@ -963,12 +976,32 @@ private async void LoadShellMenuItems(Microsoft.UI.Xaml.Controls.CommandBarFlyou
|
963 | 976 | var shiftPressed = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down);
|
964 | 977 | var shellMenuItems = await ContextFlyoutItemHelper.GetItemContextShellCommandsAsync(connection: await AppServiceConnectionHelper.Instance, currentInstanceViewModel: null, workingDir: null,
|
965 | 978 | new List<ListedItem>() { new ListedItem(null) { ItemPath = RightClickedItem.Path } }, shiftPressed: shiftPressed, showOpenMenu: false);
|
966 |
| - var overflowItems = ItemModelListToContextFlyoutHelper.GetMenuFlyoutItemsFromModel(shellMenuItems); |
967 |
| - var overflowItem = itemContextMenuFlyout.SecondaryCommands.FirstOrDefault(x => x is AppBarButton appBarButton && (appBarButton.Tag as string) == "ItemOverflow") as AppBarButton; |
968 |
| - if (overflowItem is not null) |
| 979 | + if (!App.AppSettings.MoveOverflowMenuItemsToSubMenu) |
| 980 | + { |
| 981 | + var (_, secondaryElements) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(shellMenuItems); |
| 982 | + if (secondaryElements.Any()) |
| 983 | + { |
| 984 | + var openedPopups = Windows.UI.Xaml.Media.VisualTreeHelper.GetOpenPopups(Window.Current); |
| 985 | + var secondaryMenu = openedPopups.FirstOrDefault(popup => popup.Name == "OverflowPopup"); |
| 986 | + var itemsControl = secondaryMenu?.Child.FindDescendant<ItemsControl>(); |
| 987 | + if (itemsControl is not null) |
| 988 | + { |
| 989 | + secondaryElements.OfType<FrameworkElement>().ForEach(x => x.MaxWidth = itemsControl.ActualWidth - 10); // Set items max width to current menu width (#5555) |
| 990 | + } |
| 991 | + |
| 992 | + itemContextMenuFlyout.SecondaryCommands.Add(new AppBarSeparator()); |
| 993 | + secondaryElements.ForEach(i => itemContextMenuFlyout.SecondaryCommands.Add(i)); |
| 994 | + } |
| 995 | + } |
| 996 | + else |
969 | 997 | {
|
970 |
| - overflowItems.ForEach(i => (overflowItem.Flyout as MenuFlyout).Items.Add(i)); |
971 |
| - overflowItem.Visibility = overflowItems.Any() ? Visibility.Visible : Visibility.Collapsed; |
| 998 | + var overflowItems = ItemModelListToContextFlyoutHelper.GetMenuFlyoutItemsFromModel(shellMenuItems); |
| 999 | + var overflowItem = itemContextMenuFlyout.SecondaryCommands.FirstOrDefault(x => x is AppBarButton appBarButton && (appBarButton.Tag as string) == "ItemOverflow") as AppBarButton; |
| 1000 | + if (overflowItem is not null) |
| 1001 | + { |
| 1002 | + overflowItems.ForEach(i => (overflowItem.Flyout as MenuFlyout).Items.Add(i)); |
| 1003 | + overflowItem.Visibility = overflowItems.Any() ? Visibility.Visible : Visibility.Collapsed; |
| 1004 | + } |
972 | 1005 | }
|
973 | 1006 | }
|
974 | 1007 | }
|
|
0 commit comments