Beispiel #1
0
 private static bool Check(ContextMenuFlyoutItemViewModel item, CurrentInstanceViewModel currentInstanceViewModel, List <ListedItem> selectedItems, bool shiftPressed)
 {
     return((item.ShowInRecycleBin || !currentInstanceViewModel.IsPageTypeRecycleBin) && // Hide non-recycle bin items
            (!item.ShowInCloudDrive || currentInstanceViewModel.IsPageTypeCloudDrive) && // Hide non-cloud drive items
            (!item.SingleItemOnly || selectedItems.Count == 1) &&
            item.ShowItem);
 }
 public static List <ContextMenuFlyoutItemViewModel> GetBaseLayoutMenuItems(CurrentInstanceViewModel currentInstanceViewModel, ItemViewModel itemViewModel, BaseLayoutCommandsViewModel commandsViewModel)
 {
     return(new List <ContextMenuFlyoutItemViewModel>()
     {
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "ContextMenuMoreItemsLabel".GetLocalized(),
             Glyph = "\xE712",
             ID = "ItemOverflow"
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutLayoutMode/Text".GetLocalized(),
             Glyph = "\uE152",
             ShowInRecycleBin = true,
             Items = new List <ContextMenuFlyoutItemViewModel>()
             {
                 // Details view
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutDetails/Text".GetLocalized(),
                     Glyph = "\uE179",
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ToggleLayoutModeDetailsView,
                     CommandParameter = true,
                     KeyboardAccelerator = new KeyboardAccelerator {
                         Key = VirtualKey.Number1, Modifiers = VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift, IsEnabled = false
                     }
                 },
                 // Tiles view
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutTilesView/Text".GetLocalized(),
                     Glyph = "\uE15C",
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ToggleLayoutModeTiles,
                     CommandParameter = true,
                     KeyboardAccelerator = new KeyboardAccelerator {
                         Key = VirtualKey.Number2, Modifiers = VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift, IsEnabled = false
                     }
                 },
                 // Grid view small
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutGridViewSmall/Text".GetLocalized(),
                     Glyph = "\uE80A",
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ToggleLayoutModeGridViewSmall,
                     CommandParameter = true,
                     KeyboardAccelerator = new KeyboardAccelerator {
                         Key = VirtualKey.Number3, Modifiers = VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift, IsEnabled = false
                     }
                 },
                 // Grid view medium
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutGridViewMedium/Text".GetLocalized(),
                     Glyph = "\uF0E2",
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ToggleLayoutModeGridViewMedium,
                     CommandParameter = true,
                     KeyboardAccelerator = new KeyboardAccelerator {
                         Key = VirtualKey.Number4, Modifiers = VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift, IsEnabled = false
                     }
                 },
                 // Grid view large
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutGridViewLarge/Text".GetLocalized(),
                     Glyph = "\uE739",
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ToggleLayoutModeGridViewLarge,
                     CommandParameter = true,
                     KeyboardAccelerator = new KeyboardAccelerator {
                         Key = VirtualKey.Number5, Modifiers = VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift, IsEnabled = false
                     }
                 },
                 // Column view
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutColumn/Text".GetLocalized(),
                     Glyph = "\uF115",
                     GlyphFontFamilyName = "CustomGlyph",
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ToggleLayoutModeColumnView,
                     CommandParameter = true,
                     KeyboardAccelerator = new KeyboardAccelerator {
                         Key = VirtualKey.Number6, Modifiers = VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift, IsEnabled = false
                     }
                 },
             }
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutSortBy/Text".GetLocalized(),
             Glyph = "\uE8CB",
             ShowInRecycleBin = true,
             Items = new List <ContextMenuFlyoutItemViewModel>()
             {
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByName/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedByName,
                     ShowInRecycleBin = true,
                     Command = new RelayCommand(() => itemViewModel.IsSortedByName = true),
                     ItemType = ItemType.Toggle,
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByOriginalPath/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedByOriginalPath,
                     ShowInRecycleBin = true,
                     Command = new RelayCommand(() => itemViewModel.IsSortedByOriginalPath = true),
                     ShowItem = currentInstanceViewModel.IsPageTypeRecycleBin,
                     ItemType = ItemType.Toggle,
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByDateDeleted/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedByDateDeleted,
                     Command = new RelayCommand(() => itemViewModel.IsSortedByDateDeleted = true),
                     ShowInRecycleBin = true,
                     ShowItem = currentInstanceViewModel.IsPageTypeRecycleBin,
                     ItemType = ItemType.Toggle
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByType/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedByType,
                     Command = new RelayCommand(() => itemViewModel.IsSortedByType = true),
                     ShowInRecycleBin = true,
                     ItemType = ItemType.Toggle
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortBySize/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedBySize,
                     Command = new RelayCommand(() => itemViewModel.IsSortedBySize = true),
                     ShowInRecycleBin = true,
                     ItemType = ItemType.Toggle
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByDate/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedByDate,
                     Command = new RelayCommand(() => itemViewModel.IsSortedByDate = true),
                     ShowInRecycleBin = true,
                     ItemType = ItemType.Toggle
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByDateCreated/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedByDateCreated,
                     Command = new RelayCommand(() => itemViewModel.IsSortedByDateCreated = true),
                     ShowInRecycleBin = true,
                     ItemType = ItemType.Toggle
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     ItemType = ItemType.Separator,
                     ShowInRecycleBin = true,
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByAscending/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedAscending,
                     Command = new RelayCommand(() => itemViewModel.IsSortedAscending = true),
                     ShowInRecycleBin = true,
                     ItemType = ItemType.Toggle
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByDescending/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedDescending,
                     Command = new RelayCommand(() => itemViewModel.IsSortedDescending = true),
                     ShowInRecycleBin = true,
                     ItemType = ItemType.Toggle
                 },
             }
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "NavToolbarGroupByRadioButtons/Header".GetLocalized(),
             Glyph = "\uF168",
             ShowInRecycleBin = true,
             Items = new List <ContextMenuFlyoutItemViewModel>()
             {
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "NavToolbarGroupByOption_None/Content".GetLocalized(),
                     IsChecked = currentInstanceViewModel.FolderSettings.DirectoryGroupOption == GroupOption.None,
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ChangeGroupOptionCommand,
                     CommandParameter = GroupOption.None,
                     ItemType = ItemType.Toggle,
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByName/Text".GetLocalized(),
                     IsChecked = currentInstanceViewModel.FolderSettings.DirectoryGroupOption == GroupOption.Name,
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ChangeGroupOptionCommand,
                     CommandParameter = GroupOption.Name,
                     ItemType = ItemType.Toggle,
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "NavToolbarArrangementOption_OriginalFolder/Content".GetLocalized(),
                     IsChecked = currentInstanceViewModel.FolderSettings.DirectoryGroupOption == GroupOption.OriginalFolder,
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ChangeGroupOptionCommand,
                     CommandParameter = GroupOption.OriginalFolder,
                     ItemType = ItemType.Toggle,
                     ShowItem = currentInstanceViewModel.IsPageTypeRecycleBin,
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByDateDeleted/Text".GetLocalized(),
                     IsChecked = currentInstanceViewModel.FolderSettings.DirectoryGroupOption == GroupOption.DateDeleted,
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ChangeGroupOptionCommand,
                     CommandParameter = GroupOption.DateDeleted,
                     ItemType = ItemType.Toggle,
                     ShowItem = currentInstanceViewModel.IsPageTypeRecycleBin,
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByDate/Text".GetLocalized(),
                     IsChecked = currentInstanceViewModel.FolderSettings.DirectoryGroupOption == GroupOption.DateModified,
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ChangeGroupOptionCommand,
                     CommandParameter = GroupOption.DateModified,
                     ItemType = ItemType.Toggle,
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByDateCreated/Text".GetLocalized(),
                     IsChecked = currentInstanceViewModel.FolderSettings.DirectoryGroupOption == GroupOption.DateCreated,
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ChangeGroupOptionCommand,
                     CommandParameter = GroupOption.DateCreated,
                     ItemType = ItemType.Toggle,
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByType/Text".GetLocalized(),
                     IsChecked = currentInstanceViewModel.FolderSettings.DirectoryGroupOption == GroupOption.FileType,
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ChangeGroupOptionCommand,
                     CommandParameter = GroupOption.FileType,
                     ItemType = ItemType.Toggle,
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortBySize/Text".GetLocalized(),
                     IsChecked = currentInstanceViewModel.FolderSettings.DirectoryGroupOption == GroupOption.Size,
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ChangeGroupOptionCommand,
                     CommandParameter = GroupOption.Size,
                     ItemType = ItemType.Toggle,
                 },
             }
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutRefresh/Text".GetLocalized(),
             Glyph = "\uE72C",
             ShowInRecycleBin = true,
             Command = commandsViewModel.RefreshCommand,
             KeyboardAccelerator = new KeyboardAccelerator
             {
                 Key = Windows.System.VirtualKey.F5,
                 IsEnabled = false,
             }
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutPaste/Text".GetLocalized(),
             Glyph = "\uE16D",
             Command = commandsViewModel.PasteItemsFromClipboardCommand,
             IsEnabled = currentInstanceViewModel.CanPasteInPage && App.InteractionViewModel.IsPasteEnabled,
             KeyboardAccelerator = new KeyboardAccelerator
             {
                 Key = Windows.System.VirtualKey.V,
                 Modifiers = Windows.System.VirtualKeyModifiers.Control,
                 IsEnabled = false,
             }
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutOpenInTerminal/Text".GetLocalized(),
             Glyph = "\uE756",
             Command = commandsViewModel.OpenDirectoryInDefaultTerminalCommand,
         },
         new ContextMenuFlyoutItemViewModel()
         {
             ItemType = ItemType.Separator,
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutNew/Text".GetLocalized(),
             Glyph = "\uE710",
             KeyboardAccelerator = new KeyboardAccelerator
             {
                 Key = Windows.System.VirtualKey.N,
                 Modifiers = Windows.System.VirtualKeyModifiers.Control,
                 IsEnabled = false,
             },
             Items = GetNewItemItems(commandsViewModel),
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutPinDirectoryToSidebar/Text".GetLocalized(),
             Glyph = "\uE840",
             Command = commandsViewModel.PinDirectoryToSidebarCommand,
             ShowItem = !itemViewModel.CurrentFolder.IsPinned
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutUnpinDirectoryFromSidebar/Text".GetLocalized(),
             Glyph = "\uE77A",
             Command = commandsViewModel.UnpinDirectoryFromSidebarCommand,
             ShowItem = itemViewModel.CurrentFolder.IsPinned
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "PinItemToStart/Text".GetLocalized(),
             Glyph = "\uE840",
             Command = commandsViewModel.PinItemToStartCommand,
             ShowOnShift = true,
             ShowItem = !itemViewModel.CurrentFolder.IsItemPinnedToStart,
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "UnpinItemFromStart/Text".GetLocalized(),
             Glyph = "\uE77A",
             Command = commandsViewModel.UnpinItemFromStartCommand,
             ShowOnShift = true,
             ShowItem = itemViewModel.CurrentFolder.IsItemPinnedToStart,
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutPropertiesFolder/Text".GetLocalized(),
             Glyph = "\uE946",
             Command = commandsViewModel.ShowFolderPropertiesCommand,
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutEmptyRecycleBin/Text".GetLocalized(),
             Glyph = "\uEF88",
             GlyphFontFamilyName = "RecycleBinIcons",
             Command = commandsViewModel.EmptyRecycleBinCommand,
             ShowItem = currentInstanceViewModel.IsPageTypeRecycleBin,
             ShowInRecycleBin = true,
         },
     });
 }
        public static List <ContextMenuFlyoutItemViewModel> Filter(List <ContextMenuFlyoutItemViewModel> items, List <ListedItem> selectedItems, bool shiftPressed, CurrentInstanceViewModel currentInstanceViewModel)
        {
            items = items.Where(x => Check(item: x, currentInstanceViewModel: currentInstanceViewModel, selectedItems: selectedItems, shiftPressed: shiftPressed)).ToList();
            items.ForEach(x => x.Items = x.Items.Where(y => Check(item: y, currentInstanceViewModel: currentInstanceViewModel, selectedItems: selectedItems, shiftPressed: shiftPressed)).ToList());

            var overflow = items.Where(x => x.ID == "ItemOverflow").FirstOrDefault();

            if (overflow != null)
            {
                if (!shiftPressed && App.AppSettings.MoveOverflowMenuItemsToSubMenu) // items with ShowOnShift to overflow menu
                {
                    var overflowItems = items.Where(x => x.ShowOnShift).ToList();

                    // Adds a separator between items already there and the new ones
                    if (overflow.Items.Count != 0 && overflow.Items.Last().ItemType != ItemType.Separator && overflowItems.Count > 0)
                    {
                        overflow.Items.Add(new ContextMenuFlyoutItemViewModel {
                            ItemType = ItemType.Separator
                        });
                    }

                    items = items.Except(overflowItems).ToList();
                    overflowItems.ForEach(x => overflow.Items.Add(x));
                }

                // remove the overflow if it has no child items
                if (overflow.Items.Count == 0)
                {
                    items.Remove(overflow);
                }
            }

            return(items);
        }
        public static List <ContextMenuFlyoutItemViewModel> GetBaseContextCommands(NamedPipeAsAppServiceConnection connection, CurrentInstanceViewModel currentInstanceViewModel, ItemViewModel itemViewModel, BaseLayoutCommandsViewModel commandsViewModel, bool shiftPressed, bool showOpenMenu)
        {
            var menuItemsList = ShellContextmenuHelper.SetShellContextmenu(GetBaseLayoutMenuItems(currentInstanceViewModel, itemViewModel, commandsViewModel), shiftPressed, showOpenMenu, connection, itemViewModel.WorkingDirectory, new List <ListedItem>());

            menuItemsList = Filter(items: menuItemsList, shiftPressed: shiftPressed, currentInstanceViewModel: currentInstanceViewModel, selectedItems: new List <ListedItem>());
            return(menuItemsList);
        }
        public static List <ContextMenuFlyoutItemViewModel> GetItemContextCommands(NamedPipeAsAppServiceConnection connection, CurrentInstanceViewModel currentInstanceViewModel, string workingDir, List <ListedItem> selectedItems, BaseLayoutCommandsViewModel commandsViewModel, bool shiftPressed, bool showOpenMenu, SelectedItemsPropertiesViewModel selectedItemsPropertiesViewModel)
        {
            var menuItemsList = ShellContextmenuHelper.SetShellContextmenu(GetBaseItemMenuItems(commandsViewModel: commandsViewModel, selectedItems: selectedItems, selectedItemsPropertiesViewModel: selectedItemsPropertiesViewModel), shiftPressed: shiftPressed, showOpenMenu: showOpenMenu, connection: connection, workingDirectory: workingDir, selectedItems: selectedItems);

            menuItemsList = Filter(items: menuItemsList, shiftPressed: shiftPressed, currentInstanceViewModel: currentInstanceViewModel, selectedItems: selectedItems);
            return(menuItemsList);
        }
 public static async Task <List <ContextMenuFlyoutItemViewModel> > GetBaseContextShellCommandsAsync(NamedPipeAsAppServiceConnection connection, CurrentInstanceViewModel currentInstanceViewModel, string workingDir, bool shiftPressed, bool showOpenMenu)
 {
     return(await ShellContextmenuHelper.GetShellContextmenuAsync(shiftPressed, showOpenMenu, connection, workingDir, new List <ListedItem>()));
 }
        public static List <ContextMenuFlyoutItemViewModel> GetBaseContextCommandsWithoutShellItems(NamedPipeAsAppServiceConnection connection, CurrentInstanceViewModel currentInstanceViewModel, ItemViewModel itemViewModel, BaseLayoutCommandsViewModel commandsViewModel, bool shiftPressed, bool showOpenMenu)
        {
            var menuItemsList = GetBaseLayoutMenuItems(currentInstanceViewModel, itemViewModel, commandsViewModel);

            menuItemsList = Filter(items: menuItemsList, shiftPressed: shiftPressed, currentInstanceViewModel: currentInstanceViewModel, selectedItems: new List <ListedItem>(), removeOverflowMenu: false);
            return(menuItemsList);
        }
        public static List <ContextMenuFlyoutItemViewModel> GetItemContextCommandsWithoutShellItems(CurrentInstanceViewModel currentInstanceViewModel, string workingDir, List <ListedItem> selectedItems, BaseLayoutCommandsViewModel commandsViewModel, bool shiftPressed, bool showOpenMenu, SelectedItemsPropertiesViewModel selectedItemsPropertiesViewModel)
        {
            var menuItemsList = GetBaseItemMenuItems(commandsViewModel: commandsViewModel, selectedItems: selectedItems, selectedItemsPropertiesViewModel: selectedItemsPropertiesViewModel);

            menuItemsList = Filter(items: menuItemsList, shiftPressed: shiftPressed, currentInstanceViewModel: currentInstanceViewModel, selectedItems: selectedItems, removeOverflowMenu: false);
            return(menuItemsList);
        }