From ff0122f811f374f6a0e0caf0c759f3c69bc3071c Mon Sep 17 00:00:00 2001 From: 0x5bfa <62196528+0x5bfa@users.noreply.github.com> Date: Wed, 12 Jun 2024 16:32:32 +0900 Subject: [PATCH 1/4] Init --- .../FileSystem/PasteItemToSelectionAction.cs | 2 +- .../OpenInNewTab/BaseOpenInNewTabAction.cs | 2 +- .../BaseOpenInNewWindowAction.cs | 4 +- .../Sidebar/PinFolderToSidebarAction.cs | 2 +- .../Sidebar/UnpinFolderToSidebarAction.cs | 2 +- .../Actions/Start/PinToStartAction.cs | 2 +- .../Actions/Start/UnpinFromStartAction.cs | 2 +- .../ContentPage/ContentPageContext.cs | 14 +- .../ContentPage/IContentPageContext.cs | 6 +- .../Data/Contexts/SideBar/ISideBarContext.cs | 2 +- .../Data/Contexts/SideBar/SideBarContext.cs | 8 +- ...vigationControlItem.cs => ISidebarItem.cs} | 10 +- .../Data/Contracts/IStorageArchiveService.cs | 6 +- .../ContentPageContextFlyoutFactory.cs | 10 +- .../PropertiesNavigationViewItemFactory.cs | 4 +- .../Factories/ShellContextFlyoutHelper.cs | 4 +- src/Files.App/Data/Items/FileTagItem.cs | 10 +- src/Files.App/Data/Items/LocationItem.cs | 16 +- .../{DriveItem.cs => SidebarDriveItem.cs} | 8 +- .../Data/Items/SidebarLibraryItem.cs | 2 +- src/Files.App/Data/Items/StandardFtpItem.cs | 52 +++++ .../Data/Items/StandardRecycleBinItem.cs | 55 ++++++ .../{ListedItem.cs => StandardStorageItem.cs} | 144 +++++--------- src/Files.App/Data/Items/WslDistroItem.cs | 10 +- .../Data/Models/ItemManipulationModel.cs | 24 +-- src/Files.App/Data/Models/ItemViewModel.cs | 62 +++--- .../Data/Models/PinnedFoldersManager.cs | 16 +- src/Files.App/Data/Models/SuggestionModel.cs | 2 +- .../Helpers/Layout/AdaptiveLayoutHelpers.cs | 12 +- .../Helpers/Navigation/NavigationHelpers.cs | 4 +- src/Files.App/Helpers/ShareItemHelpers.cs | 6 +- .../Helpers/UI/UIFilesystemHelpers.cs | 14 +- .../Services/Storage/StorageArchiveService.cs | 6 +- .../Services/Storage/StorageNetworkService.cs | 6 +- .../UserControls/Menus/FileTagsContextMenu.cs | 8 +- .../Utils/Cloud/CloudDrivesManager.cs | 2 +- .../Utils/FileTags/FileTagsManager.cs | 4 +- .../Utils/Global/WSLDistroManager.cs | 2 +- src/Files.App/Utils/Library/LibraryManager.cs | 10 +- .../Utils/RecycleBin/RecycleBinHelpers.cs | 4 +- .../Storage/Collection/GroupingHelper.cs | 24 +-- .../Utils/Storage/Collection/SortingHelper.cs | 14 +- .../Enumerators/UniversalStorageEnumerator.cs | 26 +-- .../Enumerators/Win32StorageEnumerator.cs | 18 +- .../Storage/Helpers/StorageFileExtensions.cs | 2 +- .../Utils/Storage/Search/FolderSearch.cs | 46 ++--- .../Storage/StorageItems/FtpStorageFile.cs | 2 +- .../StorageItems/VirtualStorageItem.cs | 2 +- .../ReorderSidebarItemsDialogViewModel.cs | 2 +- .../ViewModels/Layouts/BaseLayoutViewModel.cs | 2 +- .../Properties/BasePropertiesPage.cs | 4 +- .../Properties/CompatibilityViewModel.cs | 2 +- .../Properties/CustomizationViewModel.cs | 2 +- .../ViewModels/Properties/HashesViewModel.cs | 4 +- .../Items/CombinedFileProperties.cs | 2 +- .../Properties/Items/CombinedProperties.cs | 6 +- .../Properties/Items/FileProperties.cs | 6 +- .../Properties/Items/FolderProperties.cs | 8 +- .../Properties/SecurityAdvancedViewModel.cs | 4 +- .../Properties/SecurityViewModel.cs | 4 +- .../UserControls/AddressToolbarViewModel.cs | 4 +- .../UserControls/InfoPaneViewModel.cs | 14 +- .../Previews/ArchivePreviewViewModel.cs | 2 +- .../UserControls/Previews/BasePreviewModel.cs | 8 +- .../Previews/BasicPreviewViewModel.cs | 2 +- .../Previews/CodePreviewViewModel.cs | 2 +- .../Previews/FolderPreviewViewModel.cs | 4 +- .../Previews/HtmlPreviewViewModel.cs | 2 +- .../Previews/ImagePreviewViewModel.cs | 2 +- .../Previews/MarkdownPreviewViewModel.cs | 2 +- .../Previews/MediaPreviewViewModel.cs | 2 +- .../Previews/PDFPreviewViewModel.cs | 2 +- .../Previews/RichTextPreviewViewModel.cs | 2 +- .../Previews/ShellPreviewViewModel.cs | 2 +- .../Previews/ShortcutPreviewViewModel.cs | 2 +- .../Previews/TextPreviewViewModel.cs | 4 +- .../UserControls/SidebarViewModel.cs | 178 +++++++++--------- .../Widgets/FileTagsWidgetViewModel.cs | 2 +- .../Widgets/QuickAccessWidgetViewModel.cs | 2 +- .../Views/Layouts/BaseGroupableLayoutPage.cs | 14 +- src/Files.App/Views/Layouts/BaseLayoutPage.cs | 54 +++--- .../Views/Layouts/ColumnLayoutPage.xaml.cs | 16 +- .../Views/Layouts/DetailsLayoutPage.xaml.cs | 48 ++--- .../Views/Layouts/GridLayoutPage.xaml.cs | 22 +-- .../Views/Layouts/IBaseLayoutPage.cs | 4 +- .../Properties/CompatibilityPage.xaml.cs | 2 +- .../Views/Properties/GeneralPage.xaml.cs | 4 +- .../Views/Properties/HashesPage.xaml.cs | 2 +- src/Files.App/Views/Shells/BaseShellPage.cs | 2 +- 89 files changed, 599 insertions(+), 546 deletions(-) rename src/Files.App/Data/Contracts/{INavigationControlItem.cs => ISidebarItem.cs} (76%) rename src/Files.App/Data/Items/{DriveItem.cs => SidebarDriveItem.cs} (96%) create mode 100644 src/Files.App/Data/Items/StandardFtpItem.cs create mode 100644 src/Files.App/Data/Items/StandardRecycleBinItem.cs rename src/Files.App/Data/Items/{ListedItem.cs => StandardStorageItem.cs} (77%) diff --git a/src/Files.App/Actions/FileSystem/PasteItemToSelectionAction.cs b/src/Files.App/Actions/FileSystem/PasteItemToSelectionAction.cs index 515d7b118260..1c9611c3c053 100644 --- a/src/Files.App/Actions/FileSystem/PasteItemToSelectionAction.cs +++ b/src/Files.App/Actions/FileSystem/PasteItemToSelectionAction.cs @@ -35,7 +35,7 @@ public async Task ExecuteAsync(object? parameter = null) if (context.ShellPage is null) return; - string path = context.SelectedItem is ListedItem selectedItem + string path = context.SelectedItem is StandardStorageItem selectedItem ? selectedItem.ItemPath : context.ShellPage.FilesystemViewModel.WorkingDirectory; diff --git a/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs b/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs index 7f5ca8c797ae..91d616e051e0 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs @@ -37,7 +37,7 @@ public BaseOpenInNewTabAction() public virtual async Task ExecuteAsync(object? parameter = null) { - foreach (ListedItem listedItem in ContentPageContext.SelectedItems) + foreach (StandardStorageItem listedItem in ContentPageContext.SelectedItems) { await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(async () => { diff --git a/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs b/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs index 428447962740..ca76483c2270 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs @@ -45,9 +45,9 @@ public virtual async Task ExecuteAsync(object? parameter = null) if (ContentPageContext.ShellPage?.SlimContentPage?.SelectedItems is null) return; - List items = ContentPageContext.ShellPage.SlimContentPage.SelectedItems; + List items = ContentPageContext.ShellPage.SlimContentPage.SelectedItems; - foreach (ListedItem listedItem in items) + foreach (StandardStorageItem listedItem in items) { var selectedItemPath = (listedItem as ShortcutItem)?.TargetPath ?? listedItem.ItemPath; var folderUri = new Uri($"files-uwp:?folder={@selectedItemPath}"); diff --git a/src/Files.App/Actions/Sidebar/PinFolderToSidebarAction.cs b/src/Files.App/Actions/Sidebar/PinFolderToSidebarAction.cs index dda75fed7bf7..c8608104af68 100644 --- a/src/Files.App/Actions/Sidebar/PinFolderToSidebarAction.cs +++ b/src/Files.App/Actions/Sidebar/PinFolderToSidebarAction.cs @@ -53,7 +53,7 @@ private bool GetIsExecutable() ? context.SelectedItems.All(IsPinnable) : context.Folder is not null && IsPinnable(context.Folder); - bool IsPinnable(ListedItem item) + bool IsPinnable(StandardStorageItem item) { return item.PrimaryItemAttribute is StorageItemTypes.Folder && diff --git a/src/Files.App/Actions/Sidebar/UnpinFolderToSidebarAction.cs b/src/Files.App/Actions/Sidebar/UnpinFolderToSidebarAction.cs index fd738d74983d..a509f3cc5163 100644 --- a/src/Files.App/Actions/Sidebar/UnpinFolderToSidebarAction.cs +++ b/src/Files.App/Actions/Sidebar/UnpinFolderToSidebarAction.cs @@ -50,7 +50,7 @@ private bool GetIsExecutable() ? context.SelectedItems.All(IsPinned) : context.Folder is not null && IsPinned(context.Folder); - bool IsPinned(ListedItem item) + bool IsPinned(StandardStorageItem item) { return pinnedFolders.Contains(item.ItemPath); } diff --git a/src/Files.App/Actions/Start/PinToStartAction.cs b/src/Files.App/Actions/Start/PinToStartAction.cs index 7228ba483bf1..7d07e3c152b9 100644 --- a/src/Files.App/Actions/Start/PinToStartAction.cs +++ b/src/Files.App/Actions/Start/PinToStartAction.cs @@ -35,7 +35,7 @@ public async Task ExecuteAsync(object? parameter = null) { if (context.SelectedItems.Count > 0 && context.ShellPage?.SlimContentPage?.SelectedItems is not null) { - foreach (ListedItem listedItem in context.ShellPage.SlimContentPage.SelectedItems) + foreach (StandardStorageItem listedItem in context.ShellPage.SlimContentPage.SelectedItems) { IStorable storable = listedItem.IsFolder switch { diff --git a/src/Files.App/Actions/Start/UnpinFromStartAction.cs b/src/Files.App/Actions/Start/UnpinFromStartAction.cs index 145412fc32fb..dc757be96000 100644 --- a/src/Files.App/Actions/Start/UnpinFromStartAction.cs +++ b/src/Files.App/Actions/Start/UnpinFromStartAction.cs @@ -31,7 +31,7 @@ public async Task ExecuteAsync(object? parameter = null) { if (context.SelectedItems.Count > 0) { - foreach (ListedItem listedItem in context.ShellPage?.SlimContentPage.SelectedItems) + foreach (StandardStorageItem listedItem in context.ShellPage?.SlimContentPage.SelectedItems) { IStorable storable = listedItem.IsFolder switch { diff --git a/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs b/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs index 73adf23d8db9..c5da3c256a08 100644 --- a/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs +++ b/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs @@ -8,7 +8,7 @@ namespace Files.App.Data.Contexts { internal sealed class ContentPageContext : ObservableObject, IContentPageContext { - private static readonly IReadOnlyList emptyItems = Enumerable.Empty().ToImmutableList(); + private static readonly IReadOnlyList emptyItems = Enumerable.Empty().ToImmutableList(); private readonly IMultiPanesContext context = Ioc.Default.GetRequiredService(); @@ -21,15 +21,15 @@ internal sealed class ContentPageContext : ObservableObject, IContentPageContext private ContentPageTypes pageType = ContentPageTypes.None; public ContentPageTypes PageType => pageType; - public ListedItem? Folder => ShellPage?.FilesystemViewModel?.CurrentFolder; + public StandardStorageItem? Folder => ShellPage?.FilesystemViewModel?.CurrentFolder; public bool HasItem => ShellPage?.ToolbarViewModel?.HasItem ?? false; public bool HasSelection => SelectedItems.Count is not 0; - public ListedItem? SelectedItem => SelectedItems.Count is 1 ? SelectedItems[0] : null; + public StandardStorageItem? SelectedItem => SelectedItems.Count is 1 ? SelectedItems[0] : null; - private IReadOnlyList selectedItems = emptyItems; - public IReadOnlyList SelectedItems => selectedItems; + private IReadOnlyList selectedItems = emptyItems; + public IReadOnlyList SelectedItems => selectedItems; public bool CanRefresh => ShellPage is not null && ShellPage.ToolbarViewModel.CanRefresh; @@ -226,9 +226,9 @@ private void UpdatePageType() private void UpdateSelectedItems() { bool oldHasSelection = HasSelection; - ListedItem? oldSelectedItem = SelectedItem; + StandardStorageItem? oldSelectedItem = SelectedItem; - IReadOnlyList items = ShellPage?.ToolbarViewModel?.SelectedItems?.AsReadOnly() ?? emptyItems; + IReadOnlyList items = ShellPage?.ToolbarViewModel?.SelectedItems?.AsReadOnly() ?? emptyItems; if (SetProperty(ref selectedItems, items, nameof(SelectedItems))) { if (HasSelection != oldHasSelection) diff --git a/src/Files.App/Data/Contexts/ContentPage/IContentPageContext.cs b/src/Files.App/Data/Contexts/ContentPage/IContentPageContext.cs index fee811a60828..5742021f182f 100644 --- a/src/Files.App/Data/Contexts/ContentPage/IContentPageContext.cs +++ b/src/Files.App/Data/Contexts/ContentPage/IContentPageContext.cs @@ -11,13 +11,13 @@ public interface IContentPageContext : INotifyPropertyChanged Type PageLayoutType { get; } - ListedItem? Folder { get; } + StandardStorageItem? Folder { get; } bool HasItem { get; } bool HasSelection { get; } bool CanRefresh { get; } - ListedItem? SelectedItem { get; } - IReadOnlyList SelectedItems { get; } + StandardStorageItem? SelectedItem { get; } + IReadOnlyList SelectedItems { get; } bool CanGoBack { get; } bool CanGoForward { get; } diff --git a/src/Files.App/Data/Contexts/SideBar/ISideBarContext.cs b/src/Files.App/Data/Contexts/SideBar/ISideBarContext.cs index 92f1f3e199c1..2b8f653f6e9a 100644 --- a/src/Files.App/Data/Contexts/SideBar/ISideBarContext.cs +++ b/src/Files.App/Data/Contexts/SideBar/ISideBarContext.cs @@ -11,7 +11,7 @@ public interface ISidebarContext /// /// Gets the last sidebar right clicked item /// - INavigationControlItem? RightClickedItem { get; } + ISidebarItem? RightClickedItem { get; } /// /// Gets the value that indicates whether any item has been right clicked diff --git a/src/Files.App/Data/Contexts/SideBar/SideBarContext.cs b/src/Files.App/Data/Contexts/SideBar/SideBarContext.cs index b8412d9f8e3a..0bc158720bfa 100644 --- a/src/Files.App/Data/Contexts/SideBar/SideBarContext.cs +++ b/src/Files.App/Data/Contexts/SideBar/SideBarContext.cs @@ -13,15 +13,15 @@ internal sealed class SidebarContext : ObservableObject, ISidebarContext ? favoriteModel.IndexOfItem(_RightClickedItem!) : -1; - private INavigationControlItem? _RightClickedItem = null; - public INavigationControlItem? RightClickedItem => _RightClickedItem; + private ISidebarItem? _RightClickedItem = null; + public ISidebarItem? RightClickedItem => _RightClickedItem; public bool IsItemRightClicked => _RightClickedItem is not null; public bool IsPinnedFolderItem => IsItemRightClicked && - _RightClickedItem!.Section is SectionType.Pinned && + _RightClickedItem!.Section is SidebarSectionKind.Pinned && PinnedFolderItemIndex is not -1; public DriveItem? OpenDriveItem @@ -32,7 +32,7 @@ public SidebarContext() SidebarViewModel.RightClickedItemChanged += SidebarControl_RightClickedItemChanged; } - public void SidebarControl_RightClickedItemChanged(object? sender, INavigationControlItem? e) + public void SidebarControl_RightClickedItemChanged(object? sender, ISidebarItem? e) { if (SetProperty(ref _RightClickedItem, e, nameof(RightClickedItem))) { diff --git a/src/Files.App/Data/Contracts/INavigationControlItem.cs b/src/Files.App/Data/Contracts/ISidebarItem.cs similarity index 76% rename from src/Files.App/Data/Contracts/INavigationControlItem.cs rename to src/Files.App/Data/Contracts/ISidebarItem.cs index 80dfb5fd2f5b..d04b74700eec 100644 --- a/src/Files.App/Data/Contracts/INavigationControlItem.cs +++ b/src/Files.App/Data/Contracts/ISidebarItem.cs @@ -5,20 +5,20 @@ namespace Files.App.Data.Contracts { - public interface INavigationControlItem : IComparable, INotifyPropertyChanged, ISidebarItemModel + public interface ISidebarItem : IComparable, INotifyPropertyChanged, ISidebarItemModel { public new string Text { get; } public string Path { get; } - public SectionType Section { get; } + public SidebarSectionKind Section { get; } - public NavigationControlItemType ItemType { get; } + public SidebarItemKind ItemType { get; } public ContextMenuOptions MenuOptions { get; } } - public enum NavigationControlItemType + public enum SidebarItemKind { Drive, LinuxDistro, @@ -26,7 +26,7 @@ public enum NavigationControlItemType FileTag } - public enum SectionType + public enum SidebarSectionKind { Home, Pinned, diff --git a/src/Files.App/Data/Contracts/IStorageArchiveService.cs b/src/Files.App/Data/Contracts/IStorageArchiveService.cs index 97b31b86176b..3fb10527e0f9 100644 --- a/src/Files.App/Data/Contracts/IStorageArchiveService.cs +++ b/src/Files.App/Data/Contracts/IStorageArchiveService.cs @@ -15,14 +15,14 @@ public interface IStorageArchiveService /// /// Items to check if they can be compressed. /// True if can be compressed; otherwise, false. - bool CanCompress(IReadOnlyList items); + bool CanCompress(IReadOnlyList items); /// /// Gets the value that indicates whether specified items can be decompressed. /// /// Items to check if they can be decompressed. /// True if can be decompressed; otherwise, false. - bool CanDecompress(IReadOnlyList items); + bool CanDecompress(IReadOnlyList items); /// /// Compresses the specified items. @@ -45,7 +45,7 @@ public interface IStorageArchiveService /// /// Item names to generate archive file name. /// - string GenerateArchiveNameFromItems(IReadOnlyList items); + string GenerateArchiveNameFromItems(IReadOnlyList items); /// /// Gets the value that indicates whether the archive file is encrypted. diff --git a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs index fcfe02824fe2..37559f4ab67c 100644 --- a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs +++ b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs @@ -24,19 +24,19 @@ public static class ContentPageContextFlyoutFactory private static readonly ICommandManager Commands = Ioc.Default.GetRequiredService(); private static IStorageArchiveService StorageArchiveService { get; } = Ioc.Default.GetRequiredService(); - public static List GetItemContextCommandsWithoutShellItems(CurrentInstanceViewModel currentInstanceViewModel, List selectedItems, BaseLayoutViewModel commandsViewModel, bool shiftPressed, SelectedItemsPropertiesViewModel? selectedItemsPropertiesViewModel, ItemViewModel? itemViewModel = null) + public static List GetItemContextCommandsWithoutShellItems(CurrentInstanceViewModel currentInstanceViewModel, List selectedItems, BaseLayoutViewModel commandsViewModel, bool shiftPressed, SelectedItemsPropertiesViewModel? selectedItemsPropertiesViewModel, ItemViewModel? itemViewModel = null) { var menuItemsList = GetBaseItemMenuItems(commandsViewModel: commandsViewModel, selectedItems: selectedItems, selectedItemsPropertiesViewModel: selectedItemsPropertiesViewModel, currentInstanceViewModel: currentInstanceViewModel, itemViewModel: itemViewModel); menuItemsList = Filter(items: menuItemsList, shiftPressed: shiftPressed, currentInstanceViewModel: currentInstanceViewModel, selectedItems: selectedItems, removeOverflowMenu: false); return menuItemsList; } - public static Task> GetItemContextShellCommandsAsync(string workingDir, List selectedItems, bool shiftPressed, bool showOpenMenu, CancellationToken cancellationToken) + public static Task> GetItemContextShellCommandsAsync(string workingDir, List selectedItems, bool shiftPressed, bool showOpenMenu, CancellationToken cancellationToken) { return ShellContextFlyoutFactory.GetShellContextmenuAsync(shiftPressed: shiftPressed, showOpenMenu: showOpenMenu, workingDirectory: workingDir, selectedItems: selectedItems, cancellationToken: cancellationToken); } - public static List Filter(List items, List selectedItems, bool shiftPressed, CurrentInstanceViewModel currentInstanceViewModel, bool removeOverflowMenu = true) + public static List Filter(List items, List selectedItems, bool shiftPressed, CurrentInstanceViewModel currentInstanceViewModel, bool removeOverflowMenu = true) { items = items.Where(x => Check(item: x, currentInstanceViewModel: currentInstanceViewModel, selectedItems: selectedItems)).ToList(); items.ForEach(x => x.Items = x.Items?.Where(y => Check(item: y, currentInstanceViewModel: currentInstanceViewModel, selectedItems: selectedItems)).ToList()); @@ -64,7 +64,7 @@ public static List Filter(List selectedItems) + private static bool Check(ContextMenuFlyoutItemViewModel item, CurrentInstanceViewModel currentInstanceViewModel, List selectedItems) { return (item.ShowInRecycleBin || !currentInstanceViewModel.IsPageTypeRecycleBin) && @@ -78,7 +78,7 @@ private static bool Check(ContextMenuFlyoutItemViewModel item, CurrentInstanceVi public static List GetBaseItemMenuItems( BaseLayoutViewModel commandsViewModel, SelectedItemsPropertiesViewModel? selectedItemsPropertiesViewModel, - List selectedItems, + List selectedItems, CurrentInstanceViewModel currentInstanceViewModel, ItemViewModel? itemViewModel = null) { diff --git a/src/Files.App/Data/Factories/PropertiesNavigationViewItemFactory.cs b/src/Files.App/Data/Factories/PropertiesNavigationViewItemFactory.cs index df4da3b33448..4a6130338f30 100644 --- a/src/Files.App/Data/Factories/PropertiesNavigationViewItemFactory.cs +++ b/src/Files.App/Data/Factories/PropertiesNavigationViewItemFactory.cs @@ -72,7 +72,7 @@ public static ObservableCollection Initialize PropertiesNavigationViewItems.Add(customizationItem); PropertiesNavigationViewItems.Add(compatibilityItem); - if (item is List listedItems) + if (item is List listedItems) { var firstFileExtension = listedItems.FirstOrDefault()?.FileExtension; var commonFileExt = listedItems.All(x => x.FileExtension == firstFileExtension) ? firstFileExtension : null; @@ -91,7 +91,7 @@ public static ObservableCollection Initialize PropertiesNavigationViewItems.Remove(customizationItem); PropertiesNavigationViewItems.Remove(hashesItem); } - else if (item is ListedItem listedItem) + else if (item is StandardStorageItem listedItem) { var isShortcut = listedItem.IsShortcut; var isLibrary = listedItem.IsLibrary; diff --git a/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs b/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs index 38df8e2dc4a2..37f6322b1645 100644 --- a/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs +++ b/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs @@ -20,7 +20,7 @@ public static class ShellContextFlyoutFactory { public static IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService(); - public static async Task> GetShellContextmenuAsync(bool showOpenMenu, bool shiftPressed, string workingDirectory, List? selectedItems, CancellationToken cancellationToken) + public static async Task> GetShellContextmenuAsync(bool showOpenMenu, bool shiftPressed, string workingDirectory, List? selectedItems, CancellationToken cancellationToken) { bool IsItemSelected = selectedItems?.Count > 0; @@ -240,7 +240,7 @@ public static async Task LoadShellMenuItemsAsync( var shiftPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down); var shellMenuItems = await ContentPageContextFlyoutFactory.GetItemContextShellCommandsAsync( workingDir: null, - [new ListedItem(null) { ItemPath = path }], + [new StandardStorageItem() { ItemPath = path }], shiftPressed: shiftPressed, showOpenMenu: false, default); diff --git a/src/Files.App/Data/Items/FileTagItem.cs b/src/Files.App/Data/Items/FileTagItem.cs index e7283c69440a..e923f7b28637 100644 --- a/src/Files.App/Data/Items/FileTagItem.cs +++ b/src/Files.App/Data/Items/FileTagItem.cs @@ -9,7 +9,7 @@ namespace Files.App.Data.Items { - public sealed class FileTagItem : ObservableObject, INavigationControlItem + public sealed class FileTagItem : ObservableObject, ISidebarItem { public string Text { get; set; } @@ -27,14 +27,14 @@ public string Path public string ToolTipText { get; private set; } - public SectionType Section { get; set; } + public SidebarSectionKind Section { get; set; } public ContextMenuOptions MenuOptions { get; set; } - public NavigationControlItemType ItemType - => NavigationControlItemType.FileTag; + public SidebarItemKind ItemType + => SidebarItemKind.FileTag; - public int CompareTo(INavigationControlItem other) + public int CompareTo(ISidebarItem other) => Text.CompareTo(other.Text); public TagViewModel FileTag { get; set; } diff --git a/src/Files.App/Data/Items/LocationItem.cs b/src/Files.App/Data/Items/LocationItem.cs index 6994d3f18a36..84ad29f0d9aa 100644 --- a/src/Files.App/Data/Items/LocationItem.cs +++ b/src/Files.App/Data/Items/LocationItem.cs @@ -8,7 +8,7 @@ namespace Files.App.Data.Items { - public class LocationItem : ObservableObject, INavigationControlItem + public class LocationItem : ObservableObject, ISidebarItem { public BitmapImage icon; public BitmapImage Icon @@ -53,13 +53,13 @@ public string Path } } - public NavigationControlItemType ItemType - => NavigationControlItemType.Location; + public SidebarItemKind ItemType + => SidebarItemKind.Location; public bool IsDefaultLocation { get; set; } - public object? Children => Section == SectionType.Home ? null : ChildItems; - public BulkConcurrentObservableCollection? ChildItems { get; set; } + public object? Children => Section == SidebarSectionKind.Home ? null : ChildItems; + public BulkConcurrentObservableCollection? ChildItems { get; set; } public IconSource? IconSource { get => new ImageIconSource() @@ -81,7 +81,7 @@ public bool IsExpanded public bool IsPinned => App.QuickAccessManager.Model.PinnedFolders.Contains(path); - public SectionType Section { get; set; } + public SidebarSectionKind Section { get; set; } public ContextMenuOptions MenuOptions { get; set; } @@ -101,7 +101,7 @@ public FrameworkElement? ItemDecorator { get { - if (Section == SectionType.Pinned) + if (Section == SidebarSectionKind.Pinned) { return new OpacityIcon() { @@ -112,7 +112,7 @@ public FrameworkElement? ItemDecorator } } - public int CompareTo(INavigationControlItem other) + public int CompareTo(ISidebarItem other) => Text.CompareTo(other.Text); public static T Create() where T : LocationItem, new() diff --git a/src/Files.App/Data/Items/DriveItem.cs b/src/Files.App/Data/Items/SidebarDriveItem.cs similarity index 96% rename from src/Files.App/Data/Items/DriveItem.cs rename to src/Files.App/Data/Items/SidebarDriveItem.cs index e7a764335895..c2b98f6c559d 100644 --- a/src/Files.App/Data/Items/DriveItem.cs +++ b/src/Files.App/Data/Items/SidebarDriveItem.cs @@ -11,7 +11,7 @@ namespace Files.App.Data.Items { - public sealed class DriveItem : ObservableObject, INavigationControlItem, ILocatableFolder + public sealed class DriveItem : ObservableObject, ISidebarItem, ILocatableFolder { private BitmapImage icon; public BitmapImage Icon @@ -37,7 +37,7 @@ public string Path public StorageFolder Root { get; set; } - public NavigationControlItemType ItemType { get; set; } = NavigationControlItemType.Drive; + public SidebarItemKind ItemType { get; set; } = SidebarItemKind.Drive; public Visibility ItemVisibility { get; set; } = Visibility.Visible; @@ -138,7 +138,7 @@ public string SpaceText set => SetProperty(ref spaceText, value); } - public SectionType Section { get; set; } + public SidebarSectionKind Section { get; set; } public ContextMenuOptions MenuOptions { get; set; } @@ -299,7 +299,7 @@ public async Task UpdatePropertiesAsync() } } - public int CompareTo(INavigationControlItem other) + public int CompareTo(ISidebarItem other) { var result = Type.CompareTo((other as DriveItem)?.Type ?? Type); return result == 0 ? Text.CompareTo(other.Text) : result; diff --git a/src/Files.App/Data/Items/SidebarLibraryItem.cs b/src/Files.App/Data/Items/SidebarLibraryItem.cs index d5b445bf55c3..6682a8ebd0bf 100644 --- a/src/Files.App/Data/Items/SidebarLibraryItem.cs +++ b/src/Files.App/Data/Items/SidebarLibraryItem.cs @@ -13,7 +13,7 @@ public sealed class LibraryLocationItem : LocationItem public LibraryLocationItem(ShellLibraryItem shellLibrary) { - Section = SectionType.Library; + Section = SidebarSectionKind.Library; MenuOptions = new ContextMenuOptions { IsLocationItem = true, diff --git a/src/Files.App/Data/Items/StandardFtpItem.cs b/src/Files.App/Data/Items/StandardFtpItem.cs new file mode 100644 index 000000000000..91862e30f8f8 --- /dev/null +++ b/src/Files.App/Data/Items/StandardFtpItem.cs @@ -0,0 +1,52 @@ +// Copyright (c) 2024 Files Community +// Licensed under the MIT License. See the LICENSE. + +using FluentFTP; +using System.IO; +using Windows.Storage; + +namespace Files.App.Data.Items +{ + /// + /// Represents standard item resides in FTP storage on Windows to be shown on UI. + /// + public sealed class StandardFtpItem : StandardStorageItem + { + /// + /// Initializes an instance of class. + /// + /// + /// + public StandardFtpItem(FtpListItem item, string folder) : base() + { + var isFile = item.Type == FtpObjectType.File; + ItemDateCreatedReal = item.RawCreated < DateTime.FromFileTimeUtc(0) ? DateTimeOffset.MinValue : item.RawCreated; + ItemDateModifiedReal = item.RawModified < DateTime.FromFileTimeUtc(0) ? DateTimeOffset.MinValue : item.RawModified; + ItemNameRaw = item.Name; + FileExtension = Path.GetExtension(item.Name); + ItemPath = PathNormalization.Combine(folder, item.Name); + PrimaryItemAttribute = isFile ? StorageItemTypes.File : StorageItemTypes.Folder; + ItemPropertiesInitialized = false; + FileSizeBytes = item.Size; + HasChildren = !isFile; + FileImage = null; + FileSize = isFile ? FileSizeBytes.ToSizeString() : null; + Opacity = 1; + IsHiddenItem = false; + + ItemType = isFile + ? Name.Contains('.', StringComparison.Ordinal) + ? FileExtension.Trim('.') + " " + "File".GetLocalizedResource() + : "File".GetLocalizedResource() + : "Folder".GetLocalizedResource(); + } + + [Obsolete("StorageItem is obsolete Storage Layer. Must not use furthermore.")] + public async Task ToStorageItem() => PrimaryItemAttribute switch + { + StorageItemTypes.File => await new FtpStorageFile(ItemPath, ItemNameRaw, ItemDateCreatedReal).ToStorageFileAsync(), + StorageItemTypes.Folder => new FtpStorageFolder(ItemPath, ItemNameRaw, ItemDateCreatedReal), + _ => throw new InvalidDataException(), + }; + } +} diff --git a/src/Files.App/Data/Items/StandardRecycleBinItem.cs b/src/Files.App/Data/Items/StandardRecycleBinItem.cs new file mode 100644 index 000000000000..64a8bd2b69a2 --- /dev/null +++ b/src/Files.App/Data/Items/StandardRecycleBinItem.cs @@ -0,0 +1,55 @@ +// Copyright (c) 2024 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.App.Utils +{ + /// + /// Represents standard item resides in Recycle Bin on Windows to be shown on UI. + /// + public sealed class StandardRecycleBinItem : StandardStorageItem + { + /// + /// Gets or sets originally resided path for this removed item placed in Recycle Bin on Windows. + /// + public string OriginalPath { get; set; } = ""; + + /// + /// Gets humanized string of . + /// + public string DateDeletedHumanized { get; private set; } = ""; + + /// + /// Gets parent path of originally resided path for this removed item placed in Recycle Bin on Windows. + /// + public string OriginalParentFolderPath + => SystemIO.Path.IsPathRooted(OriginalPath) ? SystemIO.Path.GetDirectoryName(OriginalPath) ?? "" : OriginalPath; + + /// + /// Gets parent folder name of originally resided path for this removed item placed in Recycle Bin on Windows. + /// + public string OriginalParentFolderName + => SystemIO.Path.GetFileName(OriginalParentFolderPath); + + private DateTimeOffset _DateDeleted; + /// + /// Gets or sets deleted date. + /// + public DateTimeOffset DateDeleted + { + get => _DateDeleted; + set + { + DateDeletedHumanized = dateTimeFormatter.ToShortLabel(value); + _DateDeleted = value; + } + } + + /// + /// Initializes an instance of class. + /// + /// + public StandardRecycleBinItem(string folderRelativeId) : base() + { + } + } +} diff --git a/src/Files.App/Data/Items/ListedItem.cs b/src/Files.App/Data/Items/StandardStorageItem.cs similarity index 77% rename from src/Files.App/Data/Items/ListedItem.cs rename to src/Files.App/Data/Items/StandardStorageItem.cs index 5486c5f904f6..8183a2022989 100644 --- a/src/Files.App/Data/Items/ListedItem.cs +++ b/src/Files.App/Data/Items/StandardStorageItem.cs @@ -11,22 +11,31 @@ using System.Text; using Windows.Storage; -#pragma warning disable CS0618 // Type or member is obsolete - namespace Files.App.Utils { - public class ListedItem : ObservableObject, IGroupableItem + /// + /// Represents storage item to be displayed on UI with necessary storage properties. + /// + // TODO: Add required keyword + public class StandardStorageItem : ObservableObject, IGroupableItem { - protected static IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService(); + // Dependency injections - protected static IStartMenuService StartMenuService { get; } = Ioc.Default.GetRequiredService(); + protected IFileTagsSettingsService FileTagsSettingsService { get; } = Ioc.Default.GetRequiredService(); + protected IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService(); + protected IDateTimeFormatter DateTimeFormatter { get; } = Ioc.Default.GetRequiredService(); + protected IStartMenuService StartMenuService { get; } = Ioc.Default.GetRequiredService(); - protected static readonly IFileTagsSettingsService fileTagsSettingsService = Ioc.Default.GetRequiredService(); + // Properties - protected static readonly IDateTimeFormatter dateTimeFormatter = Ioc.Default.GetRequiredService(); + /// + /// Gets type of this storage item. + /// + public StorableKind StorableKind { get; } - public bool IsHiddenItem { get; set; } = false; + public bool IsHiddenItem { get; set; } + [Obsolete("Do not use furthermore. Use StorableKind instead.")] public StorageItemTypes PrimaryItemAttribute { get; set; } private volatile int itemPropertiesInitialized = 0; @@ -57,7 +66,7 @@ public string ItemTooltipText public string FolderRelativeId { get; set; } - public bool ContainsFilesOrFolders { get; set; } = true; + public bool HasChildren { get; set; } = true; private bool needsPlaceholderGlyph = true; public bool NeedsPlaceholderGlyph @@ -123,7 +132,7 @@ public string[] FileTags public IList? FileTagsUI { - get => fileTagsSettingsService.GetTagsByIds(FileTags); + get => FileTagsSettingsService.GetTagsByIds(FileTags); } private Uri customIconSource; @@ -292,7 +301,7 @@ public DateTimeOffset ItemDateModifiedReal get => itemDateModifiedReal; set { - ItemDateModified = dateTimeFormatter.ToShortLabel(value); + ItemDateModified = DateTimeFormatter.ToShortLabel(value); itemDateModifiedReal = value; OnPropertyChanged(nameof(ItemDateModified)); } @@ -304,7 +313,7 @@ public DateTimeOffset ItemDateCreatedReal get => itemDateCreatedReal; set { - ItemDateCreated = dateTimeFormatter.ToShortLabel(value); + ItemDateCreated = DateTimeFormatter.ToShortLabel(value); itemDateCreatedReal = value; OnPropertyChanged(nameof(ItemDateCreated)); } @@ -316,7 +325,7 @@ public DateTimeOffset ItemDateAccessedReal get => itemDateAccessedReal; set { - ItemDateAccessed = dateTimeFormatter.ToShortLabel(value); + ItemDateAccessed = DateTimeFormatter.ToShortLabel(value); itemDateAccessedReal = value; OnPropertyChanged(nameof(ItemDateAccessed)); } @@ -364,15 +373,6 @@ public string DimensionsDisplay } } - /// - /// Initializes a new instance of the class. - /// - /// - public ListedItem(string folderRelativeId) => FolderRelativeId = folderRelativeId; - - // Parameterless constructor for JsonConvert - public ListedItem() { } - private ObservableCollection fileDetails; public ObservableCollection FileDetails { @@ -404,11 +404,11 @@ public override string ToString() } public bool IsFolder => PrimaryItemAttribute is StorageItemTypes.Folder; - public bool IsRecycleBinItem => this is RecycleBinItem; + public bool IsRecycleBinItem => this is StandardRecycleBinItem; public bool IsShortcut => this is ShortcutItem; public bool IsLibrary => this is LibraryItem; public bool IsLinkItem => IsShortcut && ((ShortcutItem)this).IsUrl; - public bool IsFtpItem => this is FtpItem; + public bool IsFtpItem => this is StandardFtpItem; public bool IsArchive => this is ZipItem; public bool IsAlternateStream => this is AlternateStreamItem; public bool IsGitItem => this is GitItem; @@ -426,90 +426,36 @@ public BaseStorageFile ItemFile } // This is a hack used because x:Bind casting did not work properly - public RecycleBinItem AsRecycleBinItem => this as RecycleBinItem; + public StandardRecycleBinItem AsRecycleBinItem => this as StandardRecycleBinItem; public GitItem AsGitItem => this as GitItem; public string Key { get; set; } + // Constructor + /// - /// Manually check if a folder path contains child items, - /// updating the ContainsFilesOrFolders property from its default value of true + /// Initializes a new instance of the class. /// - public void UpdateContainsFilesFolders() + public StandardStorageItem() { - ContainsFilesOrFolders = FolderHelpers.CheckForFilesFolders(ItemPath); } - } - public sealed class RecycleBinItem : ListedItem - { - public RecycleBinItem(string folderRelativeId) : base(folderRelativeId) - { - } - - public string ItemDateDeleted { get; private set; } + // Methods - public DateTimeOffset ItemDateDeletedReal + /// + /// Manually check if a folder path contains child items, + /// updating the ContainsFilesOrFolders property from its default value of true + /// + public void UpdateContainsFilesFolders() { - get => itemDateDeletedReal; - set - { - ItemDateDeleted = dateTimeFormatter.ToShortLabel(value); - itemDateDeletedReal = value; - } + HasChildren = FolderHelpers.CheckForFilesFolders(ItemPath); } - - private DateTimeOffset itemDateDeletedReal; - - // For recycle bin elements (path + name) - public string ItemOriginalPath { get; set; } - - // For recycle bin elements (path) - public string ItemOriginalFolder => Path.IsPathRooted(ItemOriginalPath) ? Path.GetDirectoryName(ItemOriginalPath) : ItemOriginalPath; - - public string ItemOriginalFolderName => Path.GetFileName(ItemOriginalFolder); - } - - public sealed class FtpItem : ListedItem - { - public FtpItem(FtpListItem item, string folder) : base(null) - { - var isFile = item.Type == FtpObjectType.File; - ItemDateCreatedReal = item.RawCreated < DateTime.FromFileTimeUtc(0) ? DateTimeOffset.MinValue : item.RawCreated; - ItemDateModifiedReal = item.RawModified < DateTime.FromFileTimeUtc(0) ? DateTimeOffset.MinValue : item.RawModified; - ItemNameRaw = item.Name; - FileExtension = Path.GetExtension(item.Name); - ItemPath = PathNormalization.Combine(folder, item.Name); - PrimaryItemAttribute = isFile ? StorageItemTypes.File : StorageItemTypes.Folder; - ItemPropertiesInitialized = false; - - var itemType = isFile ? "File".GetLocalizedResource() : "Folder".GetLocalizedResource(); - if (isFile && Name.Contains('.', StringComparison.Ordinal)) - { - itemType = FileExtension.Trim('.') + " " + itemType; - } - - ItemType = itemType; - FileSizeBytes = item.Size; - ContainsFilesOrFolders = !isFile; - FileImage = null; - FileSize = isFile ? FileSizeBytes.ToSizeString() : null; - Opacity = 1; - IsHiddenItem = false; - } - - public async Task ToStorageItem() => PrimaryItemAttribute switch - { - StorageItemTypes.File => await new FtpStorageFile(ItemPath, ItemNameRaw, ItemDateCreatedReal).ToStorageFileAsync(), - StorageItemTypes.Folder => new FtpStorageFolder(ItemPath, ItemNameRaw, ItemDateCreatedReal), - _ => throw new InvalidDataException(), - }; } - public sealed class ShortcutItem : ListedItem + public sealed class ShortcutItem : StandardStorageItem { - public ShortcutItem(string folderRelativeId) : base(folderRelativeId) + public ShortcutItem(string folderRelativeId) : base() { } @@ -531,9 +477,9 @@ public override string Name public override bool IsExecutable => FileExtensionHelpers.IsExecutableFile(TargetPath, true); } - public sealed class ZipItem : ListedItem + public sealed class ZipItem : StandardStorageItem { - public ZipItem(string folderRelativeId) : base(folderRelativeId) + public ZipItem(string folderRelativeId) : base() { } @@ -555,9 +501,9 @@ public ZipItem() : base() { } } - public sealed class LibraryItem : ListedItem + public sealed class LibraryItem : StandardStorageItem { - public LibraryItem(LibraryLocationItem library) : base(null) + public LibraryItem(LibraryLocationItem library) : base() { ItemPath = library.Path; ItemNameRaw = library.Text; @@ -582,7 +528,7 @@ public LibraryItem(LibraryLocationItem library) : base(null) public ReadOnlyCollection Folders { get; } } - public sealed class AlternateStreamItem : ListedItem + public sealed class AlternateStreamItem : StandardStorageItem { public string MainStreamPath => ItemPath.Substring(0, ItemPath.LastIndexOf(':')); public string MainStreamName => Path.GetFileName(MainStreamPath); @@ -602,7 +548,7 @@ public override string Name } } - public sealed class GitItem : ListedItem + public sealed class GitItem : StandardStorageItem { private volatile int statusPropertiesInitialized = 0; public bool StatusPropertiesInitialized @@ -639,7 +585,7 @@ public DateTimeOffset? GitLastCommitDate set { SetProperty(ref _GitLastCommitDate, value); - GitLastCommitDateHumanized = value is DateTimeOffset dto ? dateTimeFormatter.ToShortLabel(dto) : ""; + GitLastCommitDateHumanized = value is DateTimeOffset dto ? DateTimeFormatter.ToShortLabel(dto) : ""; } } diff --git a/src/Files.App/Data/Items/WslDistroItem.cs b/src/Files.App/Data/Items/WslDistroItem.cs index 06ce36a1d123..50e0a1880421 100644 --- a/src/Files.App/Data/Items/WslDistroItem.cs +++ b/src/Files.App/Data/Items/WslDistroItem.cs @@ -5,7 +5,7 @@ namespace Files.App.Data.Items { - public sealed class WslDistroItem : ObservableObject, INavigationControlItem + public sealed class WslDistroItem : ObservableObject, ISidebarItem { public string Text { get; set; } @@ -20,8 +20,8 @@ public string Path } } - public NavigationControlItemType ItemType - => NavigationControlItemType.LinuxDistro; + public SidebarItemKind ItemType + => SidebarItemKind.LinuxDistro; private Uri icon; public Uri Icon @@ -34,7 +34,7 @@ public Uri Icon } } - public SectionType Section { get; set; } + public SidebarSectionKind Section { get; set; } public ContextMenuOptions MenuOptions { get; set; } @@ -61,6 +61,6 @@ public IconSource? IconSource }; } - public int CompareTo(INavigationControlItem other) => Text.CompareTo(other.Text); + public int CompareTo(ISidebarItem other) => Text.CompareTo(other.Text); } } diff --git a/src/Files.App/Data/Models/ItemManipulationModel.cs b/src/Files.App/Data/Models/ItemManipulationModel.cs index ca8500a22bba..520b5e807ae5 100644 --- a/src/Files.App/Data/Models/ItemManipulationModel.cs +++ b/src/Files.App/Data/Models/ItemManipulationModel.cs @@ -13,15 +13,15 @@ public sealed class ItemManipulationModel public event EventHandler InvertSelectionInvoked; - public event EventHandler AddSelectedItemInvoked; + public event EventHandler AddSelectedItemInvoked; - public event EventHandler RemoveSelectedItemInvoked; + public event EventHandler RemoveSelectedItemInvoked; public event EventHandler FocusSelectedItemsInvoked; public event EventHandler StartRenameItemInvoked; - public event EventHandler ScrollIntoViewInvoked; + public event EventHandler ScrollIntoViewInvoked; public event EventHandler ScrollToTopInvoked; @@ -53,39 +53,39 @@ public void InvertSelection() InvertSelectionInvoked?.Invoke(this, EventArgs.Empty); } - public void AddSelectedItem(ListedItem item) + public void AddSelectedItem(StandardStorageItem item) { AddSelectedItemInvoked?.Invoke(this, item); } - public void AddSelectedItems(List items) + public void AddSelectedItems(List items) { - foreach (ListedItem item in items) + foreach (StandardStorageItem item in items) { AddSelectedItem(item); } } - public void RemoveSelectedItem(ListedItem item) + public void RemoveSelectedItem(StandardStorageItem item) { RemoveSelectedItemInvoked?.Invoke(this, item); } - public void RemoveSelectedItems(List items) + public void RemoveSelectedItems(List items) { - foreach (ListedItem item in items) + foreach (StandardStorageItem item in items) { RemoveSelectedItem(item); } } - public void SetSelectedItem(ListedItem item) + public void SetSelectedItem(StandardStorageItem item) { ClearSelection(); AddSelectedItem(item); } - public void SetSelectedItems(List items) + public void SetSelectedItems(List items) { ClearSelection(); AddSelectedItems(items); @@ -101,7 +101,7 @@ public void StartRenameItem() StartRenameItemInvoked?.Invoke(this, EventArgs.Empty); } - public void ScrollIntoView(ListedItem item) + public void ScrollIntoView(StandardStorageItem item) { ScrollIntoViewInvoked?.Invoke(this, item); } diff --git a/src/Files.App/Data/Models/ItemViewModel.cs b/src/Files.App/Data/Models/ItemViewModel.cs index 0e063911f128..baaec33c5155 100644 --- a/src/Files.App/Data/Models/ItemViewModel.cs +++ b/src/Files.App/Data/Models/ItemViewModel.cs @@ -44,7 +44,7 @@ public sealed class ItemViewModel : ObservableObject, IDisposable private Task? gitProcessQueueAction; // Files and folders list for manipulating - private ConcurrentCollection filesAndFolders; + private ConcurrentCollection filesAndFolders; private readonly IWindowsJumpListService jumpListService = Ioc.Default.GetRequiredService(); private readonly IDialogService dialogService = Ioc.Default.GetRequiredService(); private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService(); @@ -54,12 +54,12 @@ public sealed class ItemViewModel : ObservableObject, IDisposable private readonly IStorageCacheService fileListCache = Ioc.Default.GetRequiredService(); // Only used for Binding and ApplyFilesAndFoldersChangesAsync, don't manipulate on this! - public BulkConcurrentObservableCollection FilesAndFolders { get; } + public BulkConcurrentObservableCollection FilesAndFolders { get; } private LayoutPreferencesManager folderSettings = null; - private ListedItem? currentFolder; - public ListedItem? CurrentFolder + private StandardStorageItem? currentFolder; + public StandardStorageItem? CurrentFolder { get => currentFolder; private set => SetProperty(ref currentFolder, value); @@ -109,7 +109,7 @@ public GitProperties EnabledGitProperties public event EventHandler GitDirectoryUpdated; - public event EventHandler> OnSelectionRequestedEvent; + public event EventHandler> OnSelectionRequestedEvent; public string WorkingDirectory { get; private set; } @@ -651,7 +651,7 @@ public void CancelExtendedPropertiesLoading() loadPropsCTS = new CancellationTokenSource(); } - public void CancelExtendedPropertiesLoadingForItem(ListedItem item) + public void CancelExtendedPropertiesLoadingForItem(StandardStorageItem item) { itemLoadQueue.TryUpdate(item.ItemPath, true, false); } @@ -744,7 +744,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() => } } - private Task RequestSelectionAsync(List itemsToSelect) + private Task RequestSelectionAsync(List itemsToSelect) { // Don't notify if there weren't listed items if (itemsToSelect is null || itemsToSelect.IsEmpty()) @@ -763,7 +763,7 @@ void OrderEntries() if (filesAndFolders.Count == 0) return; - filesAndFolders = new ConcurrentCollection(SortingHelper.OrderFileList(filesAndFolders.ToList(), folderSettings.DirectorySortOption, folderSettings.DirectorySortDirection, + filesAndFolders = new ConcurrentCollection(SortingHelper.OrderFileList(filesAndFolders.ToList(), folderSettings.DirectorySortOption, folderSettings.DirectorySortDirection, folderSettings.SortDirectoriesAlongsideFiles, folderSettings.SortFilesFirst)); } @@ -922,7 +922,7 @@ private async Task GetShieldIcon() return shieldIcon; } - private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancellationToken) + private async Task LoadThumbnailAsync(StandardStorageItem item, CancellationToken cancellationToken) { var loadNonCachedThumbnail = false; var thumbnailSize = folderSettings.GetRoundedIconSize(); @@ -1033,7 +1033,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(async () => } } - private static void SetFileTag(ListedItem item) + private static void SetFileTag(StandardStorageItem item) { var dbInstance = FileTagsHelper.GetDbInstance(); dbInstance.SetTags(item.ItemPath, item.FileFRN, item.FileTags ?? []); @@ -1041,7 +1041,7 @@ private static void SetFileTag(ListedItem item) // This works for recycle bin as well as GetFileFromPathAsync/GetFolderFromPathAsync work // for file inside the recycle bin (but not on the recycle bin folder itself) - public async Task LoadExtendedItemPropertiesAsync(ListedItem item) + public async Task LoadExtendedItemPropertiesAsync(StandardStorageItem item) { if (item is null) return; @@ -1060,7 +1060,7 @@ public async Task LoadExtendedItemPropertiesAsync(ListedItem item) var wasSyncStatusLoaded = false; var loadGroupHeaderInfo = false; ImageSource? groupImage = null; - GroupedCollection? gp = null; + GroupedCollection? gp = null; try { @@ -1215,7 +1215,7 @@ await SafetyExtensions.IgnoreExceptions(() => } } - private bool CheckElevationRights(ListedItem item) + private bool CheckElevationRights(StandardStorageItem item) { if (item.SyncStatusUI.LoadSyncStatus) return false; @@ -1292,7 +1292,7 @@ await SafetyExtensions.IgnoreExceptions(() => } } - private async Task GetItemTypeGroupIcon(ListedItem item, BaseStorageFile? matchingStorageItem = null) + private async Task GetItemTypeGroupIcon(StandardStorageItem item, BaseStorageFile? matchingStorageItem = null) { ImageSource? groupImage = null; if (item.PrimaryItemAttribute != StorageItemTypes.Folder || item.IsArchive) @@ -1573,7 +1573,7 @@ await DialogDisplayHelper.ShowDialogAsync( if (enumFromStorageFolder) { var basicProps = await rootFolder?.GetBasicPropertiesAsync(); - var currentFolder = library ?? new ListedItem(rootFolder?.FolderRelativeId ?? string.Empty) + var currentFolder = library ?? new StandardStorageItem() { PrimaryItemAttribute = StorageItemTypes.Folder, ItemPropertiesInitialized = true, @@ -1633,7 +1633,7 @@ await DialogDisplayHelper.ShowDialogAsync( var isHidden = (((FileAttributes)findData.dwFileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden); var opacity = isHidden ? Constants.UI.DimItemOpacity : 1d; - var currentFolder = library ?? new ListedItem(null) + var currentFolder = library ?? new StandardStorageItem() { PrimaryItemAttribute = StorageItemTypes.Folder, ItemPropertiesInitialized = true, @@ -1678,7 +1678,7 @@ await DialogDisplayHelper.ShowDialogAsync( { await Task.Run(async () => { - List fileList = await Win32StorageEnumerator.ListEntries(path, hFile, findData, cancellationToken, -1, intermediateAction: async (intermediateList) => + List fileList = await Win32StorageEnumerator.ListEntries(path, hFile, findData, cancellationToken, -1, intermediateAction: async (intermediateList) => { filesAndFolders.AddRange(intermediateList); await OrderFilesAndFoldersAsync(); @@ -1720,7 +1720,7 @@ private async Task EnumFromStorageFolderAsync(string path, BaseStorageFolder? ro await Task.Run(async () => { - List finalList = await UniversalStorageEnumerator.ListEntries( + List finalList = await UniversalStorageEnumerator.ListEntries( rootFolder, currentStorageFolder, cancellationToken, @@ -2099,7 +2099,7 @@ private async Task ProcessOperationQueueAsync(CancellationToken cancellationToke var updateQueue = new Queue(); var anyEdits = false; - ListedItem? lastItemAdded = null; + StandardStorageItem? lastItemAdded = null; var rand = Guid.NewGuid(); // Call when any edits have occurred @@ -2196,7 +2196,7 @@ async Task HandleChangesOccurredAsync() Debug.WriteLine("aProcessQueueAction done: {0}", rand); } - public Task AddFileOrFolderFromShellFile(ShellFileItem item) + public Task AddFileOrFolderFromShellFile(ShellFileItem item) { return item.IsFolder ? @@ -2204,7 +2204,7 @@ public Task AddFileOrFolderFromShellFile(ShellFileItem item) UniversalStorageEnumerator.AddFileAsync(ShellStorageFile.FromShellItem(item), currentStorageFolder, addFilesCTS.Token); } - private async Task AddFileOrFolderAsync(ListedItem? item) + private async Task AddFileOrFolderAsync(StandardStorageItem? item) { if (item is null) return; @@ -2236,7 +2236,7 @@ private async Task AddFileOrFolderAsync(ListedItem? item) enumFolderSemaphore.Release(); } - private async Task AddFileOrFolderAsync(string fileOrFolderPath) + private async Task AddFileOrFolderAsync(string fileOrFolderPath) { FINDEX_INFO_LEVELS findInfoLevel = FINDEX_INFO_LEVELS.FindExInfoBasic; var additionalFlags = FIND_FIRST_EX_CASE_SENSITIVE; @@ -2263,7 +2263,7 @@ private async Task AddFileOrFolderAsync(ListedItem? item) return null; } - ListedItem listedItem; + StandardStorageItem listedItem; // FILE_ATTRIBUTE_DIRECTORY if ((findData.dwFileAttributes & 0x10) > 0) @@ -2276,7 +2276,7 @@ private async Task AddFileOrFolderAsync(ListedItem? item) return listedItem; } - private async Task<(ListedItem Item, CloudDriveSyncStatus? SyncStatus, long? Size, DateTimeOffset Created, DateTimeOffset Modified)?> GetFileOrFolderUpdateInfoAsync(ListedItem item, bool hasSyncStatus) + private async Task<(StandardStorageItem Item, CloudDriveSyncStatus? SyncStatus, long? Size, DateTimeOffset Created, DateTimeOffset Modified)?> GetFileOrFolderUpdateInfoAsync(StandardStorageItem item, bool hasSyncStatus) { IStorageItem? storageItem = null; if (item.PrimaryItemAttribute == StorageItemTypes.File) @@ -2355,7 +2355,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() => } } - public async Task RemoveFileOrFolderAsync(string path) + public async Task RemoveFileOrFolderAsync(string path) { try { @@ -2392,7 +2392,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() => return null; } - public async Task AddSearchResultsToCollectionAsync(ObservableCollection searchItems, string currentSearchPath) + public async Task AddSearchResultsToCollectionAsync(ObservableCollection searchItems, string currentSearchPath) { filesAndFolders.Clear(); filesAndFolders.AddRange(searchItems); @@ -2416,17 +2416,17 @@ public async Task SearchAsync(FolderSearch search) ItemLoadStatusChanged?.Invoke(this, new ItemLoadStatusChangedEventArgs() { Status = ItemLoadStatusChangedEventArgs.ItemLoadStatus.InProgress }); - var results = new List(); + var results = new List(); search.SearchTick += async (s, e) => { - filesAndFolders = new ConcurrentCollection(results); + filesAndFolders = new ConcurrentCollection(results); await OrderFilesAndFoldersAsync(); await ApplyFilesAndFoldersChangesAsync(); }; await search.SearchAsync(results, searchCTS.Token); - filesAndFolders = new ConcurrentCollection(results); + filesAndFolders = new ConcurrentCollection(results); await OrderFilesAndFoldersAsync(); await ApplyFilesAndFoldersChangesAsync(); @@ -2451,8 +2451,8 @@ public void UpdateDateDisplay(bool isFormatChange) await dispatcherQueue.EnqueueOrInvokeAsync(() => item.ItemDateCreatedReal = item.ItemDateCreatedReal); if (isFormatChange || IsDateDiff(item.ItemDateModifiedReal)) await dispatcherQueue.EnqueueOrInvokeAsync(() => item.ItemDateModifiedReal = item.ItemDateModifiedReal); - if (item is RecycleBinItem recycleBinItem && (isFormatChange || IsDateDiff(recycleBinItem.ItemDateDeletedReal))) - await dispatcherQueue.EnqueueOrInvokeAsync(() => recycleBinItem.ItemDateDeletedReal = recycleBinItem.ItemDateDeletedReal); + if (item is Utils.StandardRecycleBinItem recycleBinItem && (isFormatChange || IsDateDiff(recycleBinItem.DateDeleted))) + await dispatcherQueue.EnqueueOrInvokeAsync(() => recycleBinItem.DateDeleted = recycleBinItem.DateDeleted); if (item is GitItem gitItem && gitItem.GitLastCommitDate is DateTimeOffset offset && (isFormatChange || IsDateDiff(offset))) await dispatcherQueue.EnqueueOrInvokeAsync(() => gitItem.GitLastCommitDate = gitItem.GitLastCommitDate); }); diff --git a/src/Files.App/Data/Models/PinnedFoldersManager.cs b/src/Files.App/Data/Models/PinnedFoldersManager.cs index 58208198a78e..b7f54d8fcf00 100644 --- a/src/Files.App/Data/Models/PinnedFoldersManager.cs +++ b/src/Files.App/Data/Models/PinnedFoldersManager.cs @@ -18,10 +18,10 @@ public sealed class PinnedFoldersManager public List PinnedFolders { get; set; } = []; - public readonly List _PinnedFolderItems = []; + public readonly List _PinnedFolderItems = []; [JsonIgnore] - public IReadOnlyList PinnedFolderItems + public IReadOnlyList PinnedFolderItems { get { @@ -56,7 +56,7 @@ public async Task UpdateItemsWithExplorerAsync() /// /// The location item /// Index of the item - public int IndexOfItem(INavigationControlItem locationItem) + public int IndexOfItem(ISidebarItem locationItem) { lock (_PinnedFolderItems) { @@ -83,7 +83,7 @@ public async Task CreateLocationItemFromPathAsync(string path) } locationItem.Path = path; - locationItem.Section = SectionType.Pinned; + locationItem.Section = SidebarSectionKind.Pinned; locationItem.MenuOptions = new ContextMenuOptions { IsLocationItem = true, @@ -147,12 +147,12 @@ private void AddLocationItemToSidebar(LocationItem locationItem) if (_PinnedFolderItems.Any(x => x.Path == locationItem.Path)) return; - var lastItem = _PinnedFolderItems.LastOrDefault(x => x.ItemType is NavigationControlItemType.Location); + var lastItem = _PinnedFolderItems.LastOrDefault(x => x.ItemType is SidebarItemKind.Location); insertIndex = lastItem is not null ? _PinnedFolderItems.IndexOf(lastItem) + 1 : 0; _PinnedFolderItems.Insert(insertIndex, locationItem); } - DataChanged?.Invoke(SectionType.Pinned, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, locationItem, insertIndex)); + DataChanged?.Invoke(SidebarSectionKind.Pinned, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, locationItem, insertIndex)); } /// @@ -179,12 +179,12 @@ public void RemoveStaleSidebarItems() { _PinnedFolderItems.Remove(item); } - DataChanged?.Invoke(SectionType.Pinned, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item)); + DataChanged?.Invoke(SidebarSectionKind.Pinned, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item)); } } // Remove unpinned items from sidebar - DataChanged?.Invoke(SectionType.Pinned, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + DataChanged?.Invoke(SidebarSectionKind.Pinned, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } public async void LoadAsync(object? sender, FileSystemEventArgs e) diff --git a/src/Files.App/Data/Models/SuggestionModel.cs b/src/Files.App/Data/Models/SuggestionModel.cs index cdbb2ad0d1cf..443a2c40e205 100644 --- a/src/Files.App/Data/Models/SuggestionModel.cs +++ b/src/Files.App/Data/Models/SuggestionModel.cs @@ -62,7 +62,7 @@ private void Img_ImageOpened(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) } } - public SuggestionModel(ListedItem item) + public SuggestionModel(StandardStorageItem item) { LoadFileIcon = item.LoadFileIcon; NeedsPlaceholderGlyph = item.NeedsPlaceholderGlyph; diff --git a/src/Files.App/Helpers/Layout/AdaptiveLayoutHelpers.cs b/src/Files.App/Helpers/Layout/AdaptiveLayoutHelpers.cs index 27417b823517..5eefbb138739 100644 --- a/src/Files.App/Helpers/Layout/AdaptiveLayoutHelpers.cs +++ b/src/Files.App/Helpers/Layout/AdaptiveLayoutHelpers.cs @@ -15,7 +15,7 @@ public static class AdaptiveLayoutHelpers private static IFoldersSettingsService FoldersSettingsService { get; } = Ioc.Default.GetRequiredService(); private static ILayoutSettingsService LayoutSettingsService { get; } = Ioc.Default.GetRequiredService(); - public static void ApplyAdaptativeLayout(LayoutPreferencesManager folderSettings, string path, IList filesAndFolders) + public static void ApplyAdaptativeLayout(LayoutPreferencesManager folderSettings, string path, IList filesAndFolders) { if (LayoutSettingsService.SyncFolderPreferencesAcrossDirectories) return; @@ -36,7 +36,7 @@ public static void ApplyAdaptativeLayout(LayoutPreferencesManager folderSettings } } - private static Layouts GetAdaptiveLayout(string path, IList filesAndFolders) + private static Layouts GetAdaptiveLayout(string path, IList filesAndFolders) { var pathLayout = GetPathLayout(path); if (pathLayout is not Layouts.None) @@ -81,7 +81,7 @@ static bool IsFolderType(KeyData data) => "FolderType".Equals(data.KeyName, StringComparison.OrdinalIgnoreCase); } - private static Layouts GetContentLayout(IList filesAndFolders) + private static Layouts GetContentLayout(IList filesAndFolders) { int itemCount = filesAndFolders.Count; if (filesAndFolders.Count is 0) @@ -104,14 +104,14 @@ private static Layouts GetContentLayout(IList filesAndFolders) return Layouts.Detail; return Layouts.Grid; - static bool IsFolder(ListedItem item) + static bool IsFolder(StandardStorageItem item) => item.PrimaryItemAttribute is StorageItemTypes.Folder; - static bool IsImage(ListedItem item) + static bool IsImage(StandardStorageItem item) => !string.IsNullOrEmpty(item.FileExtension) && ImagePreviewViewModel.ContainsExtension(item.FileExtension.ToLowerInvariant()); - static bool IsMedia(ListedItem item) + static bool IsMedia(StandardStorageItem item) => !string.IsNullOrEmpty(item.FileExtension) && (FileExtensionHelpers.IsAudioFile(item.FileExtension) || FileExtensionHelpers.IsVideoFile(item.FileExtension)); diff --git a/src/Files.App/Helpers/Navigation/NavigationHelpers.cs b/src/Files.App/Helpers/Navigation/NavigationHelpers.cs index 84aaa4be5f92..21076cf1de37 100644 --- a/src/Files.App/Helpers/Navigation/NavigationHelpers.cs +++ b/src/Files.App/Helpers/Navigation/NavigationHelpers.cs @@ -260,7 +260,7 @@ public static Task OpenTabInNewWindowAsync(string tabArgs) return Launcher.LaunchUriAsync(folderUri).AsTask(); } - public static void OpenInSecondaryPane(IShellPage associatedInstance, ListedItem listedItem) + public static void OpenInSecondaryPane(IShellPage associatedInstance, StandardStorageItem listedItem) { if (associatedInstance is null || listedItem is null) return; @@ -298,7 +298,7 @@ public static async Task OpenSelectedItemsAsync(IShellPage associatedInstance, b if (opened) return; - foreach (ListedItem item in selectedItems) + foreach (StandardStorageItem item in selectedItems) { var type = item.PrimaryItemAttribute == StorageItemTypes.Folder ? FilesystemItemType.Directory diff --git a/src/Files.App/Helpers/ShareItemHelpers.cs b/src/Files.App/Helpers/ShareItemHelpers.cs index c67e2a8b9ba4..5cad503cb24e 100644 --- a/src/Files.App/Helpers/ShareItemHelpers.cs +++ b/src/Files.App/Helpers/ShareItemHelpers.cs @@ -16,12 +16,12 @@ namespace Files.App.Helpers { public static class ShareItemHelpers { - public static bool IsItemShareable(ListedItem item) + public static bool IsItemShareable(StandardStorageItem item) => !item.IsHiddenItem && (!item.IsShortcut || item.IsLinkItem) && (item.PrimaryItemAttribute != StorageItemTypes.Folder || item.IsArchive); - public static async Task ShareItemsAsync(IEnumerable itemsToShare) + public static async Task ShareItemsAsync(IEnumerable itemsToShare) { if (itemsToShare is null) return; @@ -57,7 +57,7 @@ async void Manager_DataRequested(DataTransferManager sender, DataRequestedEventA List items = []; DataRequest dataRequest = args.Request; - foreach (ListedItem item in itemsToShare) + foreach (StandardStorageItem item in itemsToShare) { if (item is ShortcutItem shItem) { diff --git a/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs b/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs index 0742b61999ae..e45b930f92ff 100644 --- a/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs +++ b/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs @@ -55,7 +55,7 @@ await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachA } // FTP don't support cut, fallback to copy - if (listedItem is not FtpItem) + if (listedItem is not StandardFtpItem) { _ = dispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () => { @@ -63,7 +63,7 @@ await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachA listedItem.Opacity = Constants.UI.DimItemOpacity; }); } - if (listedItem is FtpItem ftpItem) + if (listedItem is StandardFtpItem ftpItem) { if (ftpItem.PrimaryItemAttribute is StorageItemTypes.File or StorageItemTypes.Folder) items.Add(await ftpItem.ToStorageItem()); @@ -160,7 +160,7 @@ await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachA banner.Progress.Report(); } - if (listedItem is FtpItem ftpItem) + if (listedItem is StandardFtpItem ftpItem) { if (ftpItem.PrimaryItemAttribute is StorageItemTypes.File or StorageItemTypes.Folder) items.Add(await ftpItem.ToStorageItem()); @@ -235,7 +235,7 @@ public static async Task PasteItemAsync(string destinationPath, IShellPage assoc } } - public static async Task RenameFileItemAsync(ListedItem item, string newName, IShellPage associatedInstance, bool showExtensionDialog = true) + public static async Task RenameFileItemAsync(StandardStorageItem item, string newName, IShellPage associatedInstance, bool showExtensionDialog = true) { if (item is AlternateStreamItem ads) // For alternate streams Name is not a substring ItemNameRaw { @@ -365,20 +365,20 @@ public static async Task CreateFolderWithSelectionAsync(IShellPage associatedIns /// /// /// - public static void SetHiddenAttributeItem(ListedItem item, bool isHidden, ItemManipulationModel itemManipulationModel) + public static void SetHiddenAttributeItem(StandardStorageItem item, bool isHidden, ItemManipulationModel itemManipulationModel) { item.IsHiddenItem = isHidden; itemManipulationModel.RefreshItemsOpacity(); } - public static async Task CreateShortcutAsync(IShellPage? associatedInstance, IReadOnlyList selectedItems) + public static async Task CreateShortcutAsync(IShellPage? associatedInstance, IReadOnlyList selectedItems) { var currentPath = associatedInstance?.FilesystemViewModel.WorkingDirectory; if (App.LibraryManager.TryGetLibrary(currentPath ?? string.Empty, out var library) && !library.IsEmpty) currentPath = library.DefaultSaveFolder; - foreach (ListedItem selectedItem in selectedItems) + foreach (StandardStorageItem selectedItem in selectedItems) { var fileName = FilesystemHelpers.GetShortcutNamingPreference(selectedItem.Name); var filePath = Path.Combine(currentPath ?? string.Empty, fileName); diff --git a/src/Files.App/Services/Storage/StorageArchiveService.cs b/src/Files.App/Services/Storage/StorageArchiveService.cs index 8b705f05acc3..754478b7d769 100644 --- a/src/Files.App/Services/Storage/StorageArchiveService.cs +++ b/src/Files.App/Services/Storage/StorageArchiveService.cs @@ -16,7 +16,7 @@ public class StorageArchiveService : IStorageArchiveService private IThreadingService ThreadingService { get; } = Ioc.Default.GetRequiredService(); /// - public bool CanCompress(IReadOnlyList items) + public bool CanCompress(IReadOnlyList items) { return CanDecompress(items) is false || @@ -24,7 +24,7 @@ public bool CanCompress(IReadOnlyList items) } /// - public bool CanDecompress(IReadOnlyList items) + public bool CanDecompress(IReadOnlyList items) { return items.Any() && @@ -185,7 +185,7 @@ public async Task DecompressAsync(string archiveFilePath, string destinati } /// - public string GenerateArchiveNameFromItems(IReadOnlyList items) + public string GenerateArchiveNameFromItems(IReadOnlyList items) { if (!items.Any()) return string.Empty; diff --git a/src/Files.App/Services/Storage/StorageNetworkService.cs b/src/Files.App/Services/Storage/StorageNetworkService.cs index e0249c33b7c8..b71c7f99eaee 100644 --- a/src/Files.App/Services/Storage/StorageNetworkService.cs +++ b/src/Files.App/Services/Storage/StorageNetworkService.cs @@ -46,7 +46,7 @@ public NetworkService() Text = "Network".GetLocalizedResource(), Path = Constants.UserEnvironmentPaths.NetworkFolderPath, Type = DriveType.Network, - ItemType = NavigationControlItemType.Drive, + ItemType = SidebarItemKind.Drive, }; networkItem.MenuOptions = new ContextMenuOptions() @@ -73,7 +73,7 @@ public async Task> GetComputersAsync() Path = item.FilePath, DeviceID = item.FilePath, Type = DriveType.Network, - ItemType = NavigationControlItemType.Drive, + ItemType = SidebarItemKind.Drive, }; networkItem.MenuOptions = new ContextMenuOptions() @@ -124,7 +124,7 @@ public async Task> GetShortcutsAsync() Path = item.TargetPath, DeviceID = item.FilePath, Type = DriveType.Network, - ItemType = NavigationControlItemType.Drive, + ItemType = SidebarItemKind.Drive, }; networkItem.MenuOptions = new ContextMenuOptions() diff --git a/src/Files.App/UserControls/Menus/FileTagsContextMenu.cs b/src/Files.App/UserControls/Menus/FileTagsContextMenu.cs index a83161f89724..822c305b0d25 100644 --- a/src/Files.App/UserControls/Menus/FileTagsContextMenu.cs +++ b/src/Files.App/UserControls/Menus/FileTagsContextMenu.cs @@ -14,9 +14,9 @@ public sealed class FileTagsContextMenu : MenuFlyout private IFileTagsSettingsService FileTagsSettingsService { get; } = Ioc.Default.GetService(); - public IEnumerable SelectedItems { get; } + public IEnumerable SelectedItems { get; } - public FileTagsContextMenu(IEnumerable selectedItems) + public FileTagsContextMenu(IEnumerable selectedItems) { SetValue(MenuFlyoutHelper.ItemsSourceProperty, FileTagsSettingsService.FileTagList .Select(tag => new MenuFlyoutFactoryItemViewModel(() => @@ -69,7 +69,7 @@ private void Item_Opening(object? sender, object e) commonFileTags.OfType().ForEach(x => x.IsChecked = true); } - private void RemoveFileTag(IEnumerable selectedListedItems, TagViewModel removed) + private void RemoveFileTag(IEnumerable selectedListedItems, TagViewModel removed) { foreach (var selectedItem in selectedListedItems) { @@ -82,7 +82,7 @@ private void RemoveFileTag(IEnumerable selectedListedItems, TagViewM } } - private void AddFileTag(IEnumerable selectedListedItems, TagViewModel added) + private void AddFileTag(IEnumerable selectedListedItems, TagViewModel added) { foreach (var selectedItem in selectedListedItems) { diff --git a/src/Files.App/Utils/Cloud/CloudDrivesManager.cs b/src/Files.App/Utils/Cloud/CloudDrivesManager.cs index c4eec511b3d9..83a56a65e406 100644 --- a/src/Files.App/Utils/Cloud/CloudDrivesManager.cs +++ b/src/Files.App/Utils/Cloud/CloudDrivesManager.cs @@ -93,7 +93,7 @@ await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(async () } DataChanged?.Invoke( - SectionType.CloudDrives, + SidebarSectionKind.CloudDrives, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, cloudProviderItem) ); } diff --git a/src/Files.App/Utils/FileTags/FileTagsManager.cs b/src/Files.App/Utils/FileTags/FileTagsManager.cs index f3c6cc502818..d09b9187a7c4 100644 --- a/src/Files.App/Utils/FileTags/FileTagsManager.cs +++ b/src/Files.App/Utils/FileTags/FileTagsManager.cs @@ -34,7 +34,7 @@ private async void TagsUpdatedAsync(object? _, EventArgs e) { lock (fileTags) fileTags.Clear(); - DataChanged?.Invoke(SectionType.FileTag, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + DataChanged?.Invoke(SidebarSectionKind.FileTag, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); await UpdateFileTagsAsync(); } @@ -61,7 +61,7 @@ public Task UpdateFileTagsAsync() } fileTags.Add(tagItem); } - DataChanged?.Invoke(SectionType.FileTag, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, tagItem)); + DataChanged?.Invoke(SidebarSectionKind.FileTag, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, tagItem)); } } catch (Exception ex) diff --git a/src/Files.App/Utils/Global/WSLDistroManager.cs b/src/Files.App/Utils/Global/WSLDistroManager.cs index 066478174bfb..3b47e7b4b7c7 100644 --- a/src/Files.App/Utils/Global/WSLDistroManager.cs +++ b/src/Files.App/Utils/Global/WSLDistroManager.cs @@ -49,7 +49,7 @@ public static async Task UpdateDrivesAsync() } distros.Add(distro); } - DataChanged?.Invoke(SectionType.WSL, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, distro)); + DataChanged?.Invoke(SidebarSectionKind.WSL, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, distro)); } } catch (Exception) diff --git a/src/Files.App/Utils/Library/LibraryManager.cs b/src/Files.App/Utils/Library/LibraryManager.cs index 772c6479d1c3..07d2fceb8ac2 100644 --- a/src/Files.App/Utils/Library/LibraryManager.cs +++ b/src/Files.App/Utils/Library/LibraryManager.cs @@ -111,7 +111,7 @@ public async Task UpdateLibrariesAsync() libraries.AddRange(libs); } } - DataChanged?.Invoke(SectionType.Library, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + DataChanged?.Invoke(SidebarSectionKind.Library, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } public bool TryGetLibrary(string path, out LibraryLocationItem library) @@ -159,7 +159,7 @@ public async Task CreateNewLibrary(string name) { libraries.Add(newLib); } - DataChanged?.Invoke(SectionType.Library, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, newLib)); + DataChanged?.Invoke(SidebarSectionKind.Library, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, newLib)); return true; } return false; @@ -244,7 +244,7 @@ public async Task UpdateLibrary(string libraryPath, string { libraries[libraries.IndexOf(libItem)] = newLib; } - DataChanged?.Invoke(SectionType.Library, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, newLib, libItem)); + DataChanged?.Invoke(SidebarSectionKind.Library, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, newLib, libItem)); } return newLib; } @@ -397,7 +397,7 @@ private void OnLibraryChanged(WatcherChangeTypes changeType, string oldPath, str { libraries.Remove(changedLibrary); } - DataChanged?.Invoke(SectionType.Library, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, changedLibrary)); + DataChanged?.Invoke(SidebarSectionKind.Library, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, changedLibrary)); } // library is null in case it was deleted if (library is not null && !Libraries.Any(x => x.Path == library1?.FullPath)) @@ -407,7 +407,7 @@ private void OnLibraryChanged(WatcherChangeTypes changeType, string oldPath, str { libraries.Add(libItem); } - DataChanged?.Invoke(SectionType.Library, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, libItem)); + DataChanged?.Invoke(SidebarSectionKind.Library, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, libItem)); } library?.Dispose(); diff --git a/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs b/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs index 4f6df171c2c6..3ac7c76db6bc 100644 --- a/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs +++ b/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs @@ -156,12 +156,12 @@ public static async Task RestoreItemAsync(IShellPage associatedInstance) var selected = associatedInstance.SlimContentPage.SelectedItems; if (selected == null) return; - var items = selected.ToList().Where(x => x is RecycleBinItem).Select((item) => new + var items = selected.ToList().Where(x => x is StandardRecycleBinItem).Select((item) => new { Source = StorageHelpers.FromPathAndType( item.ItemPath, item.PrimaryItemAttribute == StorageItemTypes.File ? FilesystemItemType.File : FilesystemItemType.Directory), - Dest = ((RecycleBinItem)item).ItemOriginalPath + Dest = ((StandardRecycleBinItem)item).OriginalPath }); await associatedInstance.FilesystemHelpers.RestoreItemsFromTrashAsync(items.Select(x => x.Source), items.Select(x => x.Dest), true); } diff --git a/src/Files.App/Utils/Storage/Collection/GroupingHelper.cs b/src/Files.App/Utils/Storage/Collection/GroupingHelper.cs index 141826b374b3..f8ca2edc521d 100644 --- a/src/Files.App/Utils/Storage/Collection/GroupingHelper.cs +++ b/src/Files.App/Utils/Storage/Collection/GroupingHelper.cs @@ -9,7 +9,7 @@ public static class GroupingHelper { private static readonly IDateTimeFormatter dateTimeFormatter = Ioc.Default.GetService(); - public static Func GetItemGroupKeySelector(GroupOption option, GroupByDateUnit unit) + public static Func GetItemGroupKeySelector(GroupOption option, GroupByDateUnit unit) { return option switch { @@ -20,14 +20,14 @@ public static Func GetItemGroupKeySelector(GroupOption optio GroupOption.FileType => x => x.PrimaryItemAttribute == StorageItemTypes.Folder && !x.IsShortcut ? x.ItemType : x.FileExtension?.ToLowerInvariant() ?? " ", GroupOption.SyncStatus => x => x.SyncStatusString, GroupOption.FileTag => x => x.FileTags?.FirstOrDefault() ?? "Untagged", - GroupOption.OriginalFolder => x => (x as RecycleBinItem)?.ItemOriginalFolder, - GroupOption.DateDeleted => x => dateTimeFormatter.ToTimeSpanLabel((x as RecycleBinItem)?.ItemDateDeletedReal ?? DateTimeOffset.Now, unit).Text, + GroupOption.OriginalFolder => x => (x as StandardRecycleBinItem)?.OriginalParentFolderPath, + GroupOption.DateDeleted => x => dateTimeFormatter.ToTimeSpanLabel((x as StandardRecycleBinItem)?.DateDeleted ?? DateTimeOffset.Now, unit).Text, GroupOption.FolderPath => x => PathNormalization.GetParentDir(x.ItemPath.TrimPath()), _ => null, }; } - public static (Action>, Action>) GetGroupInfoSelector(GroupOption option, GroupByDateUnit unit) + public static (Action>, Action>) GetGroupInfoSelector(GroupOption option, GroupByDateUnit unit) { return option switch { @@ -47,7 +47,7 @@ public static (Action>, Action { - ListedItem first = x.First(); + StandardStorageItem first = x.First(); var model = x.Model; model.Text = first.ItemType; @@ -82,7 +82,7 @@ public static (Action>, Action (x => { - ListedItem first = x.First(); + StandardStorageItem first = x.First(); x.Model.ShowCountTextBelow = true; x.Model.Text = first.SyncStatusString; x.Model.Icon = first?.SyncStatusUI.Glyph; @@ -90,7 +90,7 @@ public static (Action>, Action (x => { - ListedItem first = x.FirstOrDefault(); + StandardStorageItem first = x.FirstOrDefault(); x.Model.ShowCountTextBelow = true; x.Model.Text = first.FileTagsUI?.FirstOrDefault()?.Name ?? "Untagged".GetLocalizedResource(); //x.Model.Icon = first.FileTagsUI?.FirstOrDefault()?.Color; @@ -98,7 +98,7 @@ public static (Action>, Action (x => { - var vals = dateTimeFormatter.ToTimeSpanLabel((x.First() as RecycleBinItem)?.ItemDateDeletedReal ?? DateTimeOffset.Now, unit); + var vals = dateTimeFormatter.ToTimeSpanLabel((x.First() as StandardRecycleBinItem)?.DateDeleted ?? DateTimeOffset.Now, unit); x.Model.Subtext = vals?.Text; x.Model.Icon = vals?.Glyph; x.Model.SortIndexOverride = vals?.Index ?? 0; @@ -106,17 +106,17 @@ public static (Action>, Action (x => { - ListedItem first = x.First(); + StandardStorageItem first = x.First(); var model = x.Model; model.ShowCountTextBelow = true; - model.Text = (first as RecycleBinItem)?.ItemOriginalFolderName; - model.Subtext = (first as RecycleBinItem)?.ItemOriginalFolder; + model.Text = (first as StandardRecycleBinItem)?.OriginalParentFolderName; + model.Subtext = (first as StandardRecycleBinItem)?.OriginalParentFolderPath; }, null), GroupOption.FolderPath => (x => { - ListedItem first = x.First(); + StandardStorageItem first = x.First(); var model = x.Model; model.ShowCountTextBelow = true; var parentPath = PathNormalization.GetParentDir(first.ItemPath.TrimPath()); diff --git a/src/Files.App/Utils/Storage/Collection/SortingHelper.cs b/src/Files.App/Utils/Storage/Collection/SortingHelper.cs index f8af4a99643c..c7f19450e6f7 100644 --- a/src/Files.App/Utils/Storage/Collection/SortingHelper.cs +++ b/src/Files.App/Utils/Storage/Collection/SortingHelper.cs @@ -7,10 +7,10 @@ namespace Files.App.Utils.Storage { public static class SortingHelper { - private static object OrderByNameFunc(ListedItem item) + private static object OrderByNameFunc(StandardStorageItem item) => item.Name; - public static Func? GetSortFunc(SortOption directorySortOption) + public static Func? GetSortFunc(SortOption directorySortOption) { return directorySortOption switch { @@ -22,23 +22,23 @@ private static object OrderByNameFunc(ListedItem item) SortOption.SyncStatus => item => item.SyncStatusString, SortOption.FileTag => item => item.FileTags?.FirstOrDefault(), SortOption.Path => item => item.ItemPath, - SortOption.OriginalFolder => item => (item as RecycleBinItem)?.ItemOriginalFolder, - SortOption.DateDeleted => item => (item as RecycleBinItem)?.ItemDateDeletedReal, + SortOption.OriginalFolder => item => (item as StandardRecycleBinItem)?.OriginalParentFolderPath, + SortOption.DateDeleted => item => (item as StandardRecycleBinItem)?.DateDeleted, _ => null, }; } - public static IEnumerable OrderFileList(IList filesAndFolders, SortOption directorySortOption, SortDirection directorySortDirection, + public static IEnumerable OrderFileList(IList filesAndFolders, SortOption directorySortOption, SortDirection directorySortDirection, bool sortDirectoriesAlongsideFiles, bool sortFilesFirst) { var orderFunc = GetSortFunc(directorySortOption); var naturalStringComparer = NaturalStringComparer.GetForProcessor(); // Function to prioritize folders (if sortFilesFirst is false) or files (if sortFilesFirst is true) - bool PrioritizeFilesOrFolders(ListedItem listedItem) + bool PrioritizeFilesOrFolders(StandardStorageItem listedItem) => (listedItem.PrimaryItemAttribute == StorageItemTypes.File || listedItem.IsShortcut || listedItem.IsArchive) ^ sortFilesFirst; - IOrderedEnumerable ordered; + IOrderedEnumerable ordered; if (directorySortDirection == SortDirection.Ascending) { diff --git a/src/Files.App/Utils/Storage/Enumerators/UniversalStorageEnumerator.cs b/src/Files.App/Utils/Storage/Enumerators/UniversalStorageEnumerator.cs index f4438f851471..1d3dfd3b9e2d 100644 --- a/src/Files.App/Utils/Storage/Enumerators/UniversalStorageEnumerator.cs +++ b/src/Files.App/Utils/Storage/Enumerators/UniversalStorageEnumerator.cs @@ -11,16 +11,16 @@ namespace Files.App.Utils.Storage { public static class UniversalStorageEnumerator { - public static async Task> ListEntries( + public static async Task> ListEntries( BaseStorageFolder rootFolder, StorageFolderWithPath currentStorageFolder, CancellationToken cancellationToken, int countLimit, - Func, Task> intermediateAction, + Func, Task> intermediateAction, Dictionary defaultIconPairs = null) { var sampler = new IntervalSampler(500); - var tempList = new List(); + var tempList = new List(); uint count = 0; var firstRound = true; @@ -166,7 +166,7 @@ ex is FileNotFoundException || return tempList; } - public static async Task AddFolderAsync( + public static async Task AddFolderAsync( BaseStorageFolder folder, StorageFolderWithPath currentStorageFolder, CancellationToken cancellationToken) @@ -198,7 +198,7 @@ public static async Task AddFolderAsync( } else if (folder is BinStorageFolder binFolder) { - return new RecycleBinItem(folder.FolderRelativeId) + return new StandardRecycleBinItem(folder.FolderRelativeId) { PrimaryItemAttribute = StorageItemTypes.Folder, ItemNameRaw = folder.DisplayName, @@ -212,13 +212,13 @@ public static async Task AddFolderAsync( ItemPath = string.IsNullOrEmpty(folder.Path) ? PathNormalization.Combine(currentStorageFolder.Path, folder.Name) : folder.Path, FileSize = basicProperties.Size.ToSizeString(), FileSizeBytes = (long)basicProperties.Size, - ItemDateDeletedReal = binFolder.DateDeleted, - ItemOriginalPath = binFolder.OriginalPath, + DateDeleted = binFolder.DateDeleted, + OriginalPath = binFolder.OriginalPath, }; } else { - return new ListedItem(folder.FolderRelativeId) + return new StandardStorageItem() { PrimaryItemAttribute = StorageItemTypes.Folder, ItemNameRaw = folder.DisplayName, @@ -239,7 +239,7 @@ public static async Task AddFolderAsync( return null; } - public static async Task AddFileAsync( + public static async Task AddFileAsync( BaseStorageFile file, StorageFolderWithPath currentStorageFolder, CancellationToken cancellationToken) @@ -298,7 +298,7 @@ public static async Task AddFileAsync( } else if (file is BinStorageFile binFile) { - return new RecycleBinItem(file.FolderRelativeId) + return new StandardRecycleBinItem(file.FolderRelativeId) { PrimaryItemAttribute = StorageItemTypes.File, FileExtension = itemFileExtension, @@ -313,13 +313,13 @@ public static async Task AddFileAsync( ItemPath = itemPath, FileSize = itemSize, FileSizeBytes = (long)itemSizeBytes, - ItemDateDeletedReal = binFile.DateDeleted, - ItemOriginalPath = binFile.OriginalPath + DateDeleted = binFile.DateDeleted, + OriginalPath = binFile.OriginalPath }; } else { - return new ListedItem(file.FolderRelativeId) + return new StandardStorageItem() { PrimaryItemAttribute = StorageItemTypes.File, FileExtension = itemFileExtension, diff --git a/src/Files.App/Utils/Storage/Enumerators/Win32StorageEnumerator.cs b/src/Files.App/Utils/Storage/Enumerators/Win32StorageEnumerator.cs index 610af9ab439b..835730696973 100644 --- a/src/Files.App/Utils/Storage/Enumerators/Win32StorageEnumerator.cs +++ b/src/Files.App/Utils/Storage/Enumerators/Win32StorageEnumerator.cs @@ -18,17 +18,17 @@ public static class Win32StorageEnumerator private static readonly string folderTypeTextLocalized = "Folder".GetLocalizedResource(); - public static async Task> ListEntries( + public static async Task> ListEntries( string path, IntPtr hFile, Win32PInvoke.WIN32_FIND_DATA findData, CancellationToken cancellationToken, int countLimit, - Func, Task> intermediateAction + Func, Task> intermediateAction ) { var sampler = new IntervalSampler(500); - var tempList = new List(); + var tempList = new List(); var count = 0; IUserSettingsService userSettingsService = Ioc.Default.GetRequiredService(); @@ -105,13 +105,13 @@ Func, Task> intermediateAction return tempList; } - private static IEnumerable EnumAdsForPath(string itemPath, ListedItem main) + private static IEnumerable EnumAdsForPath(string itemPath, StandardStorageItem main) { foreach (var ads in Win32Helper.GetAlternateStreams(itemPath)) yield return GetAlternateStream(ads, main); } - public static ListedItem GetAlternateStream((string Name, long Size) ads, ListedItem main) + public static StandardStorageItem GetAlternateStream((string Name, long Size) ads, StandardStorageItem main) { string itemType = "File".GetLocalizedResource(); string itemFileExtension = null; @@ -143,7 +143,7 @@ public static ListedItem GetAlternateStream((string Name, long Size) ads, Listed }; } - public static async Task GetFolder( + public static async Task GetFolder( Win32PInvoke.WIN32_FIND_DATA findData, string pathRoot, bool isGitRepo, @@ -202,7 +202,7 @@ CancellationToken cancellationToken } else { - return new ListedItem(null) + return new StandardStorageItem() { PrimaryItemAttribute = StorageItemTypes.Folder, ItemNameRaw = itemName, @@ -220,7 +220,7 @@ CancellationToken cancellationToken } } - public static async Task GetFile( + public static async Task GetFile( Win32PInvoke.WIN32_FIND_DATA findData, string pathRoot, bool isGitRepo, @@ -381,7 +381,7 @@ CancellationToken cancellationToken } else { - return new ListedItem(null) + return new StandardStorageItem() { PrimaryItemAttribute = StorageItemTypes.File, FileExtension = itemFileExtension, diff --git a/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs b/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs index c1f541e6f9ac..cddcfa616ea8 100644 --- a/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs +++ b/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs @@ -302,7 +302,7 @@ private static PathBoxItem GetPathItem(string component, string path) var drivesViewModel = Ioc.Default.GetRequiredService(); var drives = drivesViewModel.Drives.Cast(); - var drive = drives.FirstOrDefault(y => y.ItemType is NavigationControlItemType.Drive && y.Path.Contains(component, StringComparison.OrdinalIgnoreCase)); + var drive = drives.FirstOrDefault(y => y.ItemType is SidebarItemKind.Drive && y.Path.Contains(component, StringComparison.OrdinalIgnoreCase)); title = drive is not null ? drive.Text : string.Format("DriveWithLetter".GetLocalizedResource(), component); } else diff --git a/src/Files.App/Utils/Storage/Search/FolderSearch.cs b/src/Files.App/Utils/Storage/Search/FolderSearch.cs index 82087b901a54..cb2702017a4d 100644 --- a/src/Files.App/Utils/Storage/Search/FolderSearch.cs +++ b/src/Files.App/Utils/Storage/Search/FolderSearch.cs @@ -68,7 +68,7 @@ public string AQSQuery } } - public Task SearchAsync(IList results, CancellationToken token) + public Task SearchAsync(IList results, CancellationToken token) { try { @@ -93,7 +93,7 @@ public Task SearchAsync(IList results, CancellationToken token) return Task.CompletedTask; } - private async Task AddItemsForHomeAsync(IList results, CancellationToken token) + private async Task AddItemsForHomeAsync(IList results, CancellationToken token) { if (AQSQuery.StartsWith("tag:", StringComparison.Ordinal)) { @@ -108,9 +108,9 @@ private async Task AddItemsForHomeAsync(IList results, CancellationT } } - public async Task> SearchAsync() + public async Task> SearchAsync() { - ObservableCollection results = []; + ObservableCollection results = []; try { var token = CancellationToken.None; @@ -135,7 +135,7 @@ public async Task> SearchAsync() return results; } - private async Task SearchAsync(BaseStorageFolder folder, IList results, CancellationToken token) + private async Task SearchAsync(BaseStorageFolder folder, IList results, CancellationToken token) { //var sampler = new IntervalSampler(500); uint index = 0; @@ -176,7 +176,7 @@ private async Task SearchAsync(BaseStorageFolder folder, IList resul } } - private async Task AddItemsForLibraryAsync(LibraryLocationItem library, IList results, CancellationToken token) + private async Task AddItemsForLibraryAsync(LibraryLocationItem library, IList results, CancellationToken token) { foreach (var folder in library.Folders) { @@ -184,7 +184,7 @@ private async Task AddItemsForLibraryAsync(LibraryLocationItem library, IList
  • results, CancellationToken token) + private async Task SearchTagsAsync(string folder, IList results, CancellationToken token) { //var sampler = new IntervalSampler(500); var tags = AQSQuery.Substring("tag:".Length)?.Split(',').Where(t => !string.IsNullOrWhiteSpace(t)) @@ -257,7 +257,7 @@ private async Task SearchTagsAsync(string folder, IList results, Can } } - private async Task AddItemsAsync(string folder, IList results, CancellationToken token) + private async Task AddItemsAsync(string folder, IList results, CancellationToken token) { if (AQSQuery.StartsWith("tag:", StringComparison.Ordinal)) { @@ -281,7 +281,7 @@ private async Task AddItemsAsync(string folder, IList results, Cance } } - private async Task SearchWithWin32Async(string folder, bool hiddenOnly, uint maxItemCount, IList results, CancellationToken token) + private async Task SearchWithWin32Async(string folder, bool hiddenOnly, uint maxItemCount, IList results, CancellationToken token) { //var sampler = new IntervalSampler(500); (IntPtr hFile, WIN32_FIND_DATA findData) = await Task.Run(() => @@ -341,9 +341,9 @@ await Task.Run(() => } } - private ListedItem GetListedItemAsync(string itemPath, WIN32_FIND_DATA findData) + private StandardStorageItem GetListedItemAsync(string itemPath, WIN32_FIND_DATA findData) { - ListedItem listedItem = null; + StandardStorageItem listedItem = null; var isHidden = ((FileAttributes)findData.dwFileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden; var isFolder = ((FileAttributes)findData.dwFileAttributes & FileAttributes.Directory) == FileAttributes.Directory; if (!isFolder) @@ -356,7 +356,7 @@ private ListedItem GetListedItemAsync(string itemPath, WIN32_FIND_DATA findData) itemType = itemFileExtension.Trim('.') + " " + itemType; } - listedItem = new ListedItem(null) + listedItem = new StandardStorageItem() { PrimaryItemAttribute = StorageItemTypes.File, ItemNameRaw = findData.cFileName, @@ -372,7 +372,7 @@ private ListedItem GetListedItemAsync(string itemPath, WIN32_FIND_DATA findData) { if (findData.cFileName != "." && findData.cFileName != "..") { - listedItem = new ListedItem(null) + listedItem = new StandardStorageItem() { PrimaryItemAttribute = StorageItemTypes.Folder, ItemNameRaw = findData.cFileName, @@ -400,16 +400,16 @@ private ListedItem GetListedItemAsync(string itemPath, WIN32_FIND_DATA findData) return listedItem; } - private async Task GetListedItemAsync(IStorageItem item) + private async Task GetListedItemAsync(IStorageItem item) { - ListedItem listedItem = null; + StandardStorageItem listedItem = null; if (item.IsOfType(StorageItemTypes.Folder)) { var folder = item.AsBaseStorageFolder(); var props = await folder.GetBasicPropertiesAsync(); if (folder is BinStorageFolder binFolder) { - listedItem = new RecycleBinItem(null) + listedItem = new StandardRecycleBinItem(null) { PrimaryItemAttribute = StorageItemTypes.Folder, ItemNameRaw = folder.DisplayName, @@ -420,13 +420,13 @@ private async Task GetListedItemAsync(IStorageItem item) Opacity = 1, FileSize = props.Size.ToSizeString(), FileSizeBytes = (long)props.Size, - ItemDateDeletedReal = binFolder.DateDeleted, - ItemOriginalPath = binFolder.OriginalPath + DateDeleted = binFolder.DateDeleted, + OriginalPath = binFolder.OriginalPath }; } else { - listedItem = new ListedItem(null) + listedItem = new StandardStorageItem() { PrimaryItemAttribute = StorageItemTypes.Folder, ItemNameRaw = folder.DisplayName, @@ -454,7 +454,7 @@ private async Task GetListedItemAsync(IStorageItem item) if (file is BinStorageFile binFile) { - listedItem = new RecycleBinItem(null) + listedItem = new StandardRecycleBinItem(null) { PrimaryItemAttribute = StorageItemTypes.File, ItemNameRaw = file.Name, @@ -468,13 +468,13 @@ private async Task GetListedItemAsync(IStorageItem item) ItemType = itemType, NeedsPlaceholderGlyph = false, Opacity = 1, - ItemDateDeletedReal = binFile.DateDeleted, - ItemOriginalPath = binFile.OriginalPath + DateDeleted = binFile.DateDeleted, + OriginalPath = binFile.OriginalPath }; } else { - listedItem = new ListedItem(null) + listedItem = new StandardStorageItem() { PrimaryItemAttribute = StorageItemTypes.File, ItemNameRaw = file.Name, diff --git a/src/Files.App/Utils/Storage/StorageItems/FtpStorageFile.cs b/src/Files.App/Utils/Storage/StorageItems/FtpStorageFile.cs index 70216b8cf1e4..db51fcc9b8e4 100644 --- a/src/Files.App/Utils/Storage/StorageItems/FtpStorageFile.cs +++ b/src/Files.App/Utils/Storage/StorageItems/FtpStorageFile.cs @@ -299,7 +299,7 @@ private sealed class FtpFileBasicProperties : BaseBasicProperties public override DateTimeOffset DateCreated { get; } public override DateTimeOffset DateModified { get; } - public FtpFileBasicProperties(FtpItem item) + public FtpFileBasicProperties(StandardFtpItem item) { Size = (ulong)item.FileSizeBytes; DateCreated = item.ItemDateCreatedReal; diff --git a/src/Files.App/Utils/Storage/StorageItems/VirtualStorageItem.cs b/src/Files.App/Utils/Storage/StorageItems/VirtualStorageItem.cs index 62f749188e6b..a084ef55bca0 100644 --- a/src/Files.App/Utils/Storage/StorageItems/VirtualStorageItem.cs +++ b/src/Files.App/Utils/Storage/StorageItems/VirtualStorageItem.cs @@ -29,7 +29,7 @@ public sealed class VirtualStorageItem : IStorageItem private VirtualStorageItem() { } - public static VirtualStorageItem FromListedItem(ListedItem item) + public static VirtualStorageItem FromListedItem(StandardStorageItem item) { return new VirtualStorageItem() { diff --git a/src/Files.App/ViewModels/Dialogs/ReorderSidebarItemsDialogViewModel.cs b/src/Files.App/ViewModels/Dialogs/ReorderSidebarItemsDialogViewModel.cs index d8df0b682af3..2c37d3f9d778 100644 --- a/src/Files.App/ViewModels/Dialogs/ReorderSidebarItemsDialogViewModel.cs +++ b/src/Files.App/ViewModels/Dialogs/ReorderSidebarItemsDialogViewModel.cs @@ -13,7 +13,7 @@ public sealed class ReorderSidebarItemsDialogViewModel : ObservableObject public ICommand PrimaryButtonCommand { get; private set; } public ObservableCollection SidebarPinnedFolderItems = new(App.QuickAccessManager.Model._PinnedFolderItems - .Where(x => x is LocationItem loc && loc.Section is SectionType.Pinned && !loc.IsHeader) + .Where(x => x is LocationItem loc && loc.Section is SidebarSectionKind.Pinned && !loc.IsHeader) .Cast()); public ReorderSidebarItemsDialogViewModel() diff --git a/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs b/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs index 9a6a9995b932..edc913be4891 100644 --- a/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs +++ b/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs @@ -54,7 +54,7 @@ private async Task ItemPointerPressedAsync(PointerRoutedEventArgs e) { // If a folder item was clicked, disable middle mouse click to scroll to cancel the mouse scrolling state and re-enable it if (e.GetCurrentPoint(null).Properties.IsMiddleButtonPressed && - e.OriginalSource is FrameworkElement { DataContext: ListedItem Item } && + e.OriginalSource is FrameworkElement { DataContext: StandardStorageItem Item } && Item.PrimaryItemAttribute == StorageItemTypes.Folder) { _associatedInstance.SlimContentPage.IsMiddleClickToScrollEnabled = false; diff --git a/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs b/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs index 05b144b85d86..3c916accccdc 100644 --- a/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs +++ b/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs @@ -54,7 +54,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) }); } // Storage objects (multi-selected) - else if (np.Parameter is List items) + else if (np.Parameter is List items) { // Selection only contains files if (items.All(item => item.PrimaryItemAttribute == StorageItemTypes.File || item.IsArchive)) @@ -70,7 +70,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) BaseProperties = new CombinedProperties(ViewModel, np.CancellationTokenSource, DispatcherQueue, items, AppInstance); } // A storage object - else if (np.Parameter is ListedItem item) + else if (np.Parameter is StandardStorageItem item) { // File or Archive if (item.PrimaryItemAttribute == StorageItemTypes.File || item.IsArchive) diff --git a/src/Files.App/ViewModels/Properties/CompatibilityViewModel.cs b/src/Files.App/ViewModels/Properties/CompatibilityViewModel.cs index c5ed13885e91..3d18693a6068 100644 --- a/src/Files.App/ViewModels/Properties/CompatibilityViewModel.cs +++ b/src/Files.App/ViewModels/Properties/CompatibilityViewModel.cs @@ -79,7 +79,7 @@ public string SelectedHighDpiOverride // Constructor - public CompatibilityViewModel(ListedItem item) + public CompatibilityViewModel(StandardStorageItem item) { ItemPath = item is ShortcutItem shortcutItem ? shortcutItem.TargetPath : item.ItemPath; diff --git a/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs b/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs index c0b704129c87..e0c7fb1c8e9a 100644 --- a/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs +++ b/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs @@ -49,7 +49,7 @@ public IconFileInfo? SelectedDllIcon public CustomizationViewModel(IShellPage appInstance, BaseProperties baseProperties, AppWindow appWindow) { - ListedItem item; + StandardStorageItem item; if (baseProperties is FileProperties fileProperties) item = fileProperties.Item; diff --git a/src/Files.App/ViewModels/Properties/HashesViewModel.cs b/src/Files.App/ViewModels/Properties/HashesViewModel.cs index 157edfec52b2..bfa0ae8e5920 100644 --- a/src/Files.App/ViewModels/Properties/HashesViewModel.cs +++ b/src/Files.App/ViewModels/Properties/HashesViewModel.cs @@ -24,11 +24,11 @@ public HashInfoItem SelectedItem public ICommand ToggleIsEnabledCommand { get; private set; } - private ListedItem _item; + private StandardStorageItem _item; private CancellationTokenSource _cancellationTokenSource; - public HashesViewModel(ListedItem item) + public HashesViewModel(StandardStorageItem item) { ToggleIsEnabledCommand = new RelayCommand(ToggleIsEnabled); diff --git a/src/Files.App/ViewModels/Properties/Items/CombinedFileProperties.cs b/src/Files.App/ViewModels/Properties/Items/CombinedFileProperties.cs index 836d7ef0038d..b649a6643641 100644 --- a/src/Files.App/ViewModels/Properties/Items/CombinedFileProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/CombinedFileProperties.cs @@ -11,7 +11,7 @@ public CombinedFileProperties( SelectedItemsPropertiesViewModel viewModel, CancellationTokenSource tokenSource, DispatcherQueue coreDispatcher, - List listedItems, + List listedItems, IShellPage instance) : base(viewModel, tokenSource, coreDispatcher, listedItems, instance) { } diff --git a/src/Files.App/ViewModels/Properties/Items/CombinedProperties.cs b/src/Files.App/ViewModels/Properties/Items/CombinedProperties.cs index 7dc2590be7a5..607b150d698d 100644 --- a/src/Files.App/ViewModels/Properties/Items/CombinedProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/CombinedProperties.cs @@ -15,13 +15,13 @@ namespace Files.App.ViewModels.Properties { internal class CombinedProperties : BaseProperties { - public List List { get; } + public List List { get; } public CombinedProperties( SelectedItemsPropertiesViewModel viewModel, CancellationTokenSource tokenSource, DispatcherQueue coreDispatcher, - List listedItems, + List listedItems, IShellPage instance) { ViewModel = viewModel; @@ -48,7 +48,7 @@ public sealed override void GetBaseProperties() ViewModel.ItemType = "PropertiesDriveItemTypeDifferent".GetLocalizedResource(); } - var itemsPath = List.Select(Item => (Item as RecycleBinItem)?.ItemOriginalFolder ?? + var itemsPath = List.Select(Item => (Item as StandardRecycleBinItem)?.OriginalParentFolderPath ?? (Path.IsPathRooted(Item.ItemPath) ? Path.GetDirectoryName(Item.ItemPath) : Item.ItemPath)); if (itemsPath.Distinct().Count() == 1) diff --git a/src/Files.App/ViewModels/Properties/Items/FileProperties.cs b/src/Files.App/ViewModels/Properties/Items/FileProperties.cs index 83d3cdd31800..1f200fadfb1b 100644 --- a/src/Files.App/ViewModels/Properties/Items/FileProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/FileProperties.cs @@ -9,13 +9,13 @@ namespace Files.App.ViewModels.Properties { public sealed class FileProperties : BaseProperties, IFileProperties { - public ListedItem Item { get; } + public StandardStorageItem Item { get; } public FileProperties( SelectedItemsPropertiesViewModel viewModel, CancellationTokenSource tokenSource, DispatcherQueue coreDispatcher, - ListedItem item, + StandardStorageItem item, IShellPage instance) { ViewModel = viewModel; @@ -37,7 +37,7 @@ public override void GetBaseProperties() ViewModel.ItemName = Item.Name; ViewModel.OriginalItemName = Item.Name; ViewModel.ItemType = Item.ItemType; - ViewModel.ItemLocation = (Item as RecycleBinItem)?.ItemOriginalFolder ?? + ViewModel.ItemLocation = (Item as StandardRecycleBinItem)?.OriginalParentFolderPath ?? (Path.IsPathRooted(Item.ItemPath) ? Path.GetDirectoryName(Item.ItemPath) : Item.ItemPath); ViewModel.ItemModifiedTimestampReal = Item.ItemDateModifiedReal; ViewModel.ItemCreatedTimestampReal = Item.ItemDateCreatedReal; diff --git a/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs b/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs index 6de0ad95b165..388410a4d3fd 100644 --- a/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs @@ -10,13 +10,13 @@ namespace Files.App.ViewModels.Properties { internal sealed class FolderProperties : BaseProperties { - public ListedItem Item { get; } + public StandardStorageItem Item { get; } public FolderProperties( SelectedItemsPropertiesViewModel viewModel, CancellationTokenSource tokenSource, DispatcherQueue coreDispatcher, - ListedItem item, + StandardStorageItem item, IShellPage instance) { ViewModel = viewModel; @@ -37,14 +37,14 @@ public override void GetBaseProperties() ViewModel.ItemName = Item.Name; ViewModel.OriginalItemName = Item.Name; ViewModel.ItemType = Item.ItemType; - ViewModel.ItemLocation = (Item as RecycleBinItem)?.ItemOriginalFolder ?? + ViewModel.ItemLocation = (Item as StandardRecycleBinItem)?.OriginalParentFolderPath ?? (Path.IsPathRooted(Item.ItemPath) ? Path.GetDirectoryName(Item.ItemPath) : Item.ItemPath); ViewModel.ItemModifiedTimestampReal = Item.ItemDateModifiedReal; ViewModel.ItemCreatedTimestampReal = Item.ItemDateCreatedReal; ViewModel.LoadCustomIcon = Item.LoadCustomIcon; ViewModel.CustomIconSource = Item.CustomIconSource; ViewModel.LoadFileIcon = Item.LoadFileIcon; - ViewModel.ContainsFilesOrFolders = Item.ContainsFilesOrFolders; + ViewModel.ContainsFilesOrFolders = Item.HasChildren; if (Item.IsShortcut) { diff --git a/src/Files.App/ViewModels/Properties/SecurityAdvancedViewModel.cs b/src/Files.App/ViewModels/Properties/SecurityAdvancedViewModel.cs index 6233b591266d..5ba811400a8c 100644 --- a/src/Files.App/ViewModels/Properties/SecurityAdvancedViewModel.cs +++ b/src/Files.App/ViewModels/Properties/SecurityAdvancedViewModel.cs @@ -128,7 +128,7 @@ public SecurityAdvancedViewModel(PropertiesPageNavigationParameter parameter) switch (parameter.Parameter) { - case ListedItem listedItem: + case StandardStorageItem listedItem: _path = listedItem.ItemPath; _isFolder = listedItem.PrimaryItemAttribute == StorageItemTypes.Folder && !listedItem.IsShortcut; break; @@ -137,7 +137,7 @@ public SecurityAdvancedViewModel(PropertiesPageNavigationParameter parameter) _isFolder = true; break; default: - var defaultlistedItem = (ListedItem)parameter.Parameter; + var defaultlistedItem = (StandardStorageItem)parameter.Parameter; _path = defaultlistedItem.ItemPath; _isFolder = defaultlistedItem.PrimaryItemAttribute == StorageItemTypes.Folder && !defaultlistedItem.IsShortcut; break; diff --git a/src/Files.App/ViewModels/Properties/SecurityViewModel.cs b/src/Files.App/ViewModels/Properties/SecurityViewModel.cs index 4e162e96b6a7..6e88f1298efd 100644 --- a/src/Files.App/ViewModels/Properties/SecurityViewModel.cs +++ b/src/Files.App/ViewModels/Properties/SecurityViewModel.cs @@ -74,7 +74,7 @@ public SecurityViewModel(PropertiesPageNavigationParameter parameter) switch (parameter.Parameter) { - case ListedItem listedItem: + case StandardStorageItem listedItem: _path = listedItem.ItemPath; _isFolder = listedItem.PrimaryItemAttribute == StorageItemTypes.Folder && !listedItem.IsShortcut; break; @@ -83,7 +83,7 @@ public SecurityViewModel(PropertiesPageNavigationParameter parameter) _isFolder = true; break; default: - var defaultlistedItem = (ListedItem)parameter.Parameter; + var defaultlistedItem = (StandardStorageItem)parameter.Parameter; _path = defaultlistedItem.ItemPath; _isFolder = defaultlistedItem.PrimaryItemAttribute == StorageItemTypes.Folder && !defaultlistedItem.IsShortcut; break; diff --git a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs index 6f31808bdf0d..a652d8b893cc 100644 --- a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs @@ -998,9 +998,9 @@ public bool HasItem set => SetProperty(ref hasItem, value); } - private List? selectedItems; + private List? selectedItems; - public List SelectedItems + public List SelectedItems { get => selectedItems; set diff --git a/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs b/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs index b4a5c62c88dd..ffce155d50dc 100644 --- a/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs @@ -36,8 +36,8 @@ public bool IsEnabled /// Current selected item in the file list. /// TODO see about removing this and accessing it from the page context instead /// - private ListedItem? selectedItem; - public ListedItem? SelectedItem + private StandardStorageItem? selectedItem; + public StandardStorageItem? SelectedItem { get => selectedItem; set @@ -124,7 +124,7 @@ private async void ContentPageContext_PropertyChanged(object? sender, PropertyCh case nameof(IContentPageContext.Folder): case nameof(IContentPageContext.SelectedItem): - ListedItem? tempSelectedItem = null; + StandardStorageItem? tempSelectedItem = null; if (contentPageContext.SelectedItems.Count == 1) tempSelectedItem = contentPageContext.SelectedItems.First(); @@ -180,7 +180,7 @@ private async Task LoadPreviewControlAsync(CancellationToken token, bool downloa PreviewPaneState = PreviewPaneStates.PreviewAndDetailsAvailable; } - private async Task GetBuiltInPreviewControlAsync(ListedItem item, bool downloadItem) + private async Task GetBuiltInPreviewControlAsync(StandardStorageItem item, bool downloadItem) { ShowCloudItemButton = false; @@ -449,9 +449,9 @@ private async Task LoadBasicPreviewAsync() private void SelectedItem_PropertyChanged(object? sender, PropertyChangedEventArgs e) { - if (e.PropertyName is nameof(ListedItem.HasTags)) + if (e.PropertyName is nameof(StandardStorageItem.HasTags)) OnPropertyChanged(nameof(LoadTagsList)); - else if (e.PropertyName is nameof(ListedItem.FileTagsUI)) + else if (e.PropertyName is nameof(StandardStorageItem.FileTagsUI)) UpdateTagsItems(); } @@ -461,7 +461,7 @@ private void UpdateTagsItems() SelectedItem?.FileTagsUI?.ForEach(tag => Items.Add(new TagItem(tag))); - Items.Add(new FlyoutItem(new Files.App.UserControls.Menus.FileTagsContextMenu(new List() { SelectedItem }))); + Items.Add(new FlyoutItem(new Files.App.UserControls.Menus.FileTagsContextMenu(new List() { SelectedItem }))); } public void Dispose() diff --git a/src/Files.App/ViewModels/UserControls/Previews/ArchivePreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/ArchivePreviewViewModel.cs index 2855d345b3c3..eb9ae22c24c4 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/ArchivePreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/ArchivePreviewViewModel.cs @@ -9,7 +9,7 @@ namespace Files.App.ViewModels.Previews { public sealed class ArchivePreviewViewModel : BasePreviewModel { - public ArchivePreviewViewModel(ListedItem item) + public ArchivePreviewViewModel(StandardStorageItem item) : base(item) { } diff --git a/src/Files.App/ViewModels/UserControls/Previews/BasePreviewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/BasePreviewModel.cs index fd4f5009d672..23068d31137d 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/BasePreviewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/BasePreviewModel.cs @@ -12,7 +12,7 @@ public abstract class BasePreviewModel : ObservableObject { private readonly IUserSettingsService userSettingsService = Ioc.Default.GetRequiredService(); - public ListedItem Item { get; } + public StandardStorageItem Item { get; } private BitmapImage fileImage; public BitmapImage FileImage @@ -28,12 +28,12 @@ public BitmapImage FileImage /// public CancellationTokenSource LoadCancelledTokenSource { get; } = new CancellationTokenSource(); - public BasePreviewModel(ListedItem item) : base() + public BasePreviewModel(StandardStorageItem item) : base() => Item = item; public delegate void LoadedEventHandler(object sender, EventArgs e); - public static Task LoadDetailsOnlyAsync(ListedItem item, List details = null) + public static Task LoadDetailsOnlyAsync(StandardStorageItem item, List details = null) { var temp = new DetailsOnlyPreviewModel(item) { DetailsFromPreview = details }; return temp.LoadAsync(); @@ -131,7 +131,7 @@ private async Task> GetSystemFilePropertiesAsync() private sealed class DetailsOnlyPreviewModel : BasePreviewModel { - public DetailsOnlyPreviewModel(ListedItem item) : base(item) { } + public DetailsOnlyPreviewModel(StandardStorageItem item) : base(item) { } public override Task> LoadPreviewAndDetailsAsync() => Task.FromResult(DetailsFromPreview); } diff --git a/src/Files.App/ViewModels/UserControls/Previews/BasicPreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/BasicPreviewViewModel.cs index 43586005f1d3..72c8208e070b 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/BasicPreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/BasicPreviewViewModel.cs @@ -5,6 +5,6 @@ namespace Files.App.ViewModels.Previews { public sealed class BasicPreviewViewModel : BasePreviewModel { - public BasicPreviewViewModel(ListedItem item) : base(item) { } + public BasicPreviewViewModel(StandardStorageItem item) : base(item) { } } } diff --git a/src/Files.App/ViewModels/UserControls/Previews/CodePreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/CodePreviewViewModel.cs index f0fe0cde10b6..ed8f4d0abe0a 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/CodePreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/CodePreviewViewModel.cs @@ -25,7 +25,7 @@ public ILanguage CodeLanguage private set => SetProperty(ref codeLanguage, value); } - public CodePreviewViewModel(ListedItem item) + public CodePreviewViewModel(StandardStorageItem item) : base(item) { } diff --git a/src/Files.App/ViewModels/UserControls/Previews/FolderPreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/FolderPreviewViewModel.cs index f826df056e35..bd92bb1c7190 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/FolderPreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/FolderPreviewViewModel.cs @@ -12,13 +12,13 @@ public sealed class FolderPreviewViewModel { private static readonly IDateTimeFormatter dateTimeFormatter = Ioc.Default.GetRequiredService(); - public ListedItem Item { get; } + public StandardStorageItem Item { get; } public BitmapImage Thumbnail { get; set; } = new(); private BaseStorageFolder Folder { get; set; } - public FolderPreviewViewModel(ListedItem item) + public FolderPreviewViewModel(StandardStorageItem item) => Item = item; public Task LoadAsync() diff --git a/src/Files.App/ViewModels/UserControls/Previews/HtmlPreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/HtmlPreviewViewModel.cs index 4edbb7d8343e..2cffe1c440d9 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/HtmlPreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/HtmlPreviewViewModel.cs @@ -7,7 +7,7 @@ namespace Files.App.ViewModels.Previews { public sealed class HtmlPreviewViewModel : BasePreviewModel { - public HtmlPreviewViewModel(ListedItem item) + public HtmlPreviewViewModel(StandardStorageItem item) : base(item) { } diff --git a/src/Files.App/ViewModels/UserControls/Previews/ImagePreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/ImagePreviewViewModel.cs index a7a1bb8f6eae..ba288c5fe712 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/ImagePreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/ImagePreviewViewModel.cs @@ -19,7 +19,7 @@ public ImageSource ImageSource private set => SetProperty(ref imageSource, value); } - public ImagePreviewViewModel(ListedItem item) + public ImagePreviewViewModel(StandardStorageItem item) : base(item) { } diff --git a/src/Files.App/ViewModels/UserControls/Previews/MarkdownPreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/MarkdownPreviewViewModel.cs index 75f70c4a25d4..b41b86f3e9d9 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/MarkdownPreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/MarkdownPreviewViewModel.cs @@ -14,7 +14,7 @@ public string TextValue private set => SetProperty(ref textValue, value); } - public MarkdownPreviewViewModel(ListedItem item) + public MarkdownPreviewViewModel(StandardStorageItem item) : base(item) { } diff --git a/src/Files.App/ViewModels/UserControls/Previews/MediaPreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/MediaPreviewViewModel.cs index 970ce5a1ff69..68bed6a4dc7c 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/MediaPreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/MediaPreviewViewModel.cs @@ -18,7 +18,7 @@ public MediaSource Source private set => SetProperty(ref source, value); } - public MediaPreviewViewModel(ListedItem item) : base(item) { } + public MediaPreviewViewModel(StandardStorageItem item) : base(item) { } public void TogglePlayback() => TogglePlaybackRequested?.Invoke(this, null); diff --git a/src/Files.App/ViewModels/UserControls/Previews/PDFPreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/PDFPreviewViewModel.cs index c2b0f8c86c48..52f11f7f32e6 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/PDFPreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/PDFPreviewViewModel.cs @@ -30,7 +30,7 @@ public int PageCount public ObservableCollection Pages { get; } = []; - public PDFPreviewViewModel(ListedItem item) + public PDFPreviewViewModel(StandardStorageItem item) : base(item) { } diff --git a/src/Files.App/ViewModels/UserControls/Previews/RichTextPreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/RichTextPreviewViewModel.cs index fda43bedea55..b51ade453d7b 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/RichTextPreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/RichTextPreviewViewModel.cs @@ -10,7 +10,7 @@ public sealed class RichTextPreviewViewModel : BasePreviewModel { public IRandomAccessStream Stream { get; set; } - public RichTextPreviewViewModel(ListedItem item) : base(item) { } + public RichTextPreviewViewModel(StandardStorageItem item) : base(item) { } public static bool ContainsExtension(string extension) => extension is ".rtf"; diff --git a/src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs index 4a932c1de4df..965b626a5661 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs @@ -20,7 +20,7 @@ namespace Files.App.ViewModels.Previews { public sealed class ShellPreviewViewModel : BasePreviewModel { - public ShellPreviewViewModel(ListedItem item) + public ShellPreviewViewModel(StandardStorageItem item) : base(item) { } diff --git a/src/Files.App/ViewModels/UserControls/Previews/ShortcutPreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/ShortcutPreviewViewModel.cs index 46f6f964fe9b..1e76fbc8a146 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/ShortcutPreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/ShortcutPreviewViewModel.cs @@ -7,7 +7,7 @@ namespace Files.App.ViewModels.Previews { internal sealed class ShortcutPreviewViewModel : BasePreviewModel { - public ShortcutPreviewViewModel(ListedItem item) : base(item) { } + public ShortcutPreviewViewModel(StandardStorageItem item) : base(item) { } public async override Task> LoadPreviewAndDetailsAsync() { diff --git a/src/Files.App/ViewModels/UserControls/Previews/TextPreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/TextPreviewViewModel.cs index 1081792c7d8f..b89f4109b5d8 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/TextPreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/TextPreviewViewModel.cs @@ -15,7 +15,7 @@ public string TextValue private set => SetProperty(ref textValue, value); } - public TextPreviewViewModel(ListedItem item) + public TextPreviewViewModel(StandardStorageItem item) : base(item) { } @@ -44,7 +44,7 @@ public async override Task> LoadPreviewAndDetailsAsync() return details; } - public static async Task TryLoadAsTextAsync(ListedItem item) + public static async Task TryLoadAsTextAsync(StandardStorageItem item) { string extension = item.FileExtension?.ToLowerInvariant(); if (ExcludedExtensions(extension) || item.FileSizeBytes is 0 or > Constants.PreviewPane.TryLoadAsTextSizeLimit) diff --git a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs index e66ed7e646c5..3ae452ee053c 100644 --- a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs @@ -43,10 +43,10 @@ public IFilesystemHelpers FilesystemHelpers => PaneHolder?.FilesystemHelpers; private Microsoft.UI.Dispatching.DispatcherQueue dispatcherQueue; - private INavigationControlItem rightClickedItem; + private ISidebarItem rightClickedItem; public object SidebarItems => sidebarItems; - public BulkConcurrentObservableCollection sidebarItems { get; init; } + public BulkConcurrentObservableCollection sidebarItems { get; init; } public PinnedFoldersManager SidebarPinnedModel => App.QuickAccessManager.Model; public IQuickAccessService QuickAccessService { get; } = Ioc.Default.GetRequiredService(); @@ -70,18 +70,18 @@ public SidebarDisplayMode SidebarDisplayMode public delegate void SelectedTagChangedEventHandler(object sender, SelectedTagChangedEventArgs e); public static event SelectedTagChangedEventHandler? SelectedTagChanged; - public static event EventHandler? RightClickedItemChanged; + public static event EventHandler? RightClickedItemChanged; - private readonly SectionType[] SectionOrder = + private readonly SidebarSectionKind[] SectionOrder = [ - SectionType.Home, - SectionType.Pinned, - SectionType.Library, - SectionType.Drives, - SectionType.CloudDrives, - SectionType.Network, - SectionType.WSL, - SectionType.FileTag + SidebarSectionKind.Home, + SidebarSectionKind.Pinned, + SidebarSectionKind.Library, + SidebarSectionKind.Drives, + SidebarSectionKind.CloudDrives, + SidebarSectionKind.Network, + SidebarSectionKind.WSL, + SidebarSectionKind.FileTag ]; public bool IsSidebarCompactSize @@ -98,7 +98,7 @@ public void UpdateSidebarSelectedItemFromArgs(string? arg) { var value = arg; - INavigationControlItem? item = null; + ISidebarItem? item = null; var filteredItems = sidebarItems .Where(x => !string.IsNullOrWhiteSpace(x.Path)) .Concat(sidebarItems.Where(x => (x as LocationItem)?.ChildItems is not null).SelectMany(x => ((LocationItem)x).ChildItems).Where(x => !string.IsNullOrWhiteSpace(x.Path))) @@ -220,9 +220,9 @@ public bool ShowFileTagsSection } } - private INavigationControlItem selectedSidebarItem; + private ISidebarItem selectedSidebarItem; - public INavigationControlItem SidebarSelectedItem + public ISidebarItem SidebarSelectedItem { get => selectedSidebarItem; set => SetProperty(ref selectedSidebarItem, value); @@ -237,19 +237,19 @@ public SidebarViewModel() UserSettingsService.OnSettingChangedEvent += UserSettingsService_OnSettingChangedEvent; CreateItemHomeAsync(); - Manager_DataChanged(SectionType.Pinned, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); - Manager_DataChanged(SectionType.Library, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); - Manager_DataChanged(SectionType.Drives, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); - Manager_DataChanged(SectionType.CloudDrives, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); - Manager_DataChanged(SectionType.Network, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); - Manager_DataChanged(SectionType.WSL, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); - Manager_DataChanged(SectionType.FileTag, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + Manager_DataChanged(SidebarSectionKind.Pinned, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + Manager_DataChanged(SidebarSectionKind.Library, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + Manager_DataChanged(SidebarSectionKind.Drives, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + Manager_DataChanged(SidebarSectionKind.CloudDrives, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + Manager_DataChanged(SidebarSectionKind.Network, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + Manager_DataChanged(SidebarSectionKind.WSL, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + Manager_DataChanged(SidebarSectionKind.FileTag, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); App.QuickAccessManager.Model.DataChanged += Manager_DataChanged; App.LibraryManager.DataChanged += Manager_DataChanged; - drivesViewModel.Drives.CollectionChanged += (x, args) => Manager_DataChanged(SectionType.Drives, args); + drivesViewModel.Drives.CollectionChanged += (x, args) => Manager_DataChanged(SidebarSectionKind.Drives, args); CloudDrivesManager.DataChanged += Manager_DataChanged; - NetworkService.Computers.CollectionChanged += (x, args) => Manager_DataChanged(SectionType.Network, args); + NetworkService.Computers.CollectionChanged += (x, args) => Manager_DataChanged(SidebarSectionKind.Network, args); WSLDistroManager.DataChanged += Manager_DataChanged; App.FileTagsManager.DataChanged += Manager_DataChanged; SidebarDisplayMode = UserSettingsService.AppearanceSettingsService.IsSidebarOpen ? SidebarDisplayMode.Expanded : SidebarDisplayMode.Compact; @@ -268,31 +268,31 @@ public SidebarViewModel() private Task CreateItemHomeAsync() { - return CreateSectionAsync(SectionType.Home); + return CreateSectionAsync(SidebarSectionKind.Home); } private async void Manager_DataChanged(object sender, NotifyCollectionChangedEventArgs e) { await dispatcherQueue.EnqueueOrInvokeAsync(async () => { - var sectionType = (SectionType)sender; + var sectionType = (SidebarSectionKind)sender; var section = await GetOrCreateSectionAsync(sectionType); - Func> getElements = () => sectionType switch + Func> getElements = () => sectionType switch { - SectionType.Pinned => App.QuickAccessManager.Model.PinnedFolderItems, - SectionType.CloudDrives => CloudDrivesManager.Drives, - SectionType.Drives => drivesViewModel.Drives.Cast().ToList().AsReadOnly(), - SectionType.Network => NetworkService.Computers.Cast().ToList().AsReadOnly(), - SectionType.WSL => WSLDistroManager.Distros, - SectionType.Library => App.LibraryManager.Libraries, - SectionType.FileTag => App.FileTagsManager.FileTags, + SidebarSectionKind.Pinned => App.QuickAccessManager.Model.PinnedFolderItems, + SidebarSectionKind.CloudDrives => CloudDrivesManager.Drives, + SidebarSectionKind.Drives => drivesViewModel.Drives.Cast().ToList().AsReadOnly(), + SidebarSectionKind.Network => NetworkService.Computers.Cast().ToList().AsReadOnly(), + SidebarSectionKind.WSL => WSLDistroManager.Distros, + SidebarSectionKind.Library => App.LibraryManager.Libraries, + SidebarSectionKind.FileTag => App.FileTagsManager.FileTags, _ => null }; await SyncSidebarItemsAsync(section, getElements, e); }); } - private async Task SyncSidebarItemsAsync(LocationItem section, Func> getElements, NotifyCollectionChangedEventArgs e) + private async Task SyncSidebarItemsAsync(LocationItem section, Func> getElements, NotifyCollectionChangedEventArgs e) { if (section is null) { @@ -306,7 +306,7 @@ private async Task SyncSidebarItemsAsync(LocationItem section, Func x.Path == elem.Path); section.ChildItems.Remove(match); @@ -331,11 +331,11 @@ private async Task SyncSidebarItemsAsync(LocationItem section, Func x.Path == elem.Path)) { @@ -351,7 +351,7 @@ private async Task SyncSidebarItemsAsync(LocationItem section, Func item is not null && !item.IsEmpty && item.IsDefaultLocation; - private async Task AddElementToSectionAsync(INavigationControlItem elem, LocationItem section, int index = -1) + private async Task AddElementToSectionAsync(ISidebarItem elem, LocationItem section, int index = -1) { if (elem is LibraryLocationItem lib) { @@ -365,7 +365,7 @@ await lib.CheckDefaultSaveFolderAccess() && } else if (elem is DriveItem drive) { - if (section.Section is SectionType.Network or SectionType.CloudDrives) + if (section.Section is SidebarSectionKind.Network or SidebarSectionKind.CloudDrives) { // Already sorted if (!section.ChildItems.Any(x => x.Path == drive.Path)) @@ -409,18 +409,18 @@ private void Section_PropertyChanged(object? sender, PropertyChangedEventArgs e) } } - private async Task GetOrCreateSectionAsync(SectionType sectionType) + private async Task GetOrCreateSectionAsync(SidebarSectionKind sectionType) { LocationItem? section = GetSection(sectionType) ?? await CreateSectionAsync(sectionType); return section; } - private LocationItem? GetSection(SectionType sectionType) + private LocationItem? GetSection(SidebarSectionKind sectionType) { return sidebarItems.FirstOrDefault(x => x.Section == sectionType) as LocationItem; } - private async Task CreateSectionAsync(SectionType sectionType) + private async Task CreateSectionAsync(SidebarSectionKind sectionType) { LocationItem section = null; BitmapImage icon = null; @@ -428,7 +428,7 @@ private async Task CreateSectionAsync(SectionType sectionType) switch (sectionType) { - case SectionType.Home: + case SidebarSectionKind.Home: { section = BuildSection("Home".GetLocalizedResource(), sectionType, new ContextMenuOptions { IsLocationItem = true }, true); section.Path = "Home"; @@ -438,7 +438,7 @@ private async Task CreateSectionAsync(SectionType sectionType) break; } - case SectionType.Pinned: + case SidebarSectionKind.Pinned: { if (ShowPinnedFoldersSection == false) { @@ -452,7 +452,7 @@ private async Task CreateSectionAsync(SectionType sectionType) break; } - case SectionType.Library: + case SidebarSectionKind.Library: { if (ShowLibrarySection == false) { @@ -465,7 +465,7 @@ private async Task CreateSectionAsync(SectionType sectionType) break; } - case SectionType.Drives: + case SidebarSectionKind.Drives: { if (ShowDrivesSection == false) { @@ -478,7 +478,7 @@ private async Task CreateSectionAsync(SectionType sectionType) break; } - case SectionType.CloudDrives: + case SidebarSectionKind.CloudDrives: { if (ShowCloudDrivesSection == false || CloudDrivesManager.Drives.Any() == false) { @@ -491,7 +491,7 @@ private async Task CreateSectionAsync(SectionType sectionType) break; } - case SectionType.Network: + case SidebarSectionKind.Network: { if (!ShowNetworkSection) { @@ -504,7 +504,7 @@ private async Task CreateSectionAsync(SectionType sectionType) break; } - case SectionType.WSL: + case SidebarSectionKind.WSL: { if (ShowWslSection == false || WSLDistroManager.Distros.Any() == false) { @@ -517,7 +517,7 @@ private async Task CreateSectionAsync(SectionType sectionType) break; } - case SectionType.FileTag: + case SidebarSectionKind.FileTag: { if (!ShowFileTagsSection) { @@ -549,7 +549,7 @@ private async Task CreateSectionAsync(SectionType sectionType) return section; } - private LocationItem BuildSection(string sectionName, SectionType sectionType, ContextMenuOptions options, bool selectsOnInvoked) + private LocationItem BuildSection(string sectionName, SidebarSectionKind sectionType, ContextMenuOptions options, bool selectsOnInvoked) { return new LocationItem() { @@ -567,7 +567,7 @@ private void AddSectionToSideBar(LocationItem section) sidebarItems.Insert(Math.Min(index, sidebarItems.Count), section); } - public async Task UpdateSectionVisibilityAsync(SectionType sectionType, bool show) + public async Task UpdateSectionVisibilityAsync(SidebarSectionKind sectionType, bool show) { if (show) { @@ -575,13 +575,13 @@ public async Task UpdateSectionVisibilityAsync(SectionType sectionType, bool sho Func action = sectionType switch { - SectionType.CloudDrives when generalSettingsService.ShowCloudDrivesSection => CloudDrivesManager.UpdateDrivesAsync, - SectionType.Drives => drivesViewModel.UpdateDrivesAsync, - SectionType.Network when generalSettingsService.ShowNetworkSection => NetworkService.UpdateComputersAsync, - SectionType.WSL when generalSettingsService.ShowWslSection => WSLDistroManager.UpdateDrivesAsync, - SectionType.FileTag when generalSettingsService.ShowFileTagsSection => App.FileTagsManager.UpdateFileTagsAsync, - SectionType.Library => App.LibraryManager.UpdateLibrariesAsync, - SectionType.Pinned => App.QuickAccessManager.Model.AddAllItemsToSidebarAsync, + SidebarSectionKind.CloudDrives when generalSettingsService.ShowCloudDrivesSection => CloudDrivesManager.UpdateDrivesAsync, + SidebarSectionKind.Drives => drivesViewModel.UpdateDrivesAsync, + SidebarSectionKind.Network when generalSettingsService.ShowNetworkSection => NetworkService.UpdateComputersAsync, + SidebarSectionKind.WSL when generalSettingsService.ShowWslSection => WSLDistroManager.UpdateDrivesAsync, + SidebarSectionKind.FileTag when generalSettingsService.ShowFileTagsSection => App.FileTagsManager.UpdateFileTagsAsync, + SidebarSectionKind.Library => App.LibraryManager.UpdateLibrariesAsync, + SidebarSectionKind.Pinned => App.QuickAccessManager.Model.AddAllItemsToSidebarAsync, _ => () => Task.CompletedTask }; @@ -606,31 +606,31 @@ private async void UserSettingsService_OnSettingChangedEvent(object sender, Sett } break; case nameof(UserSettingsService.GeneralSettingsService.ShowPinnedSection): - await UpdateSectionVisibilityAsync(SectionType.Pinned, ShowPinnedFoldersSection); + await UpdateSectionVisibilityAsync(SidebarSectionKind.Pinned, ShowPinnedFoldersSection); OnPropertyChanged(nameof(ShowPinnedFoldersSection)); break; case nameof(UserSettingsService.GeneralSettingsService.ShowLibrarySection): - await UpdateSectionVisibilityAsync(SectionType.Library, ShowLibrarySection); + await UpdateSectionVisibilityAsync(SidebarSectionKind.Library, ShowLibrarySection); OnPropertyChanged(nameof(ShowLibrarySection)); break; case nameof(UserSettingsService.GeneralSettingsService.ShowCloudDrivesSection): - await UpdateSectionVisibilityAsync(SectionType.CloudDrives, ShowCloudDrivesSection); + await UpdateSectionVisibilityAsync(SidebarSectionKind.CloudDrives, ShowCloudDrivesSection); OnPropertyChanged(nameof(ShowCloudDrivesSection)); break; case nameof(UserSettingsService.GeneralSettingsService.ShowDrivesSection): - await UpdateSectionVisibilityAsync(SectionType.Drives, ShowDrivesSection); + await UpdateSectionVisibilityAsync(SidebarSectionKind.Drives, ShowDrivesSection); OnPropertyChanged(nameof(ShowDrivesSection)); break; case nameof(UserSettingsService.GeneralSettingsService.ShowNetworkSection): - await UpdateSectionVisibilityAsync(SectionType.Network, ShowNetworkSection); + await UpdateSectionVisibilityAsync(SidebarSectionKind.Network, ShowNetworkSection); OnPropertyChanged(nameof(ShowNetworkSection)); break; case nameof(UserSettingsService.GeneralSettingsService.ShowWslSection): - await UpdateSectionVisibilityAsync(SectionType.WSL, ShowWslSection); + await UpdateSectionVisibilityAsync(SidebarSectionKind.WSL, ShowWslSection); OnPropertyChanged(nameof(ShowWslSection)); break; case nameof(UserSettingsService.GeneralSettingsService.ShowFileTagsSection): - await UpdateSectionVisibilityAsync(SectionType.FileTag, ShowFileTagsSection); + await UpdateSectionVisibilityAsync(SidebarSectionKind.FileTag, ShowFileTagsSection); OnPropertyChanged(nameof(ShowFileTagsSection)); break; } @@ -642,9 +642,9 @@ public void Dispose() App.QuickAccessManager.Model.DataChanged -= Manager_DataChanged; App.LibraryManager.DataChanged -= Manager_DataChanged; - drivesViewModel.Drives.CollectionChanged -= (x, args) => Manager_DataChanged(SectionType.Drives, args); + drivesViewModel.Drives.CollectionChanged -= (x, args) => Manager_DataChanged(SidebarSectionKind.Drives, args); CloudDrivesManager.DataChanged -= Manager_DataChanged; - NetworkService.Computers.CollectionChanged -= (x, args) => Manager_DataChanged(SectionType.Network, args); + NetworkService.Computers.CollectionChanged -= (x, args) => Manager_DataChanged(SidebarSectionKind.Network, args); WSLDistroManager.DataChanged -= Manager_DataChanged; App.FileTagsManager.DataChanged -= Manager_DataChanged; } @@ -664,7 +664,7 @@ public async void HandleItemContextInvokedAsync(object sender, ItemContextInvoke if (sender is not FrameworkElement sidebarItem) return; - if (args.Item is not INavigationControlItem item) + if (args.Item is not ISidebarItem item) { // We are in the pane context requested path PaneFlyout.ShowAt(sender as FrameworkElement, args.Position); @@ -723,7 +723,7 @@ private async void ItemContextMenuFlyout_Opened(object? sender, object e) public async void HandleItemInvokedAsync(object item, PointerUpdateKind pointerUpdateKind) { - if (item is not INavigationControlItem navigationControlItem) return; + if (item is not ISidebarItem navigationControlItem) return; var navigationPath = item as string; if (await DriveHelpers.CheckEmptyDrive(navigationPath)) @@ -744,7 +744,7 @@ public async void HandleItemInvokedAsync(object item, PointerUpdateKind pointerU switch (navigationControlItem.ItemType) { - case NavigationControlItemType.Location: + case SidebarItemKind.Location: { // Get the path of the invoked item var ItemPath = navigationControlItem.Path; @@ -765,7 +765,7 @@ public async void HandleItemInvokedAsync(object item, PointerUpdateKind pointerU break; } - case NavigationControlItemType.FileTag: + case SidebarItemKind.FileTag: var tagPath = navigationControlItem.Path; // Get the path of the invoked item if (PaneHolder?.ActivePane is IShellPage shp) { @@ -845,7 +845,7 @@ private void PinItem() } private void UnpinItem() { - if (rightClickedItem.Section == SectionType.Pinned || rightClickedItem is DriveItem) + if (rightClickedItem.Section == SidebarSectionKind.Pinned || rightClickedItem is DriveItem) _ = QuickAccessService.UnpinFromSidebarAsync(rightClickedItem.Path); } @@ -853,25 +853,25 @@ private void HideSection() { switch (rightClickedItem.Section) { - case SectionType.Pinned: + case SidebarSectionKind.Pinned: UserSettingsService.GeneralSettingsService.ShowPinnedSection = false; break; - case SectionType.Library: + case SidebarSectionKind.Library: UserSettingsService.GeneralSettingsService.ShowLibrarySection = false; break; - case SectionType.CloudDrives: + case SidebarSectionKind.CloudDrives: UserSettingsService.GeneralSettingsService.ShowCloudDrivesSection = false; break; - case SectionType.Drives: + case SidebarSectionKind.Drives: UserSettingsService.GeneralSettingsService.ShowDrivesSection = false; break; - case SectionType.Network: + case SidebarSectionKind.Network: UserSettingsService.GeneralSettingsService.ShowNetworkSection = false; break; - case SectionType.WSL: + case SidebarSectionKind.WSL: UserSettingsService.GeneralSettingsService.ShowWslSection = false; break; - case SectionType.FileTag: + case SidebarSectionKind.FileTag: UserSettingsService.GeneralSettingsService.ShowFileTagsSection = false; break; } @@ -896,7 +896,7 @@ private void OpenProperties(CommandBarFlyout menu) FilePropertiesHelpers.OpenPropertiesWindow(new LibraryItem(library), PaneHolder.ActivePane); else if (rightClickedItem is LocationItem locationItem) { - var listedItem = new ListedItem(null!) + var listedItem = new StandardStorageItem() { ItemPath = locationItem.Path, ItemNameRaw = locationItem.Text, @@ -931,7 +931,7 @@ private void FormatDrive() Win32Helper.OpenFormatDriveDialog(rightClickedItem.Path); } - private List GetLocationItemMenuItems(INavigationControlItem item, CommandBarFlyout menu) + private List GetLocationItemMenuItems(ISidebarItem item, CommandBarFlyout menu) { var options = item.MenuOptions; @@ -939,7 +939,7 @@ private List GetLocationItemMenuItems(INavigatio var pinnedFolderIndex = pinnedFolderModel.IndexOfItem(item); var pinnedFolderCount = pinnedFolderModel.PinnedFolders.Count; - var isPinnedItem = item.Section is SectionType.Pinned && pinnedFolderIndex is not -1; + var isPinnedItem = item.Section is SidebarSectionKind.Pinned && pinnedFolderIndex is not -1; var showMoveItemUp = isPinnedItem && pinnedFolderIndex > 0; var showMoveItemDown = isPinnedItem && pinnedFolderIndex < pinnedFolderCount - 1; @@ -998,7 +998,7 @@ private List GetLocationItemMenuItems(INavigatio Text = "ReorderSidebarItemsDialogText".GetLocalizedResource(), Glyph = "\uE8D8", Command = ReorderItemsCommand, - ShowItem = isPinnedItem || item.Section is SectionType.Pinned + ShowItem = isPinnedItem || item.Section is SidebarSectionKind.Pinned }, new ContextMenuFlyoutItemViewModel() { @@ -1072,7 +1072,7 @@ private async Task HandleLocationItemDragOverAsync(LocationItem locationItem, It var storageItems = await Utils.Storage.FilesystemHelpers.GetDraggedStorageItems(args.DroppedItem); var hasStorageItems = storageItems.Any(); - if (isPathNull && hasStorageItems && SectionType.Pinned.Equals(locationItem.Section)) + if (isPathNull && hasStorageItems && SidebarSectionKind.Pinned.Equals(locationItem.Section)) { var haveFoldersToPin = storageItems.Any(item => item.ItemType == FilesystemItemType.Directory && !SidebarPinnedModel.PinnedFolders.Contains(item.Path)); @@ -1234,7 +1234,7 @@ private async Task HandleLocationItemDroppedAsync(LocationItem locationItem, Ite { if (Utils.Storage.FilesystemHelpers.HasDraggedStorageItems(args.DroppedItem)) { - if (string.IsNullOrEmpty(locationItem.Path) && SectionType.Pinned.Equals(locationItem.Section)) // Pin to "Pinned" section + if (string.IsNullOrEmpty(locationItem.Path) && SidebarSectionKind.Pinned.Equals(locationItem.Section)) // Pin to "Pinned" section { var storageItems = await Utils.Storage.FilesystemHelpers.GetDraggedStorageItems(args.DroppedItem); foreach (var item in storageItems) @@ -1260,7 +1260,7 @@ private async Task HandleTagItemDroppedAsync(FileTagItem fileTagItem, ItemDroppe var storageItems = await Utils.Storage.FilesystemHelpers.GetDraggedStorageItems(args.DroppedItem); foreach (var item in storageItems.Where(x => !string.IsNullOrEmpty(x.Path))) { - var listedItem = new ListedItem(null) + var listedItem = new StandardStorageItem() { ItemPath = item.Path, FileFRN = await FileTagsHelper.GetFileFRN(item.Item), diff --git a/src/Files.App/ViewModels/UserControls/Widgets/FileTagsWidgetViewModel.cs b/src/Files.App/ViewModels/UserControls/Widgets/FileTagsWidgetViewModel.cs index 835289ddc3a0..6733fa91975c 100644 --- a/src/Files.App/ViewModels/UserControls/Widgets/FileTagsWidgetViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Widgets/FileTagsWidgetViewModel.cs @@ -152,7 +152,7 @@ private void ExecuteOpenPropertiesCommand(WidgetCardItem? item) { flyout!.Closed -= flyoutClosed; - ListedItem listedItem = new(null!) + StandardStorageItem listedItem = new() { ItemPath = (item.Item as WidgetFileTagCardItem)?.Path ?? string.Empty, ItemNameRaw = (item.Item as WidgetFileTagCardItem)?.Name ?? string.Empty, diff --git a/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs b/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs index e3f4b037887f..ffa459202e75 100644 --- a/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs @@ -272,7 +272,7 @@ private void ExecuteOpenPropertiesCommand(WidgetFolderCardItem? item) { flyout!.Closed -= flyoutClosed; - ListedItem listedItem = new(null!) + StandardStorageItem listedItem = new() { ItemPath = item.Item.Path, ItemNameRaw = item.Item.Text, diff --git a/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs b/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs index 8e93fd76628f..5453ca9ed82e 100644 --- a/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs +++ b/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs @@ -42,10 +42,10 @@ public BaseGroupableLayoutPage() : base() // Abstract methods - protected abstract void ItemManipulationModel_AddSelectedItemInvoked(object? sender, ListedItem e); - protected abstract void ItemManipulationModel_RemoveSelectedItemInvoked(object? sender, ListedItem e); + protected abstract void ItemManipulationModel_AddSelectedItemInvoked(object? sender, StandardStorageItem e); + protected abstract void ItemManipulationModel_RemoveSelectedItemInvoked(object? sender, StandardStorageItem e); protected abstract void ItemManipulationModel_FocusSelectedItemsInvoked(object? sender, EventArgs e); - protected abstract void ItemManipulationModel_ScrollIntoViewInvoked(object? sender, ListedItem e); + protected abstract void ItemManipulationModel_ScrollIntoViewInvoked(object? sender, StandardStorageItem e); protected abstract void ItemManipulationModel_ScrollToTopInvoked(object? sender, EventArgs e); protected abstract void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e); protected abstract void EndRename(TextBox textBox); @@ -196,8 +196,8 @@ protected virtual void ItemManipulationModel_InvertSelectionInvoked(object? send return; } - List newSelectedItems = GetAllItems() - .Cast() + List newSelectedItems = GetAllItems() + .Cast() .Except(SelectedItems) .ToList(); @@ -217,7 +217,7 @@ protected virtual void ZoomIn(object? sender, GroupOption option) protected virtual void FileList_SelectionChanged(object sender, SelectionChangedEventArgs e) { - SelectedItems = ListViewBase.SelectedItems.Cast().Where(x => x is not null).ToList(); + SelectedItems = ListViewBase.SelectedItems.Cast().Where(x => x is not null).ToList(); } protected virtual void SelectionRectangle_SelectionEnded(object? sender, EventArgs e) @@ -349,7 +349,7 @@ protected async void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs e) } } - protected bool TryStartRenameNextItem(ListedItem item) + protected bool TryStartRenameNextItem(StandardStorageItem item) { var nextItemIndex = ListViewBase.Items.IndexOf(item) + NextRenameIndex; NextRenameIndex = 0; diff --git a/src/Files.App/Views/Layouts/BaseLayoutPage.cs b/src/Files.App/Views/Layouts/BaseLayoutPage.cs index 71c993679f35..362a0a946150 100644 --- a/src/Files.App/Views/Layouts/BaseLayoutPage.cs +++ b/src/Files.App/Views/Layouts/BaseLayoutPage.cs @@ -64,9 +64,9 @@ public abstract class BaseLayoutPage : Page, IBaseLayoutPage, INotifyPropertyCha private bool shiftPressed; - private ListedItem? dragOverItem = null; - private ListedItem? hoveredItem = null; - private ListedItem? preRenamingItem = null; + private StandardStorageItem? dragOverItem = null; + private StandardStorageItem? hoveredItem = null; + private StandardStorageItem? preRenamingItem = null; // Properties @@ -108,8 +108,8 @@ public bool AllowItemDrag public bool IsRenamingItem { get; set; } public bool LockPreviewPaneContent { get; set; } - public ListedItem? RenamingItem { get; set; } - public ListedItem? SelectedItem { get; private set; } + public StandardStorageItem? RenamingItem { get; set; } + public StandardStorageItem? SelectedItem { get; private set; } public string? OldItemName { get; set; } @@ -179,14 +179,14 @@ public string JumpString value = jumpString; if (value != string.Empty) { - ListedItem? jumpedToItem = null; - ListedItem? previouslySelectedItem = IsItemSelected ? SelectedItem : null; + StandardStorageItem? jumpedToItem = null; + StandardStorageItem? previouslySelectedItem = IsItemSelected ? SelectedItem : null; // Select first matching item after currently selected item if (previouslySelectedItem is not null) { // Use FilesAndFolders because only displayed entries should be jumped to - IEnumerable candidateItems = ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders.ToList() + IEnumerable candidateItems = ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders.ToList() .SkipWhile(x => x != previouslySelectedItem) .Skip(value.Length == 1 ? 1 : 0) // User is trying to cycle through items starting with the same letter .Where(f => f.Name.Length >= value.Length && string.Equals(f.Name.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase)); @@ -196,7 +196,7 @@ public string JumpString if (jumpedToItem is null) { // Use FilesAndFolders because only displayed entries should be jumped to - IEnumerable candidateItems = ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders.ToList() + IEnumerable candidateItems = ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders.ToList() .Where(f => f.Name.Length >= value.Length && string.Equals(f.Name.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase)); jumpedToItem = candidateItems.FirstOrDefault(); } @@ -216,8 +216,8 @@ public string JumpString } } - private List? selectedItems = []; - public List? SelectedItems + private List? selectedItems = []; + public List? SelectedItems { get => selectedItems; internal set @@ -314,13 +314,13 @@ private void JumpTimer_Tick(object sender, object e) jumpTimer.Stop(); } - protected IEnumerable? GetAllItems() + protected IEnumerable? GetAllItems() { var items = CollectionViewSource.IsSourceGrouped - ? (CollectionViewSource.Source as BulkConcurrentObservableCollection>)?.SelectMany(g => g) // add all items from each group to the new list - : CollectionViewSource.Source as IEnumerable; + ? (CollectionViewSource.Source as BulkConcurrentObservableCollection>)?.SelectMany(g => g) // add all items from each group to the new list + : CollectionViewSource.Source as IEnumerable; - return items ?? new List(); + return items ?? new List(); } public virtual void ResetItemOpacity() @@ -336,12 +336,12 @@ public virtual void ResetItemOpacity() } } - protected ListedItem? GetItemFromElement(object element) + protected StandardStorageItem? GetItemFromElement(object element) { if (element is not ContentControl item || !CanGetItemFromElement(element)) return null; - return (item.DataContext as ListedItem) ?? (item.Content as ListedItem) ?? (ItemsControl.ItemFromContainer(item) as ListedItem); + return (item.DataContext as StandardStorageItem) ?? (item.Content as StandardStorageItem) ?? (ItemsControl.ItemFromContainer(item) as StandardStorageItem); } protected virtual void BaseFolderSettings_LayoutModeChangeRequested(object? sender, LayoutModeEventArgs e) @@ -491,7 +491,7 @@ public void SetSelectedItemsOnNavigation() navigationArguments.SelectItems is not null && navigationArguments.SelectItems.Any()) { - List listedItemsToSelect = + List listedItemsToSelect = [ .. ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders.ToList().Where((li) => navigationArguments.SelectItems.Contains(li.ItemNameRaw)), ]; @@ -570,7 +570,7 @@ private async void ItemContextFlyout_Opening(object? sender, object e) } // Workaround for item sometimes not getting selected - if (!IsItemSelected && (sender as CommandBarFlyout)?.Target is ListViewItem { Content: ListedItem li }) + if (!IsItemSelected && (sender as CommandBarFlyout)?.Target is ListViewItem { Content: StandardStorageItem li }) ItemManipulationModel.SetSelectedItem(li); if (IsItemSelected) @@ -971,7 +971,7 @@ protected virtual void FileList_DragItemsStarting(object sender, DragItemsStarti { try { - var shellItemList = SafetyExtensions.IgnoreExceptions(() => e.Items.OfType().Select(x => new VanaraWindowsShell.ShellItem(x.ItemPath)).ToArray()); + var shellItemList = SafetyExtensions.IgnoreExceptions(() => e.Items.OfType().Select(x => new VanaraWindowsShell.ShellItem(x.ItemPath)).ToArray()); if (shellItemList?[0].FileSystemPath is not null && !InstanceViewModel.IsPageTypeSearchResults) { var iddo = shellItemList[0].Parent.GetChildrenUIObjects(HWND.NULL, shellItemList); @@ -987,7 +987,7 @@ protected virtual void FileList_DragItemsStarting(object sender, DragItemsStarti else { // Only support IStorageItem capable paths - var storageItemList = e.Items.OfType().Where(x => !(x.IsHiddenItem && x.IsLinkItem && x.IsRecycleBinItem && x.IsShortcut)).Select(x => VirtualStorageItem.FromListedItem(x)); + var storageItemList = e.Items.OfType().Where(x => !(x.IsHiddenItem && x.IsLinkItem && x.IsRecycleBinItem && x.IsShortcut)).Select(x => VirtualStorageItem.FromListedItem(x)); e.Data.SetStorageItems(storageItemList, false); } } @@ -1152,7 +1152,7 @@ private void RefreshContainer(SelectorItem container, bool inRecycleQueue) private void RefreshItem(SelectorItem container, object item, bool inRecycleQueue, ContainerContentChangingEventArgs args) { - if (item is not ListedItem listedItem) + if (item is not StandardStorageItem listedItem) return; if (inRecycleQueue) @@ -1228,7 +1228,7 @@ selectedItems is not null && found++; if (found != 0 && !selectedItems.Contains(ItemsControl.Items[i])) - ItemManipulationModel.AddSelectedItem((ListedItem)ItemsControl.Items[i]); + ItemManipulationModel.AddSelectedItem((StandardStorageItem)ItemsControl.Items[i]); } } // Avoid resetting the selection if multiple items are selected @@ -1257,7 +1257,7 @@ protected void FileListItem_RightTapped(object sender, RightTappedRoutedEventArg ItemManipulationModel.SetSelectedItem(rightClickedItem); } - protected void InitializeDrag(UIElement container, ListedItem item) + protected void InitializeDrag(UIElement container, StandardStorageItem item) { if (item is null) return; @@ -1329,7 +1329,7 @@ protected void SemanticZoom_ViewChangeStarted(object sender, SemanticZoomViewCha return; // According to the docs this isn't necessary, but it would crash otherwise - var destination = e.DestinationItem.Item as GroupedCollection; + var destination = e.DestinationItem.Item as GroupedCollection; e.DestinationItem.Item = destination?.FirstOrDefault(); } @@ -1361,7 +1361,7 @@ private void ItemManipulationModel_RefreshItemsOpacityInvoked(object? sender, Ev if (items is null) return; - foreach (ListedItem listedItem in items) + foreach (StandardStorageItem listedItem in items) { if (listedItem.IsHiddenItem) listedItem.Opacity = Constants.UI.DimItemOpacity; @@ -1382,7 +1382,7 @@ virtual public void StartRenameItem() public void CheckRenameDoubleClick(object clickedItem) { - if (clickedItem is ListedItem item) + if (clickedItem is StandardStorageItem item) { if (item == preRenamingItem) { diff --git a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs index 145334ba2356..6020a6785600 100644 --- a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs @@ -96,7 +96,7 @@ internal void ClearOpenedFolderSelectionIndicator() openedFolderPresenter = null; } - protected override void ItemManipulationModel_ScrollIntoViewInvoked(object? sender, ListedItem e) + protected override void ItemManipulationModel_ScrollIntoViewInvoked(object? sender, StandardStorageItem e) { try { @@ -122,7 +122,7 @@ protected override void ItemManipulationModel_FocusSelectedItemsInvoked(object? } } - protected override void ItemManipulationModel_AddSelectedItemInvoked(object? sender, ListedItem e) + protected override void ItemManipulationModel_AddSelectedItemInvoked(object? sender, StandardStorageItem e) { if (NextRenameIndex != 0 && TryStartRenameNextItem(e)) return; @@ -130,7 +130,7 @@ protected override void ItemManipulationModel_AddSelectedItemInvoked(object? sen FileList?.SelectedItems.Add(e); } - protected override void ItemManipulationModel_RemoveSelectedItemInvoked(object? sender, ListedItem e) + protected override void ItemManipulationModel_RemoveSelectedItemInvoked(object? sender, StandardStorageItem e) { FileList?.SelectedItems.Remove(e); } @@ -158,7 +158,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs) private void HighlightPathDirectory(ListViewBase sender, ContainerContentChangingEventArgs args) { - if (args.Item is ListedItem item && columnsOwner?.OwnerPath is string ownerPath + if (args.Item is StandardStorageItem item && columnsOwner?.OwnerPath is string ownerPath && (ownerPath == item.ItemPath || ownerPath.StartsWith(item.ItemPath) && ownerPath[item.ItemPath.Length] is '/' or '\\')) { SetFolderBackground(args.ItemContainer as ListViewItem, this.Resources["ListViewItemBackgroundSelected"] as SolidColorBrush); @@ -415,7 +415,7 @@ private async void FileList_DoubleTapped(object sender, DoubleTappedRoutedEventA var clickedItem = e.OriginalSource as FrameworkElement; - if (clickedItem?.DataContext is ListedItem item) + if (clickedItem?.DataContext is StandardStorageItem item) { switch (item.PrimaryItemAttribute) { @@ -458,7 +458,7 @@ private async void FileList_ItemTapped(object sender, TappedRoutedEventArgs e) { var ctrlPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down); var shiftPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down); - var item = (e.OriginalSource as FrameworkElement)?.DataContext as ListedItem; + var item = (e.OriginalSource as FrameworkElement)?.DataContext as StandardStorageItem; // Allow for Ctrl+Shift selection if (ctrlPressed || shiftPressed) @@ -498,7 +498,7 @@ private async void FileList_ItemTapped(object sender, TappedRoutedEventArgs e) } } - private void CheckDoubleClick(ListedItem item) + private void CheckDoubleClick(StandardStorageItem item) { doubleClickTimer.Debounce(() => { @@ -527,7 +527,7 @@ private void Grid_Loaded(object sender, RoutedEventArgs e) private void Grid_PointerEntered(object sender, PointerRoutedEventArgs e) { - if (sender is FrameworkElement element && element.DataContext is ListedItem item) + if (sender is FrameworkElement element && element.DataContext is StandardStorageItem item) // Reassign values to update date display ToolTipService.SetToolTip(element, item.ItemTooltipText); } diff --git a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs index 625deb606b17..b5a7da48beb1 100644 --- a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs @@ -28,7 +28,7 @@ public sealed partial class DetailsLayoutPage : BaseGroupableLayoutPage // Fields - private ListedItem? _nextItemToSelect; + private StandardStorageItem? _nextItemToSelect; // Properties @@ -91,7 +91,7 @@ public DetailsLayoutPage() : base() // Methods - protected override void ItemManipulationModel_ScrollIntoViewInvoked(object? sender, ListedItem e) + protected override void ItemManipulationModel_ScrollIntoViewInvoked(object? sender, StandardStorageItem e) { FileList.ScrollIntoView(e); ContentScroller?.ChangeView(null, FileList.Items.IndexOf(e) * RowHeight, null, true); // Scroll to index * item height @@ -112,7 +112,7 @@ protected override void ItemManipulationModel_FocusSelectedItemsInvoked(object? } } - protected override void ItemManipulationModel_AddSelectedItemInvoked(object? sender, ListedItem e) + protected override void ItemManipulationModel_AddSelectedItemInvoked(object? sender, StandardStorageItem e) { if (NextRenameIndex != 0) { @@ -123,7 +123,7 @@ protected override void ItemManipulationModel_AddSelectedItemInvoked(object? sen FileList!.SelectedItems.Add(e); } - protected override void ItemManipulationModel_RemoveSelectedItemInvoked(object? sender, ListedItem e) + protected override void ItemManipulationModel_RemoveSelectedItemInvoked(object? sender, StandardStorageItem e) { if (FileList?.Items.Contains(e) ?? false) FileList.SelectedItems.Remove(e); @@ -314,7 +314,7 @@ private void FolderSettings_LayoutModeChangeRequested(object? sender, LayoutMode private void FileList_SelectionChanged(object sender, SelectionChangedEventArgs e) { - SelectedItems = FileList.SelectedItems.Cast().Where(x => x is not null).ToList(); + SelectedItems = FileList.SelectedItems.Cast().Where(x => x is not null).ToList(); if (e != null) { @@ -413,7 +413,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv var folders = ParentShellPageInstance?.SlimContentPage.SelectedItems?.Where(file => file.PrimaryItemAttribute == StorageItemTypes.Folder); if (folders is not null) { - foreach (ListedItem folder in folders) + foreach (StandardStorageItem folder in folders) await NavigationHelpers.OpenPathInNewTab(folder.ItemPath, false); } } @@ -498,7 +498,7 @@ private async void FileList_ItemTapped(object sender, TappedRoutedEventArgs e) var clickedItem = e.OriginalSource as FrameworkElement; var ctrlPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down); var shiftPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down); - var item = clickedItem?.DataContext as ListedItem; + var item = clickedItem?.DataContext as StandardStorageItem; if (item is null) { if (IsRenamingItem && RenamingItem is not null) @@ -554,7 +554,7 @@ clickedItem is Microsoft.UI.Xaml.Shapes.Rectangle private async void FileList_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) { // Skip opening selected items if the double tap doesn't capture an item - if ((e.OriginalSource as FrameworkElement)?.DataContext is ListedItem item + if ((e.OriginalSource as FrameworkElement)?.DataContext is StandardStorageItem item && !UserSettingsService.FoldersSettingsService.OpenItemsWithOneClick) { await Commands.OpenItem.ExecuteAsync(); @@ -675,19 +675,19 @@ private void ResizeColumnToFit(int columnToResize) var maxItemLength = columnToResize switch { 1 => 40, // Check all items columns - 2 => FileList.Items.Cast().Select(x => x.Name?.Length ?? 0).Max(), // file name column - 4 => FileList.Items.Cast().Select(x => (x as GitItem)?.GitLastCommitDateHumanized?.Length ?? 0).Max(), // git - 5 => FileList.Items.Cast().Select(x => (x as GitItem)?.GitLastCommitMessage?.Length ?? 0).Max(), // git - 6 => FileList.Items.Cast().Select(x => (x as GitItem)?.GitLastCommitAuthor?.Length ?? 0).Max(), // git - 7 => FileList.Items.Cast().Select(x => (x as GitItem)?.GitLastCommitSha?.Length ?? 0).Max(), // git - 8 => FileList.Items.Cast().Select(x => x.FileTagsUI?.Sum(x => x?.Name?.Length ?? 0) ?? 0).Max(), // file tag column - 9 => FileList.Items.Cast().Select(x => x.ItemPath?.Length ?? 0).Max(), // path column - 10 => FileList.Items.Cast().Select(x => (x as RecycleBinItem)?.ItemOriginalPath?.Length ?? 0).Max(), // original path column - 11 => FileList.Items.Cast().Select(x => (x as RecycleBinItem)?.ItemDateDeleted?.Length ?? 0).Max(), // date deleted column - 12 => FileList.Items.Cast().Select(x => x.ItemDateModified?.Length ?? 0).Max(), // date modified column - 13 => FileList.Items.Cast().Select(x => x.ItemDateCreated?.Length ?? 0).Max(), // date created column - 14 => FileList.Items.Cast().Select(x => x.ItemType?.Length ?? 0).Max(), // item type column - 15 => FileList.Items.Cast().Select(x => x.FileSize?.Length ?? 0).Max(), // item size column + 2 => FileList.Items.Cast().Select(x => x.Name?.Length ?? 0).Max(), // file name column + 4 => FileList.Items.Cast().Select(x => (x as GitItem)?.GitLastCommitDateHumanized?.Length ?? 0).Max(), // git + 5 => FileList.Items.Cast().Select(x => (x as GitItem)?.GitLastCommitMessage?.Length ?? 0).Max(), // git + 6 => FileList.Items.Cast().Select(x => (x as GitItem)?.GitLastCommitAuthor?.Length ?? 0).Max(), // git + 7 => FileList.Items.Cast().Select(x => (x as GitItem)?.GitLastCommitSha?.Length ?? 0).Max(), // git + 8 => FileList.Items.Cast().Select(x => x.FileTagsUI?.Sum(x => x?.Name?.Length ?? 0) ?? 0).Max(), // file tag column + 9 => FileList.Items.Cast().Select(x => x.ItemPath?.Length ?? 0).Max(), // path column + 10 => FileList.Items.Cast().Select(x => (x as StandardRecycleBinItem)?.OriginalPath?.Length ?? 0).Max(), // original path column + 11 => FileList.Items.Cast().Select(x => (x as StandardRecycleBinItem)?.DateDeletedHumanized?.Length ?? 0).Max(), // date deleted column + 12 => FileList.Items.Cast().Select(x => x.ItemDateModified?.Length ?? 0).Max(), // date modified column + 13 => FileList.Items.Cast().Select(x => x.ItemDateCreated?.Length ?? 0).Max(), // date created column + 14 => FileList.Items.Cast().Select(x => x.ItemType?.Length ?? 0).Max(), // item type column + 15 => FileList.Items.Cast().Select(x => x.FileSize?.Length ?? 0).Max(), // item size column _ => 20 // cloud status column }; @@ -833,13 +833,13 @@ private void SetDetailsColumnsAsDefault_Click(object sender, RoutedEventArgs e) private void ItemSelected_Checked(object sender, RoutedEventArgs e) { - if (sender is CheckBox checkBox && checkBox.DataContext is ListedItem item && !FileList.SelectedItems.Contains(item)) + if (sender is CheckBox checkBox && checkBox.DataContext is StandardStorageItem item && !FileList.SelectedItems.Contains(item)) FileList.SelectedItems.Add(item); } private void ItemSelected_Unchecked(object sender, RoutedEventArgs e) { - if (sender is CheckBox checkBox && checkBox.DataContext is ListedItem item && FileList.SelectedItems.Contains(item)) + if (sender is CheckBox checkBox && checkBox.DataContext is StandardStorageItem item && FileList.SelectedItems.Contains(item)) FileList.SelectedItems.Remove(item); } @@ -904,7 +904,7 @@ private void RemoveTagIcon_Tapped(object sender, TappedRoutedEventArgs e) var parent = (sender as FontIcon)?.Parent as StackPanel; var tagName = (parent?.Children[TAG_TEXT_BLOCK] as TextBlock)?.Text; - if (tagName is null || parent?.DataContext is not ListedItem item) + if (tagName is null || parent?.DataContext is not StandardStorageItem item) return; var tagId = FileTagsSettingsService.GetTagsByName(tagName).FirstOrDefault()?.Uid; diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs index 6455b3bfb919..e2a704a81535 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs @@ -84,7 +84,7 @@ public GridLayoutPage() : base() // Methods - protected override void ItemManipulationModel_ScrollIntoViewInvoked(object? sender, ListedItem e) + protected override void ItemManipulationModel_ScrollIntoViewInvoked(object? sender, StandardStorageItem e) { FileList.ScrollIntoView(e); } @@ -106,7 +106,7 @@ protected override void ItemManipulationModel_FocusSelectedItemsInvoked(object? } } - protected override void ItemManipulationModel_AddSelectedItemInvoked(object? sender, ListedItem e) + protected override void ItemManipulationModel_AddSelectedItemInvoked(object? sender, StandardStorageItem e) { if ((NextRenameIndex != 0 && TryStartRenameNextItem(e)) || (!FileList?.Items.Contains(e) ?? true)) return; @@ -114,7 +114,7 @@ protected override void ItemManipulationModel_AddSelectedItemInvoked(object? sen FileList!.SelectedItems.Add(e); } - protected override void ItemManipulationModel_RemoveSelectedItemInvoked(object? sender, ListedItem e) + protected override void ItemManipulationModel_RemoveSelectedItemInvoked(object? sender, StandardStorageItem e) { if (FileList?.Items.Contains(e) ?? false) FileList.SelectedItems.Remove(e); @@ -392,7 +392,7 @@ protected override void EndRename(TextBox textBox) popup.IsOpen = false; if (textBlock is not null) - textBlock.Opacity = (textBlock.DataContext as ListedItem)!.Opacity; + textBlock.Opacity = (textBlock.DataContext as StandardStorageItem)!.Opacity; } else if (FolderSettings.LayoutMode == FolderLayoutModes.TilesView || FolderSettings.LayoutMode == FolderLayoutModes.ListView) { @@ -444,7 +444,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv if (ctrlPressed && !shiftPressed) { var folders = ParentShellPageInstance?.SlimContentPage.SelectedItems?.Where(file => file.PrimaryItemAttribute == StorageItemTypes.Folder); - foreach (ListedItem? folder in folders) + foreach (StandardStorageItem? folder in folders) { if (folder is not null) await NavigationHelpers.OpenPathInNewTab(folder.ItemPath, false); @@ -510,7 +510,7 @@ private async Task ReloadItemIconsAsync() ParentShellPageInstance.FilesystemViewModel.CancelExtendedPropertiesLoading(); var filesAndFolders = ParentShellPageInstance.FilesystemViewModel.FilesAndFolders.ToList(); - foreach (ListedItem listedItem in filesAndFolders) + foreach (StandardStorageItem listedItem in filesAndFolders) { listedItem.ItemPropertiesInitialized = false; if (FileList.ContainerFromItem(listedItem) is not null) @@ -535,7 +535,7 @@ private async void FileList_ItemTapped(object sender, TappedRoutedEventArgs e) var ctrlPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down); var shiftPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down); - var item = (e.OriginalSource as FrameworkElement)?.DataContext as ListedItem; + var item = (e.OriginalSource as FrameworkElement)?.DataContext as StandardStorageItem; if (item is null) return; @@ -587,7 +587,7 @@ private async void FileList_ItemTapped(object sender, TappedRoutedEventArgs e) private async void FileList_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) { // Skip opening selected items if the double tap doesn't capture an item - if ((e.OriginalSource as FrameworkElement)?.DataContext is ListedItem item && + if ((e.OriginalSource as FrameworkElement)?.DataContext is StandardStorageItem item && !UserSettingsService.FoldersSettingsService.OpenItemsWithOneClick) await Commands.OpenItem.ExecuteAsync(); else if (UserSettingsService.FoldersSettingsService.DoubleClickToGoUp) @@ -599,7 +599,7 @@ private async void FileList_DoubleTapped(object sender, DoubleTappedRoutedEventA private void ItemSelected_Checked(object sender, RoutedEventArgs e) { if (sender is CheckBox checkBox && - checkBox.DataContext is ListedItem item && + checkBox.DataContext is StandardStorageItem item && !FileList.SelectedItems.Contains(item)) FileList.SelectedItems.Add(item); } @@ -607,7 +607,7 @@ checkBox.DataContext is ListedItem item && private void ItemSelected_Unchecked(object sender, RoutedEventArgs e) { if (sender is CheckBox checkBox && - checkBox.DataContext is ListedItem item && + checkBox.DataContext is StandardStorageItem item && FileList.SelectedItems.Contains(item)) FileList.SelectedItems.Remove(item); } @@ -676,7 +676,7 @@ private void Grid_Loaded(object sender, RoutedEventArgs e) private void Grid_PointerEntered(object sender, PointerRoutedEventArgs e) { - if (sender is FrameworkElement element && element.DataContext is ListedItem item) + if (sender is FrameworkElement element && element.DataContext is StandardStorageItem item) // Reassign values to update date display ToolTipService.SetToolTip(element, item.ItemTooltipText); } diff --git a/src/Files.App/Views/Layouts/IBaseLayoutPage.cs b/src/Files.App/Views/Layouts/IBaseLayoutPage.cs index 2e2a8bea9875..77555c0154bc 100644 --- a/src/Files.App/Views/Layouts/IBaseLayoutPage.cs +++ b/src/Files.App/Views/Layouts/IBaseLayoutPage.cs @@ -19,9 +19,9 @@ public interface IBaseLayoutPage : IDisposable /// bool LockPreviewPaneContent { get; set; } - List? SelectedItems { get; } + List? SelectedItems { get; } - ListedItem? SelectedItem { get; } + StandardStorageItem? SelectedItem { get; } ItemManipulationModel ItemManipulationModel { get; } diff --git a/src/Files.App/Views/Properties/CompatibilityPage.xaml.cs b/src/Files.App/Views/Properties/CompatibilityPage.xaml.cs index 2dc0071fa296..bdfacdf9348a 100644 --- a/src/Files.App/Views/Properties/CompatibilityPage.xaml.cs +++ b/src/Files.App/Views/Properties/CompatibilityPage.xaml.cs @@ -19,7 +19,7 @@ public CompatibilityPage() protected override void OnNavigatedTo(NavigationEventArgs e) { var np = (PropertiesPageNavigationParameter)e.Parameter; - if (np.Parameter is ListedItem listedItem) + if (np.Parameter is StandardStorageItem listedItem) CompatibilityViewModel = new CompatibilityViewModel(listedItem); base.OnNavigatedTo(e); diff --git a/src/Files.App/Views/Properties/GeneralPage.xaml.cs b/src/Files.App/Views/Properties/GeneralPage.xaml.cs index 1238d99e5271..3f4cd3037aa2 100644 --- a/src/Files.App/Views/Properties/GeneralPage.xaml.cs +++ b/src/Files.App/Views/Properties/GeneralPage.xaml.cs @@ -122,7 +122,7 @@ async Task SaveLibraryAsync(LibraryItem library) return false; } - async Task SaveCombinedAsync(IList fileOrFolders) + async Task SaveCombinedAsync(IList fileOrFolders) { // Handle the visibility attribute for multiple files var itemMM = AppInstance?.SlimContentPage?.ItemManipulationModel; @@ -155,7 +155,7 @@ await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => return true; } - async Task SaveBaseAsync(ListedItem item) + async Task SaveBaseAsync(StandardStorageItem item) { // Handle the visibility attribute for a single file var itemMM = AppInstance?.SlimContentPage?.ItemManipulationModel; diff --git a/src/Files.App/Views/Properties/HashesPage.xaml.cs b/src/Files.App/Views/Properties/HashesPage.xaml.cs index 1413899684f6..4918feded539 100644 --- a/src/Files.App/Views/Properties/HashesPage.xaml.cs +++ b/src/Files.App/Views/Properties/HashesPage.xaml.cs @@ -26,7 +26,7 @@ public HashesPage() protected override void OnNavigatedTo(NavigationEventArgs e) { var np = (PropertiesPageNavigationParameter)e.Parameter; - if (np.Parameter is ListedItem listedItem) + if (np.Parameter is StandardStorageItem listedItem) HashesViewModel = new(listedItem); base.OnNavigatedTo(e); diff --git a/src/Files.App/Views/Shells/BaseShellPage.cs b/src/Files.App/Views/Shells/BaseShellPage.cs index 1e6af0b502cf..67d7aeb6b3f4 100644 --- a/src/Files.App/Views/Shells/BaseShellPage.cs +++ b/src/Files.App/Views/Shells/BaseShellPage.cs @@ -218,7 +218,7 @@ protected void FilesystemViewModel_PageTypeUpdated(object sender, PageTypeUpdate InstanceViewModel.IsPageTypeCloudDrive = e.IsTypeCloudDrive; } - protected void FilesystemViewModel_OnSelectionRequestedEvent(object sender, List e) + protected void FilesystemViewModel_OnSelectionRequestedEvent(object sender, List e) { // Set focus since selection might occur before the UI finishes updating ContentPage.ItemManipulationModel.FocusFileList(); From 5b56b49d9091fd606a857d71c2319aa3639ce800 Mon Sep 17 00:00:00 2001 From: 0x5bfa <62196528+0x5bfa@users.noreply.github.com> Date: Wed, 12 Jun 2024 18:09:06 +0900 Subject: [PATCH 2/4] Update --- .../Data/Items/StandardRecycleBinItem.cs | 7 +++---- .../Data/Items/StandardStorageItem.cs | 19 ++++++++----------- src/Files.App/Data/Models/ItemViewModel.cs | 4 +--- .../Enumerators/UniversalStorageEnumerator.cs | 4 ++-- .../Utils/Storage/Search/FolderSearch.cs | 4 ++-- .../Views/Layouts/ColumnLayoutPage.xaml | 4 ++-- .../Views/Layouts/DetailsLayoutPage.xaml | 8 ++++---- .../Views/Layouts/GridLayoutPage.xaml | 8 ++++---- 8 files changed, 26 insertions(+), 32 deletions(-) diff --git a/src/Files.App/Data/Items/StandardRecycleBinItem.cs b/src/Files.App/Data/Items/StandardRecycleBinItem.cs index 64a8bd2b69a2..3b88bb6fda30 100644 --- a/src/Files.App/Data/Items/StandardRecycleBinItem.cs +++ b/src/Files.App/Data/Items/StandardRecycleBinItem.cs @@ -1,7 +1,7 @@ // Copyright (c) 2024 Files Community // Licensed under the MIT License. See the LICENSE. -namespace Files.App.Utils +namespace Files.App.Data.Items { /// /// Represents standard item resides in Recycle Bin on Windows to be shown on UI. @@ -39,7 +39,7 @@ public DateTimeOffset DateDeleted get => _DateDeleted; set { - DateDeletedHumanized = dateTimeFormatter.ToShortLabel(value); + DateDeletedHumanized = DateTimeFormatter.ToShortLabel(value); _DateDeleted = value; } } @@ -47,8 +47,7 @@ public DateTimeOffset DateDeleted /// /// Initializes an instance of class. /// - /// - public StandardRecycleBinItem(string folderRelativeId) : base() + public StandardRecycleBinItem() : base() { } } diff --git a/src/Files.App/Data/Items/StandardStorageItem.cs b/src/Files.App/Data/Items/StandardStorageItem.cs index 8183a2022989..bcee89796e17 100644 --- a/src/Files.App/Data/Items/StandardStorageItem.cs +++ b/src/Files.App/Data/Items/StandardStorageItem.cs @@ -3,7 +3,6 @@ using Files.App.ViewModels.Properties; using Files.Shared.Helpers; -using FluentFTP; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Media.Imaging; using System.Drawing; @@ -11,7 +10,7 @@ using System.Text; using Windows.Storage; -namespace Files.App.Utils +namespace Files.App.Data.Items { /// /// Represents storage item to be displayed on UI with necessary storage properties. @@ -64,8 +63,6 @@ public string ItemTooltipText } } - public string FolderRelativeId { get; set; } - public bool HasChildren { get; set; } = true; private bool needsPlaceholderGlyph = true; @@ -173,10 +170,10 @@ public CloudDriveSyncStatusUI SyncStatusUI } // This is used to avoid passing a null value to AutomationProperties.Name, which causes a crash - public string SyncStatusString - { - get => string.IsNullOrEmpty(SyncStatusUI?.SyncStatusString) ? "CloudDriveSyncStatus_Unknown".GetLocalizedResource() : SyncStatusUI.SyncStatusString; - } + public string SyncStatusString => + string.IsNullOrEmpty(SyncStatusUI?.SyncStatusString) + ? "CloudDriveSyncStatus_Unknown".GetLocalizedResource() + : SyncStatusUI.SyncStatusString; private BitmapImage fileImage; public BitmapImage FileImage @@ -426,10 +423,10 @@ public BaseStorageFile ItemFile } // This is a hack used because x:Bind casting did not work properly - public StandardRecycleBinItem AsRecycleBinItem => this as StandardRecycleBinItem; - - public GitItem AsGitItem => this as GitItem; + public StandardRecycleBinItem? AsRecycleBinItem => this as StandardRecycleBinItem; + public GitItem? AsGitItem => this as GitItem; + /// public string Key { get; set; } // Constructor diff --git a/src/Files.App/Data/Models/ItemViewModel.cs b/src/Files.App/Data/Models/ItemViewModel.cs index baaec33c5155..ff6c31394413 100644 --- a/src/Files.App/Data/Models/ItemViewModel.cs +++ b/src/Files.App/Data/Models/ItemViewModel.cs @@ -1094,7 +1094,6 @@ public async Task LoadExtendedItemPropertiesAsync(StandardStorageItem item) await dispatcherQueue.EnqueueOrInvokeAsync(() => { - item.FolderRelativeId = matchingStorageFile.FolderRelativeId; item.ItemType = itemType; item.SyncStatusUI = CloudDriveSyncStatusUI.FromCloudDriveSyncStatus(syncStatus); item.FileFRN = fileFRN; @@ -1139,7 +1138,6 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() => await dispatcherQueue.EnqueueOrInvokeAsync(() => { - item.FolderRelativeId = matchingStorageFolder.FolderRelativeId; item.ItemType = itemType; item.SyncStatusUI = CloudDriveSyncStatusUI.FromCloudDriveSyncStatus(syncStatus); item.FileFRN = fileFRN; @@ -2451,7 +2449,7 @@ public void UpdateDateDisplay(bool isFormatChange) await dispatcherQueue.EnqueueOrInvokeAsync(() => item.ItemDateCreatedReal = item.ItemDateCreatedReal); if (isFormatChange || IsDateDiff(item.ItemDateModifiedReal)) await dispatcherQueue.EnqueueOrInvokeAsync(() => item.ItemDateModifiedReal = item.ItemDateModifiedReal); - if (item is Utils.StandardRecycleBinItem recycleBinItem && (isFormatChange || IsDateDiff(recycleBinItem.DateDeleted))) + if (item is StandardRecycleBinItem recycleBinItem && (isFormatChange || IsDateDiff(recycleBinItem.DateDeleted))) await dispatcherQueue.EnqueueOrInvokeAsync(() => recycleBinItem.DateDeleted = recycleBinItem.DateDeleted); if (item is GitItem gitItem && gitItem.GitLastCommitDate is DateTimeOffset offset && (isFormatChange || IsDateDiff(offset))) await dispatcherQueue.EnqueueOrInvokeAsync(() => gitItem.GitLastCommitDate = gitItem.GitLastCommitDate); diff --git a/src/Files.App/Utils/Storage/Enumerators/UniversalStorageEnumerator.cs b/src/Files.App/Utils/Storage/Enumerators/UniversalStorageEnumerator.cs index 1d3dfd3b9e2d..e3ba95bd92e2 100644 --- a/src/Files.App/Utils/Storage/Enumerators/UniversalStorageEnumerator.cs +++ b/src/Files.App/Utils/Storage/Enumerators/UniversalStorageEnumerator.cs @@ -198,7 +198,7 @@ public static async Task AddFolderAsync( } else if (folder is BinStorageFolder binFolder) { - return new StandardRecycleBinItem(folder.FolderRelativeId) + return new StandardRecycleBinItem() { PrimaryItemAttribute = StorageItemTypes.Folder, ItemNameRaw = folder.DisplayName, @@ -298,7 +298,7 @@ public static async Task AddFileAsync( } else if (file is BinStorageFile binFile) { - return new StandardRecycleBinItem(file.FolderRelativeId) + return new StandardRecycleBinItem() { PrimaryItemAttribute = StorageItemTypes.File, FileExtension = itemFileExtension, diff --git a/src/Files.App/Utils/Storage/Search/FolderSearch.cs b/src/Files.App/Utils/Storage/Search/FolderSearch.cs index cb2702017a4d..a9d1c960d7a5 100644 --- a/src/Files.App/Utils/Storage/Search/FolderSearch.cs +++ b/src/Files.App/Utils/Storage/Search/FolderSearch.cs @@ -409,7 +409,7 @@ private async Task GetListedItemAsync(IStorageItem item) var props = await folder.GetBasicPropertiesAsync(); if (folder is BinStorageFolder binFolder) { - listedItem = new StandardRecycleBinItem(null) + listedItem = new StandardRecycleBinItem() { PrimaryItemAttribute = StorageItemTypes.Folder, ItemNameRaw = folder.DisplayName, @@ -454,7 +454,7 @@ private async Task GetListedItemAsync(IStorageItem item) if (file is BinStorageFile binFile) { - listedItem = new StandardRecycleBinItem(null) + listedItem = new StandardRecycleBinItem() { PrimaryItemAttribute = StorageItemTypes.File, ItemNameRaw = file.Name, diff --git a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml index 5867b5031142..4fc48030aa06 100644 --- a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml +++ b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml @@ -6,7 +6,7 @@ xmlns:cloud="using:Files.App.Utils.Cloud" xmlns:converters="using:Files.App.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:filesystem="using:Files.App.Utils" + xmlns:dataitems="using:Files.App.Data.Items" xmlns:helpers="using:Files.App.Helpers" xmlns:local="using:Files.App.Views.Layouts" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -202,7 +202,7 @@ Tapped="FileList_ItemTapped"> - + - + @@ -1192,7 +1192,7 @@ DataContextChanged="TextBlock_DataContextChanged" IsTextTrimmedChanged="TextBlock_IsTextTrimmedChanged" Style="{StaticResource ColumnContentTextBlock}" - Text="{x:Bind AsRecycleBinItem.ItemDateDeleted, Mode=OneWay}" + Text="{x:Bind AsRecycleBinItem.DateDeletedHumanized, Mode=OneWay}" Visibility="{Binding ColumnsViewModel.DateDeletedColumn.Visibility, ElementName=PageRoot, Mode=OneWay}" /> diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml b/src/Files.App/Views/Layouts/GridLayoutPage.xaml index fcc8f9c0495b..39a4ad688c18 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml @@ -6,7 +6,7 @@ xmlns:cloud="using:Files.App.Utils.Cloud" xmlns:converters="using:Files.App.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:filesystem="using:Files.App.Utils" + xmlns:dataitems="using:Files.App.Data.Items" xmlns:helpers="using:Files.App.Helpers" xmlns:i="using:Microsoft.Xaml.Interactivity" xmlns:icore="using:Microsoft.Xaml.Interactions.Core" @@ -91,7 +91,7 @@ - + - + - + Date: Wed, 12 Jun 2024 18:48:06 +0900 Subject: [PATCH 3/4] Init --- .../Compress/BaseCompressArchiveAction.cs | 2 +- .../Decompress/BaseDecompressArchiveAction.cs | 2 +- .../DecompressArchiveToChildFolderAction.cs | 2 +- .../Content/Background/BaseSetAsAction.cs | 6 +- .../ImageManipulation/BaseRotateAction.cs | 8 +- .../PreviewPopup/LaunchPreviewPopupAction.cs | 4 +- .../Content/Run/RunWithPowershellAction.cs | 2 +- .../Content/Selection/ClearSelectionAction.cs | 8 +- .../Selection/InvertSelectionAction.cs | 8 +- .../Content/Selection/SelectAllAction.cs | 10 +- .../Actions/FileSystem/BaseDeleteAction.cs | 4 +- .../Actions/FileSystem/CopyPathAction.cs | 8 +- .../FileSystem/CopyPathWithQuotesAction.cs | 6 +- .../FileSystem/OpenFileLocationAction.cs | 4 +- .../Actions/FileSystem/PasteItemAction.cs | 2 +- .../FileSystem/PasteItemToSelectionAction.cs | 2 +- .../Actions/FileSystem/RenameAction.cs | 4 +- .../Actions/Global/EditPathAction.cs | 2 +- src/Files.App/Actions/Global/SearchAction.cs | 2 +- .../OpenInNewPane/BaseOpenInNewPaneAction.cs | 2 +- .../OpenInNewTab/BaseOpenInNewTabAction.cs | 2 +- .../BaseOpenInNewWindowAction.cs | 6 +- .../Actions/Open/OpenCommandPaletteAction.cs | 2 +- .../Actions/Open/OpenInVSCodeAction.cs | 2 +- .../Actions/Open/OpenPropertiesAction.cs | 6 +- .../Actions/Start/PinToStartAction.cs | 8 +- .../Actions/Start/UnpinFromStartAction.cs | 4 +- src/Files.App/App.xaml.cs | 2 +- .../ContentPage/ContentPageContext.cs | 30 +-- src/Files.App/Data/Contracts/IShellPage.cs | 6 +- .../ContentPageContextFlyoutFactory.cs | 4 +- .../Extensions/ShellNewEntryExtensions.cs | 2 +- .../Helpers/Dialog/DynamicDialogFactory.cs | 2 +- .../Helpers/Navigation/NavigationHelpers.cs | 26 +-- .../Helpers/UI/UIFilesystemHelpers.cs | 44 ++-- .../Helpers/Win32/Win32Helper.Process.cs | 4 +- .../Utils/RecycleBin/RecycleBinHelpers.cs | 6 +- .../Storage/Helpers/FilePropertiesHelpers.cs | 4 +- .../Storage/Helpers/StorageFileExtensions.cs | 2 +- .../Storage/Operations/FilesystemHelpers.cs | 2 +- .../Operations/FilesystemOperations.cs | 36 +-- .../Operations/ShellFilesystemOperations.cs | 2 +- .../ViewModels/Layouts/BaseLayoutViewModel.cs | 12 +- .../Properties/CustomizationViewModel.cs | 2 +- .../Properties/Items/FileProperties.cs | 2 +- .../Properties/Items/FolderProperties.cs | 2 +- .../Properties/Items/LibraryProperties.cs | 4 +- .../ShellViewModel.cs} | 6 +- .../UserControls/AddressToolbarViewModel.cs | 20 +- .../UserControls/SidebarViewModel.cs | 4 +- .../Widgets/QuickAccessWidgetViewModel.cs | 4 +- src/Files.App/Views/HomePage.xaml.cs | 26 +-- .../Views/Layouts/BaseGroupableLayoutPage.cs | 28 +-- src/Files.App/Views/Layouts/BaseLayoutPage.cs | 76 +++---- .../Views/Layouts/ColumnLayoutPage.xaml.cs | 8 +- .../Views/Layouts/ColumnsLayoutPage.xaml.cs | 28 +-- .../Views/Layouts/DetailsLayoutPage.xaml.cs | 24 +- .../Views/Layouts/GridLayoutPage.xaml.cs | 18 +- src/Files.App/Views/MainPage.xaml.cs | 12 +- .../Views/Properties/GeneralPage.xaml.cs | 12 +- src/Files.App/Views/ShellPanesPage.xaml.cs | 20 +- src/Files.App/Views/Shells/BaseShellPage.cs | 211 +++++++++--------- .../Views/Shells/ColumnShellPage.xaml.cs | 36 +-- .../Views/Shells/ModernShellPage.xaml.cs | 62 ++--- 64 files changed, 454 insertions(+), 453 deletions(-) rename src/Files.App/{Data/Models/ItemViewModel.cs => ViewModels/ShellViewModel.cs} (99%) diff --git a/src/Files.App/Actions/Content/Archives/Compress/BaseCompressArchiveAction.cs b/src/Files.App/Actions/Content/Archives/Compress/BaseCompressArchiveAction.cs index 3831bca97af6..7e1cb31c825e 100644 --- a/src/Files.App/Actions/Content/Archives/Compress/BaseCompressArchiveAction.cs +++ b/src/Files.App/Actions/Content/Archives/Compress/BaseCompressArchiveAction.cs @@ -35,7 +35,7 @@ protected void GetDestination(out string[] sources, out string directory, out st if (sources.Length is not 0) { // Get the current directory path - directory = context.ShellPage.FilesystemViewModel.WorkingDirectory.Normalize(); + directory = context.ShellPage.ShellViewModel.WorkingDirectory.Normalize(); // Get the library save folder if the folder is library item if (App.LibraryManager.TryGetLibrary(directory, out var library) && !library.IsEmpty) diff --git a/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs b/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs index 2f7dfa0cdad9..cfe8039995fb 100644 --- a/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs +++ b/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs @@ -55,7 +55,7 @@ protected async Task DecompressArchiveHereAsync(bool smart = false) { var password = string.Empty; BaseStorageFile archive = await StorageHelpers.ToStorageItem(selectedItem.ItemPath); - BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem(context.ShellPage?.FilesystemViewModel.CurrentFolder?.ItemPath ?? string.Empty); + BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem(context.ShellPage?.ShellViewModel.CurrentFolder?.ItemPath ?? string.Empty); if (archive?.Path is null) return; diff --git a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveToChildFolderAction.cs b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveToChildFolderAction.cs index c7cd966391a3..361bc3bf2fb1 100644 --- a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveToChildFolderAction.cs +++ b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveToChildFolderAction.cs @@ -31,7 +31,7 @@ public override async Task ExecuteAsync(object? parameter = null) var password = string.Empty; BaseStorageFile archive = await StorageHelpers.ToStorageItem(selectedItem.ItemPath); - BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem(context.ShellPage?.FilesystemViewModel.CurrentFolder.ItemPath); + BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem(context.ShellPage?.ShellViewModel.CurrentFolder.ItemPath); BaseStorageFolder destinationFolder = null; if (archive?.Path is null) diff --git a/src/Files.App/Actions/Content/Background/BaseSetAsAction.cs b/src/Files.App/Actions/Content/Background/BaseSetAsAction.cs index d4239457c320..3af2b64f1ff9 100644 --- a/src/Files.App/Actions/Content/Background/BaseSetAsAction.cs +++ b/src/Files.App/Actions/Content/Background/BaseSetAsAction.cs @@ -17,7 +17,7 @@ internal abstract class BaseSetAsAction : ObservableObject, IAction context.ShellPage is not null && context.PageType != ContentPageTypes.RecycleBin && context.PageType != ContentPageTypes.ZipFolder && - (context.ShellPage?.SlimContentPage?.SelectedItemsPropertiesViewModel?.IsCompatibleToSetAsWindowsWallpaper ?? false); + (context.ShellPage?.LayoutPage?.SelectedItemsPropertiesViewModel?.IsCompatibleToSetAsWindowsWallpaper ?? false); public BaseSetAsAction() { @@ -38,9 +38,9 @@ private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) case nameof(IContentPageContext.SelectedItem): case nameof(IContentPageContext.SelectedItems): { - if (context.ShellPage is not null && context.ShellPage.SlimContentPage is not null) + if (context.ShellPage is not null && context.ShellPage.LayoutPage is not null) { - var viewModel = context.ShellPage.SlimContentPage.SelectedItemsPropertiesViewModel; + var viewModel = context.ShellPage.LayoutPage.SelectedItemsPropertiesViewModel; var extensions = context.SelectedItems.Select(selectedItem => selectedItem.FileExtension).Distinct().ToList(); viewModel.CheckAllFileExtensions(extensions); diff --git a/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs b/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs index eead57e36a66..6c2e5cea5660 100644 --- a/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs +++ b/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs @@ -21,7 +21,7 @@ internal abstract class BaseRotateAction : ObservableObject, IAction public bool IsExecutable => IsContextPageTypeAdaptedToCommand() && - (context.ShellPage?.SlimContentPage?.SelectedItemsPropertiesViewModel?.IsCompatibleToSetAsWindowsWallpaper ?? false); + (context.ShellPage?.LayoutPage?.SelectedItemsPropertiesViewModel?.IsCompatibleToSetAsWindowsWallpaper ?? false); public BaseRotateAction() { @@ -35,7 +35,7 @@ public async Task ExecuteAsync(object? parameter = null) { await Task.WhenAll(context.SelectedItems.Select(image => BitmapHelper.RotateAsync(PathNormalization.NormalizePath(image.ItemPath), Rotation))); - context.ShellPage?.SlimContentPage?.ItemManipulationModel?.RefreshItemsThumbnail(); + context.ShellPage?.LayoutPage?.ItemManipulationModel?.RefreshItemsThumbnail(); await _infoPaneViewModel.UpdateSelectedItemPreviewAsync(); } @@ -52,9 +52,9 @@ private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName is nameof(IContentPageContext.SelectedItem)) { - if (context.ShellPage is not null && context.ShellPage.SlimContentPage is not null) + if (context.ShellPage is not null && context.ShellPage.LayoutPage is not null) { - var viewModel = context.ShellPage.SlimContentPage.SelectedItemsPropertiesViewModel; + var viewModel = context.ShellPage.LayoutPage.SelectedItemsPropertiesViewModel; var extensions = context.SelectedItems.Select(selectedItem => selectedItem.FileExtension).Distinct().ToList(); viewModel.CheckAllFileExtensions(extensions); diff --git a/src/Files.App/Actions/Content/PreviewPopup/LaunchPreviewPopupAction.cs b/src/Files.App/Actions/Content/PreviewPopup/LaunchPreviewPopupAction.cs index e78e93474ddc..7ef70fa0298e 100644 --- a/src/Files.App/Actions/Content/PreviewPopup/LaunchPreviewPopupAction.cs +++ b/src/Files.App/Actions/Content/PreviewPopup/LaunchPreviewPopupAction.cs @@ -20,8 +20,8 @@ public HotKey HotKey public bool IsExecutable => context.SelectedItems.Count == 1 && - (!context.ShellPage?.ToolbarViewModel?.IsEditModeEnabled ?? false) && - (!context.ShellPage?.SlimContentPage?.IsRenamingItem ?? false); + (!context.ShellPage?.AddressToolbarViewModel?.IsEditModeEnabled ?? false) && + (!context.ShellPage?.LayoutPage?.IsRenamingItem ?? false); public LaunchPreviewPopupAction() { diff --git a/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs b/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs index bd4029c31c5c..2dac1b004f4a 100644 --- a/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs +++ b/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs @@ -31,7 +31,7 @@ public RunWithPowershellAction() public Task ExecuteAsync(object? parameter = null) { - return Win32Helper.RunPowershellCommandAsync($"{context.ShellPage?.SlimContentPage?.SelectedItem?.ItemPath}", false); + return Win32Helper.RunPowershellCommandAsync($"{context.ShellPage?.LayoutPage?.SelectedItem?.ItemPath}", false); } private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) diff --git a/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs b/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs index e0eb0e783bd3..8fc9bfe365b3 100644 --- a/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs +++ b/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs @@ -30,9 +30,9 @@ public bool IsExecutable if (page is null) return false; - bool isCommandPaletteOpen = page.ToolbarViewModel.IsCommandPaletteOpen; - bool isEditing = page.ToolbarViewModel.IsEditModeEnabled; - bool isRenaming = page.SlimContentPage.IsRenamingItem; + bool isCommandPaletteOpen = page.AddressToolbarViewModel.IsCommandPaletteOpen; + bool isEditing = page.AddressToolbarViewModel.IsEditModeEnabled; + bool isRenaming = page.LayoutPage.IsRenamingItem; return isCommandPaletteOpen || (!isEditing && !isRenaming); } @@ -45,7 +45,7 @@ public ClearSelectionAction() public Task ExecuteAsync(object? parameter = null) { - context.ShellPage?.SlimContentPage?.ItemManipulationModel?.ClearSelection(); + context.ShellPage?.LayoutPage?.ItemManipulationModel?.ClearSelection(); return Task.CompletedTask; } diff --git a/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs b/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs index 4558204c0476..9509f057824d 100644 --- a/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs +++ b/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs @@ -30,9 +30,9 @@ public bool IsExecutable if (page is null) return false; - bool isCommandPaletteOpen = page.ToolbarViewModel.IsCommandPaletteOpen; - bool isEditing = page.ToolbarViewModel.IsEditModeEnabled; - bool isRenaming = page.SlimContentPage.IsRenamingItem; + bool isCommandPaletteOpen = page.AddressToolbarViewModel.IsCommandPaletteOpen; + bool isEditing = page.AddressToolbarViewModel.IsEditModeEnabled; + bool isRenaming = page.LayoutPage.IsRenamingItem; return isCommandPaletteOpen || (!isEditing && !isRenaming); } @@ -45,7 +45,7 @@ public InvertSelectionAction() public Task ExecuteAsync(object? parameter = null) { - context?.ShellPage?.SlimContentPage?.ItemManipulationModel?.InvertSelection(); + context?.ShellPage?.LayoutPage?.ItemManipulationModel?.InvertSelection(); return Task.CompletedTask; } diff --git a/src/Files.App/Actions/Content/Selection/SelectAllAction.cs b/src/Files.App/Actions/Content/Selection/SelectAllAction.cs index dc10151fd933..359802ef8dab 100644 --- a/src/Files.App/Actions/Content/Selection/SelectAllAction.cs +++ b/src/Files.App/Actions/Content/Selection/SelectAllAction.cs @@ -30,14 +30,14 @@ public bool IsExecutable if (page is null) return false; - int itemCount = page.FilesystemViewModel.FilesAndFolders.Count; + int itemCount = page.ShellViewModel.FilesAndFolders.Count; int selectedItemCount = context.SelectedItems.Count; if (itemCount == selectedItemCount) return false; - bool isCommandPaletteOpen = page.ToolbarViewModel.IsCommandPaletteOpen; - bool isEditing = page.ToolbarViewModel.IsEditModeEnabled; - bool isRenaming = page.SlimContentPage?.IsRenamingItem ?? false; + bool isCommandPaletteOpen = page.AddressToolbarViewModel.IsCommandPaletteOpen; + bool isEditing = page.AddressToolbarViewModel.IsEditModeEnabled; + bool isRenaming = page.LayoutPage?.IsRenamingItem ?? false; return isCommandPaletteOpen || (!isEditing && !isRenaming); } @@ -50,7 +50,7 @@ public SelectAllAction() public Task ExecuteAsync(object? parameter = null) { - context.ShellPage?.SlimContentPage?.ItemManipulationModel?.SelectAllItems(); + context.ShellPage?.LayoutPage?.ItemManipulationModel?.SelectAllItems(); return Task.CompletedTask; } diff --git a/src/Files.App/Actions/FileSystem/BaseDeleteAction.cs b/src/Files.App/Actions/FileSystem/BaseDeleteAction.cs index bbb385287a92..a564bc705c11 100644 --- a/src/Files.App/Actions/FileSystem/BaseDeleteAction.cs +++ b/src/Files.App/Actions/FileSystem/BaseDeleteAction.cs @@ -13,7 +13,7 @@ internal abstract class BaseDeleteAction : BaseUIAction public override bool IsExecutable => context.HasSelection && - (!context.ShellPage?.SlimContentPage?.IsRenamingItem ?? false) && + (!context.ShellPage?.LayoutPage?.IsRenamingItem ?? false) && UIHelpers.CanShowDialog; public BaseDeleteAction() @@ -37,7 +37,7 @@ item.PrimaryItemAttribute is StorageItemTypes.File if (context.ShellPage is IShellPage shellPage) { await shellPage.FilesystemHelpers.DeleteItemsAsync(items, settings.DeleteConfirmationPolicy, permanently, true); - await shellPage.FilesystemViewModel.ApplyFilesAndFoldersChangesAsync(); + await shellPage.ShellViewModel.ApplyFilesAndFoldersChangesAsync(); } } diff --git a/src/Files.App/Actions/FileSystem/CopyPathAction.cs b/src/Files.App/Actions/FileSystem/CopyPathAction.cs index 19a7fa955566..9b291da33dd2 100644 --- a/src/Files.App/Actions/FileSystem/CopyPathAction.cs +++ b/src/Files.App/Actions/FileSystem/CopyPathAction.cs @@ -31,11 +31,11 @@ public CopyPathAction() public Task ExecuteAsync(object? parameter = null) { - if (context.ShellPage?.SlimContentPage is not null) + if (context.ShellPage?.LayoutPage is not null) { - var path = context.ShellPage.SlimContentPage.SelectedItems is not null - ? context.ShellPage.SlimContentPage.SelectedItems.Select(x => x.ItemPath).Aggregate((accum, current) => accum + "\n" + current) - : context.ShellPage.FilesystemViewModel.WorkingDirectory; + var path = context.ShellPage.LayoutPage.SelectedItems is not null + ? context.ShellPage.LayoutPage.SelectedItems.Select(x => x.ItemPath).Aggregate((accum, current) => accum + "\n" + current) + : context.ShellPage.ShellViewModel.WorkingDirectory; if (FtpHelpers.IsFtpPath(path)) path = path.Replace("\\", "/", StringComparison.Ordinal); diff --git a/src/Files.App/Actions/FileSystem/CopyPathWithQuotesAction.cs b/src/Files.App/Actions/FileSystem/CopyPathWithQuotesAction.cs index 957ec14765c0..1bd15138c1c7 100644 --- a/src/Files.App/Actions/FileSystem/CopyPathWithQuotesAction.cs +++ b/src/Files.App/Actions/FileSystem/CopyPathWithQuotesAction.cs @@ -31,12 +31,12 @@ public CopyPathWithQuotesAction() public Task ExecuteAsync(object? parameter = null) { - if (context.ShellPage?.SlimContentPage is not null) + if (context.ShellPage?.LayoutPage is not null) { - var selectedItems = context.ShellPage.SlimContentPage.SelectedItems; + var selectedItems = context.ShellPage.LayoutPage.SelectedItems; var path = selectedItems is not null ? string.Join("\n", selectedItems.Select(item => $"\"{item.ItemPath}\"")) - : context.ShellPage.FilesystemViewModel.WorkingDirectory; + : context.ShellPage.ShellViewModel.WorkingDirectory; if (FtpHelpers.IsFtpPath(path)) path = path.Replace("\\", "/", StringComparison.Ordinal); diff --git a/src/Files.App/Actions/FileSystem/OpenFileLocationAction.cs b/src/Files.App/Actions/FileSystem/OpenFileLocationAction.cs index 28090f560b95..8e37acd1be0d 100644 --- a/src/Files.App/Actions/FileSystem/OpenFileLocationAction.cs +++ b/src/Files.App/Actions/FileSystem/OpenFileLocationAction.cs @@ -32,7 +32,7 @@ public OpenFileLocationAction() public async Task ExecuteAsync(object? parameter = null) { - if (context.ShellPage?.FilesystemViewModel is null) + if (context.ShellPage?.ShellViewModel is null) return; var item = context.SelectedItem as ShortcutItem; @@ -42,7 +42,7 @@ public async Task ExecuteAsync(object? parameter = null) // Check if destination path exists var folderPath = Path.GetDirectoryName(item.TargetPath); - var destFolder = await context.ShellPage.FilesystemViewModel.GetFolderWithPathFromPathAsync(folderPath); + var destFolder = await context.ShellPage.ShellViewModel.GetFolderWithPathFromPathAsync(folderPath); if (destFolder) { diff --git a/src/Files.App/Actions/FileSystem/PasteItemAction.cs b/src/Files.App/Actions/FileSystem/PasteItemAction.cs index 4f9afe5bd2ea..a89c0d5a59f1 100644 --- a/src/Files.App/Actions/FileSystem/PasteItemAction.cs +++ b/src/Files.App/Actions/FileSystem/PasteItemAction.cs @@ -43,7 +43,7 @@ public async Task ExecuteAsync(object? parameter = null) if (context.ShellPage is null) return; - string path = context.ShellPage.FilesystemViewModel.WorkingDirectory; + string path = context.ShellPage.ShellViewModel.WorkingDirectory; await UIFilesystemHelpers.PasteItemAsync(path, context.ShellPage); } diff --git a/src/Files.App/Actions/FileSystem/PasteItemToSelectionAction.cs b/src/Files.App/Actions/FileSystem/PasteItemToSelectionAction.cs index 1c9611c3c053..337918038fb6 100644 --- a/src/Files.App/Actions/FileSystem/PasteItemToSelectionAction.cs +++ b/src/Files.App/Actions/FileSystem/PasteItemToSelectionAction.cs @@ -37,7 +37,7 @@ public async Task ExecuteAsync(object? parameter = null) string path = context.SelectedItem is StandardStorageItem selectedItem ? selectedItem.ItemPath - : context.ShellPage.FilesystemViewModel.WorkingDirectory; + : context.ShellPage.ShellViewModel.WorkingDirectory; await UIFilesystemHelpers.PasteItemAsync(path, context.ShellPage); } diff --git a/src/Files.App/Actions/FileSystem/RenameAction.cs b/src/Files.App/Actions/FileSystem/RenameAction.cs index 621b1266668b..2a317704d8cc 100644 --- a/src/Files.App/Actions/FileSystem/RenameAction.cs +++ b/src/Files.App/Actions/FileSystem/RenameAction.cs @@ -22,7 +22,7 @@ public RichGlyph Glyph public bool IsExecutable => context.ShellPage is not null && IsPageTypeValid() && - context.ShellPage.SlimContentPage is not null && + context.ShellPage.LayoutPage is not null && IsSelectionValid(); public RenameAction() @@ -34,7 +34,7 @@ public RenameAction() public Task ExecuteAsync(object? parameter = null) { - context.ShellPage?.SlimContentPage?.ItemManipulationModel.StartRenameItem(); + context.ShellPage?.LayoutPage?.ItemManipulationModel.StartRenameItem(); return Task.CompletedTask; } diff --git a/src/Files.App/Actions/Global/EditPathAction.cs b/src/Files.App/Actions/Global/EditPathAction.cs index cd02dfa97a90..469998f0f72c 100644 --- a/src/Files.App/Actions/Global/EditPathAction.cs +++ b/src/Files.App/Actions/Global/EditPathAction.cs @@ -27,7 +27,7 @@ public EditPathAction() public Task ExecuteAsync(object? parameter = null) { if (context.ShellPage is not null) - context.ShellPage.ToolbarViewModel.IsEditModeEnabled = true; + context.ShellPage.AddressToolbarViewModel.IsEditModeEnabled = true; return Task.CompletedTask; } diff --git a/src/Files.App/Actions/Global/SearchAction.cs b/src/Files.App/Actions/Global/SearchAction.cs index cf2bac0ee9a4..2ef9a6749f6a 100644 --- a/src/Files.App/Actions/Global/SearchAction.cs +++ b/src/Files.App/Actions/Global/SearchAction.cs @@ -34,7 +34,7 @@ public SearchAction() public Task ExecuteAsync(object? parameter = null) { - context.ShellPage!.ToolbarViewModel.SwitchSearchBoxVisibility(); + context.ShellPage!.AddressToolbarViewModel.SwitchSearchBoxVisibility(); return Task.CompletedTask; } diff --git a/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs b/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs index e6f73a419648..523e431e2095 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs @@ -33,7 +33,7 @@ public virtual Task ExecuteAsync(object? parameter = null) { NavigationHelpers.OpenInSecondaryPane( ContentPageContext.ShellPage, - ContentPageContext.ShellPage.SlimContentPage.SelectedItems.FirstOrDefault()); + ContentPageContext.ShellPage.LayoutPage.SelectedItems.FirstOrDefault()); return Task.CompletedTask; } diff --git a/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs b/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs index 91d616e051e0..9a9558a9e4bf 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs @@ -24,7 +24,7 @@ public virtual bool IsAccessibleGlobally public virtual bool IsExecutable => ContentPageContext.ShellPage is not null && - ContentPageContext.ShellPage.SlimContentPage is not null && + ContentPageContext.ShellPage.LayoutPage is not null && ContentPageContext.SelectedItems.Count is not 0 && ContentPageContext.SelectedItems.Count <= 5 && ContentPageContext.SelectedItems.Count(x => x.IsFolder) == ContentPageContext.SelectedItems.Count && diff --git a/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs b/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs index ca76483c2270..00ab5d6a808b 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs @@ -29,7 +29,7 @@ public virtual bool IsAccessibleGlobally public virtual bool IsExecutable => ContentPageContext.ShellPage is not null && - ContentPageContext.ShellPage.SlimContentPage is not null && + ContentPageContext.ShellPage.LayoutPage is not null && ContentPageContext.SelectedItems.Count is not 0 && ContentPageContext.SelectedItems.Count <= 5 && ContentPageContext.SelectedItems.Count(x => x.IsFolder) == ContentPageContext.SelectedItems.Count && @@ -42,10 +42,10 @@ public BaseOpenInNewWindowAction() public virtual async Task ExecuteAsync(object? parameter = null) { - if (ContentPageContext.ShellPage?.SlimContentPage?.SelectedItems is null) + if (ContentPageContext.ShellPage?.LayoutPage?.SelectedItems is null) return; - List items = ContentPageContext.ShellPage.SlimContentPage.SelectedItems; + List items = ContentPageContext.ShellPage.LayoutPage.SelectedItems; foreach (StandardStorageItem listedItem in items) { diff --git a/src/Files.App/Actions/Open/OpenCommandPaletteAction.cs b/src/Files.App/Actions/Open/OpenCommandPaletteAction.cs index 4d61f1022bc9..5ece5b1179f1 100644 --- a/src/Files.App/Actions/Open/OpenCommandPaletteAction.cs +++ b/src/Files.App/Actions/Open/OpenCommandPaletteAction.cs @@ -23,7 +23,7 @@ public OpenCommandPaletteAction() public Task ExecuteAsync(object? parameter = null) { - _context.ShellPage?.ToolbarViewModel.OpenCommandPalette(); + _context.ShellPage?.AddressToolbarViewModel.OpenCommandPalette(); return Task.CompletedTask; } diff --git a/src/Files.App/Actions/Open/OpenInVSCodeAction.cs b/src/Files.App/Actions/Open/OpenInVSCodeAction.cs index 5d6ede12f8e3..a65e5b11eb00 100644 --- a/src/Files.App/Actions/Open/OpenInVSCodeAction.cs +++ b/src/Files.App/Actions/Open/OpenInVSCodeAction.cs @@ -32,7 +32,7 @@ public OpenInVSCodeAction() public Task ExecuteAsync(object? parameter = null) { - return Win32Helper.RunPowershellCommandAsync($"code \'{_context.ShellPage?.FilesystemViewModel.WorkingDirectory}\'", false); + return Win32Helper.RunPowershellCommandAsync($"code \'{_context.ShellPage?.ShellViewModel.WorkingDirectory}\'", false); } private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) diff --git a/src/Files.App/Actions/Open/OpenPropertiesAction.cs b/src/Files.App/Actions/Open/OpenPropertiesAction.cs index 5628eafec65e..062c34e4fa2d 100644 --- a/src/Files.App/Actions/Open/OpenPropertiesAction.cs +++ b/src/Files.App/Actions/Open/OpenPropertiesAction.cs @@ -33,7 +33,7 @@ public OpenPropertiesAction() public Task ExecuteAsync(object? parameter = null) { - var page = context.ShellPage?.SlimContentPage; + var page = context.ShellPage?.LayoutPage; if (page?.ItemContextMenuFlyout.IsOpen ?? false) page.ItemContextMenuFlyout.Closed += OpenPropertiesFromItemContextMenuFlyout; @@ -47,7 +47,7 @@ public Task ExecuteAsync(object? parameter = null) private void OpenPropertiesFromItemContextMenuFlyout(object? _, object e) { - var page = context.ShellPage?.SlimContentPage; + var page = context.ShellPage?.LayoutPage; if (page is not null) page.ItemContextMenuFlyout.Closed -= OpenPropertiesFromItemContextMenuFlyout; @@ -56,7 +56,7 @@ private void OpenPropertiesFromItemContextMenuFlyout(object? _, object e) private void OpenPropertiesFromBaseContextMenuFlyout(object? _, object e) { - var page = context.ShellPage?.SlimContentPage; + var page = context.ShellPage?.LayoutPage; if (page is not null) page.BaseContextMenuFlyout.Closed -= OpenPropertiesFromBaseContextMenuFlyout; diff --git a/src/Files.App/Actions/Start/PinToStartAction.cs b/src/Files.App/Actions/Start/PinToStartAction.cs index 7d07e3c152b9..cc98ec95c653 100644 --- a/src/Files.App/Actions/Start/PinToStartAction.cs +++ b/src/Files.App/Actions/Start/PinToStartAction.cs @@ -33,9 +33,9 @@ public PinToStartAction() public async Task ExecuteAsync(object? parameter = null) { - if (context.SelectedItems.Count > 0 && context.ShellPage?.SlimContentPage?.SelectedItems is not null) + if (context.SelectedItems.Count > 0 && context.ShellPage?.LayoutPage?.SelectedItems is not null) { - foreach (StandardStorageItem listedItem in context.ShellPage.SlimContentPage.SelectedItems) + foreach (StandardStorageItem listedItem in context.ShellPage.LayoutPage.SelectedItems) { IStorable storable = listedItem.IsFolder switch { @@ -45,9 +45,9 @@ public async Task ExecuteAsync(object? parameter = null) await StartMenuService.PinAsync(storable, listedItem.Name); } } - else if (context.ShellPage?.FilesystemViewModel?.CurrentFolder is not null) + else if (context.ShellPage?.ShellViewModel?.CurrentFolder is not null) { - var currentFolder = context.ShellPage.FilesystemViewModel.CurrentFolder; + var currentFolder = context.ShellPage.ShellViewModel.CurrentFolder; var folder = await StorageService.GetFolderAsync(currentFolder.ItemPath); await StartMenuService.PinAsync(folder, currentFolder.Name); diff --git a/src/Files.App/Actions/Start/UnpinFromStartAction.cs b/src/Files.App/Actions/Start/UnpinFromStartAction.cs index dc757be96000..5f152de3d781 100644 --- a/src/Files.App/Actions/Start/UnpinFromStartAction.cs +++ b/src/Files.App/Actions/Start/UnpinFromStartAction.cs @@ -31,7 +31,7 @@ public async Task ExecuteAsync(object? parameter = null) { if (context.SelectedItems.Count > 0) { - foreach (StandardStorageItem listedItem in context.ShellPage?.SlimContentPage.SelectedItems) + foreach (StandardStorageItem listedItem in context.ShellPage?.LayoutPage.SelectedItems) { IStorable storable = listedItem.IsFolder switch { @@ -43,7 +43,7 @@ public async Task ExecuteAsync(object? parameter = null) } else { - var currentFolder = context.ShellPage.FilesystemViewModel.CurrentFolder; + var currentFolder = context.ShellPage.ShellViewModel.CurrentFolder; var folder = await StorageService.GetFolderAsync(currentFolder.ItemPath); await StartMenuService.UnpinAsync(folder); diff --git a/src/Files.App/App.xaml.cs b/src/Files.App/App.xaml.cs index 3e9cf91b98a1..ad4fa6fd9049 100644 --- a/src/Files.App/App.xaml.cs +++ b/src/Files.App/App.xaml.cs @@ -216,7 +216,7 @@ private async void Window_Closed(object sender, WindowEventArgs args) if (instance is null) return; - var items = (instance.TabItemContent as ShellPanesPage)?.ActivePane?.SlimContentPage?.SelectedItems; + var items = (instance.TabItemContent as ShellPanesPage)?.ActivePane?.LayoutPage?.SelectedItems; if (items is null) return; diff --git a/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs b/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs index c5da3c256a08..32fa86f31746 100644 --- a/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs +++ b/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs @@ -12,7 +12,7 @@ internal sealed class ContentPageContext : ObservableObject, IContentPageContext private readonly IMultiPanesContext context = Ioc.Default.GetRequiredService(); - private ItemViewModel? filesystemViewModel; + private ShellViewModel? filesystemViewModel; public IShellPage? ShellPage => context?.ActivePaneOrColumn; @@ -21,9 +21,9 @@ internal sealed class ContentPageContext : ObservableObject, IContentPageContext private ContentPageTypes pageType = ContentPageTypes.None; public ContentPageTypes PageType => pageType; - public StandardStorageItem? Folder => ShellPage?.FilesystemViewModel?.CurrentFolder; + public StandardStorageItem? Folder => ShellPage?.ShellViewModel?.CurrentFolder; - public bool HasItem => ShellPage?.ToolbarViewModel?.HasItem ?? false; + public bool HasItem => ShellPage?.AddressToolbarViewModel?.HasItem ?? false; public bool HasSelection => SelectedItems.Count is not 0; public StandardStorageItem? SelectedItem => SelectedItems.Count is 1 ? SelectedItems[0] : null; @@ -31,15 +31,15 @@ internal sealed class ContentPageContext : ObservableObject, IContentPageContext private IReadOnlyList selectedItems = emptyItems; public IReadOnlyList SelectedItems => selectedItems; - public bool CanRefresh => ShellPage is not null && ShellPage.ToolbarViewModel.CanRefresh; + public bool CanRefresh => ShellPage is not null && ShellPage.AddressToolbarViewModel.CanRefresh; - public bool CanGoBack => ShellPage is not null && ShellPage.ToolbarViewModel.CanGoBack; + public bool CanGoBack => ShellPage is not null && ShellPage.AddressToolbarViewModel.CanGoBack; - public bool CanGoForward => ShellPage is not null && ShellPage.ToolbarViewModel.CanGoForward; + public bool CanGoForward => ShellPage is not null && ShellPage.AddressToolbarViewModel.CanGoForward; - public bool CanNavigateToParent => ShellPage is not null && ShellPage.ToolbarViewModel.CanNavigateToParent; + public bool CanNavigateToParent => ShellPage is not null && ShellPage.AddressToolbarViewModel.CanNavigateToParent; - public bool IsSearchBoxVisible => ShellPage is not null && ShellPage.ToolbarViewModel.IsSearchBoxVisible; + public bool IsSearchBoxVisible => ShellPage is not null && ShellPage.AddressToolbarViewModel.IsSearchBoxVisible; public bool CanCreateItem => GetCanCreateItem(); @@ -51,7 +51,7 @@ internal sealed class ContentPageContext : ObservableObject, IContentPageContext public bool CanExecuteGitAction => IsGitRepository && !GitHelpers.IsExecutingGitAction; - public string? SolutionFilePath => ShellPage?.FilesystemViewModel?.SolutionFilePath; + public string? SolutionFilePath => ShellPage?.ShellViewModel?.SolutionFilePath; public ContentPageContext() { @@ -74,7 +74,7 @@ private void Context_Changing(object? sender, EventArgs e) page.PropertyChanged -= Page_PropertyChanged; page.ContentChanged -= Page_ContentChanged; page.InstanceViewModel.PropertyChanged -= InstanceViewModel_PropertyChanged; - page.ToolbarViewModel.PropertyChanged -= ToolbarViewModel_PropertyChanged; + page.AddressToolbarViewModel.PropertyChanged -= ToolbarViewModel_PropertyChanged; if (page.PaneHolder is not null) page.PaneHolder.PropertyChanged -= PaneHolder_PropertyChanged; @@ -93,13 +93,13 @@ private void Context_Changed(object? sender, EventArgs e) page.PropertyChanged += Page_PropertyChanged; page.ContentChanged += Page_ContentChanged; page.InstanceViewModel.PropertyChanged += InstanceViewModel_PropertyChanged; - page.ToolbarViewModel.PropertyChanged += ToolbarViewModel_PropertyChanged; + page.AddressToolbarViewModel.PropertyChanged += ToolbarViewModel_PropertyChanged; if (page.PaneHolder is not null) page.PaneHolder.PropertyChanged += PaneHolder_PropertyChanged; } - filesystemViewModel = ShellPage?.FilesystemViewModel; + filesystemViewModel = ShellPage?.ShellViewModel; if (filesystemViewModel is not null) filesystemViewModel.PropertyChanged += FilesystemViewModel_PropertyChanged; @@ -178,10 +178,10 @@ private void FilesystemViewModel_PropertyChanged(object? sender, PropertyChanged { switch (e.PropertyName) { - case nameof(ItemViewModel.CurrentFolder): + case nameof(ShellViewModel.CurrentFolder): OnPropertyChanged(nameof(Folder)); break; - case nameof(ItemViewModel.SolutionFilePath): + case nameof(ShellViewModel.SolutionFilePath): OnPropertyChanged(nameof(SolutionFilePath)); break; } @@ -228,7 +228,7 @@ private void UpdateSelectedItems() bool oldHasSelection = HasSelection; StandardStorageItem? oldSelectedItem = SelectedItem; - IReadOnlyList items = ShellPage?.ToolbarViewModel?.SelectedItems?.AsReadOnly() ?? emptyItems; + IReadOnlyList items = ShellPage?.AddressToolbarViewModel?.SelectedItems?.AsReadOnly() ?? emptyItems; if (SetProperty(ref selectedItems, items, nameof(SelectedItems))) { if (HasSelection != oldHasSelection) diff --git a/src/Files.App/Data/Contracts/IShellPage.cs b/src/Files.App/Data/Contracts/IShellPage.cs index 57256fef21a5..f6faa3986b36 100644 --- a/src/Files.App/Data/Contracts/IShellPage.cs +++ b/src/Files.App/Data/Contracts/IShellPage.cs @@ -5,19 +5,19 @@ namespace Files.App.Data.Contracts { public interface IShellPage : ITabBarItemContent, IMultiPaneInfo, IDisposable, INotifyPropertyChanged { - ItemViewModel FilesystemViewModel { get; } + ShellViewModel ShellViewModel { get; } CurrentInstanceViewModel InstanceViewModel { get; } StorageHistoryHelpers StorageHistoryHelpers { get; } - IBaseLayoutPage SlimContentPage { get; } + IBaseLayoutPage LayoutPage { get; } Type CurrentPageType { get; } IFilesystemHelpers FilesystemHelpers { get; } - AddressToolbarViewModel ToolbarViewModel { get; } + AddressToolbarViewModel AddressToolbarViewModel { get; } bool CanNavigateBackward { get; } diff --git a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs index 37559f4ab67c..137e0d9c071f 100644 --- a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs +++ b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs @@ -24,7 +24,7 @@ public static class ContentPageContextFlyoutFactory private static readonly ICommandManager Commands = Ioc.Default.GetRequiredService(); private static IStorageArchiveService StorageArchiveService { get; } = Ioc.Default.GetRequiredService(); - public static List GetItemContextCommandsWithoutShellItems(CurrentInstanceViewModel currentInstanceViewModel, List selectedItems, BaseLayoutViewModel commandsViewModel, bool shiftPressed, SelectedItemsPropertiesViewModel? selectedItemsPropertiesViewModel, ItemViewModel? itemViewModel = null) + public static List GetItemContextCommandsWithoutShellItems(CurrentInstanceViewModel currentInstanceViewModel, List selectedItems, BaseLayoutViewModel commandsViewModel, bool shiftPressed, SelectedItemsPropertiesViewModel? selectedItemsPropertiesViewModel, ShellViewModel? itemViewModel = null) { var menuItemsList = GetBaseItemMenuItems(commandsViewModel: commandsViewModel, selectedItems: selectedItems, selectedItemsPropertiesViewModel: selectedItemsPropertiesViewModel, currentInstanceViewModel: currentInstanceViewModel, itemViewModel: itemViewModel); menuItemsList = Filter(items: menuItemsList, shiftPressed: shiftPressed, currentInstanceViewModel: currentInstanceViewModel, selectedItems: selectedItems, removeOverflowMenu: false); @@ -80,7 +80,7 @@ public static List GetBaseItemMenuItems( SelectedItemsPropertiesViewModel? selectedItemsPropertiesViewModel, List selectedItems, CurrentInstanceViewModel currentInstanceViewModel, - ItemViewModel? itemViewModel = null) + ShellViewModel? itemViewModel = null) { bool itemsSelected = itemViewModel is null; bool canDecompress = selectedItems.Any() && selectedItems.All(x => x.IsArchive) diff --git a/src/Files.App/Extensions/ShellNewEntryExtensions.cs b/src/Files.App/Extensions/ShellNewEntryExtensions.cs index ed697800a589..3688bac70833 100644 --- a/src/Files.App/Extensions/ShellNewEntryExtensions.cs +++ b/src/Files.App/Extensions/ShellNewEntryExtensions.cs @@ -36,7 +36,7 @@ public static async Task> GetNewContextMenuEntries() public static async Task> Create(this ShellNewEntry shellEntry, string filePath, IShellPage associatedInstance) { - var parentFolder = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(filePath)); + var parentFolder = await associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(filePath)); if (parentFolder) { return await Create(shellEntry, parentFolder, filePath); diff --git a/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs b/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs index 12961015584c..4c3b6af8c7ec 100644 --- a/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs +++ b/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs @@ -324,7 +324,7 @@ public static DynamicDialog GetFor_RenameRequiresHigherPermissions(string path) SecondaryButtonAction = (vm, e) => { var context = Ioc.Default.GetRequiredService(); - var item = context.ShellPage?.FilesystemViewModel.FilesAndFolders.FirstOrDefault(li => li.ItemPath.Equals(path)); + var item = context.ShellPage?.ShellViewModel.FilesAndFolders.FirstOrDefault(li => li.ItemPath.Equals(path)); if (context.ShellPage is not null && item is not null) FilePropertiesHelpers.OpenPropertiesWindow(item, context.ShellPage, PropertiesNavigationViewItemType.Security); diff --git a/src/Files.App/Helpers/Navigation/NavigationHelpers.cs b/src/Files.App/Helpers/Navigation/NavigationHelpers.cs index 21076cf1de37..d29dbcdf0b7a 100644 --- a/src/Files.App/Helpers/Navigation/NavigationHelpers.cs +++ b/src/Files.App/Helpers/Navigation/NavigationHelpers.cs @@ -277,14 +277,14 @@ public static Task LaunchNewWindowAsync() public static async Task OpenSelectedItemsAsync(IShellPage associatedInstance, bool openViaApplicationPicker = false) { // Don't open files and folders inside recycle bin - if (associatedInstance.FilesystemViewModel.WorkingDirectory.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal) || - associatedInstance.SlimContentPage?.SelectedItems is null) + if (associatedInstance.ShellViewModel.WorkingDirectory.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal) || + associatedInstance.LayoutPage?.SelectedItems is null) { return; } var forceOpenInNewTab = false; - var selectedItems = associatedInstance.SlimContentPage.SelectedItems.ToList(); + var selectedItems = associatedInstance.LayoutPage.SelectedItems.ToList(); var opened = false; // If multiple files are selected, open them together @@ -314,8 +314,8 @@ public static async Task OpenSelectedItemsAsync(IShellPage associatedInstance, b public static async Task OpenItemsWithExecutableAsync(IShellPage associatedInstance, IEnumerable items, string executablePath) { // Don't open files and folders inside recycle bin - if (associatedInstance.FilesystemViewModel.WorkingDirectory.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal) || - associatedInstance.SlimContentPage is null) + if (associatedInstance.ShellViewModel.WorkingDirectory.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal) || + associatedInstance.LayoutPage is null) return; var arguments = string.Join(" ", items.Select(item => $"\"{item.Path}\"")); @@ -334,7 +334,7 @@ public static async Task OpenItemsWithExecutableAsync(IShellPage associatedInsta /// Open folders in a new tab regardless of the "OpenFoldersInNewTab" option public static async Task OpenPath(string path, IShellPage associatedInstance, FilesystemItemType? itemType = null, bool openSilent = false, bool openViaApplicationPicker = false, IEnumerable? selectItems = null, string? args = default, bool forceOpenInNewTab = false) { - string previousDir = associatedInstance.FilesystemViewModel.WorkingDirectory; + string previousDir = associatedInstance.ShellViewModel.WorkingDirectory; bool isHiddenItem = Win32Helper.HasFileAttribute(path, System.IO.FileAttributes.Hidden); bool isDirectory = Win32Helper.HasFileAttribute(path, System.IO.FileAttributes.Directory); bool isReparsePoint = Win32Helper.HasFileAttribute(path, System.IO.FileAttributes.ReparsePoint); @@ -430,8 +430,8 @@ public static async Task OpenPath(string path, IShellPage associatedInstan if (opened.ErrorCode == FileSystemStatusCode.NotFound && !openSilent) { await DialogDisplayHelper.ShowDialogAsync("FileNotFoundDialog/Title".GetLocalizedResource(), "FileNotFoundDialog/Text".GetLocalizedResource()); - associatedInstance.ToolbarViewModel.CanRefresh = false; - associatedInstance.FilesystemViewModel?.RefreshItems(previousDir); + associatedInstance.AddressToolbarViewModel.CanRefresh = false; + associatedInstance.ShellViewModel?.RefreshItems(previousDir); } return opened; @@ -485,7 +485,7 @@ private static async Task OpenDirectory(string path, IShellPag } else { - opened = await associatedInstance.FilesystemViewModel.GetFolderWithPathFromPathAsync(path) + opened = await associatedInstance.ShellViewModel.GetFolderWithPathFromPathAsync(path) .OnSuccess((childFolder) => { // Add location to Recent Items List @@ -519,7 +519,7 @@ private static async Task OpenFile(string path, IShellPage ass { if (!FileExtensionHelpers.IsWebLinkFile(path)) { - StorageFileWithPath childFile = await associatedInstance.FilesystemViewModel.GetFileWithPathFromPathAsync(shortcutInfo.TargetPath); + StorageFileWithPath childFile = await associatedInstance.ShellViewModel.GetFileWithPathFromPathAsync(shortcutInfo.TargetPath); // Add location to Recent Items List if (childFile?.Item is SystemStorageFile) App.RecentItemsManager.AddToRecentItems(childFile.Path); @@ -534,7 +534,7 @@ private static async Task OpenFile(string path, IShellPage ass } else { - opened = await associatedInstance.FilesystemViewModel.GetFileWithPathFromPathAsync(path) + opened = await associatedInstance.ShellViewModel.GetFileWithPathFromPathAsync(path) .OnSuccess(async childFile => { // Add location to Recent Items List @@ -558,7 +558,7 @@ private static async Task OpenFile(string path, IShellPage ass BaseStorageFileQueryResult? fileQueryResult = null; //Get folder to create a file query (to pass to apps like Photos, Movies & TV..., needed to scroll through the folder like what Windows Explorer does) - BaseStorageFolder currentFolder = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(path)); + BaseStorageFolder currentFolder = await associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(path)); if (currentFolder is not null) { @@ -655,7 +655,7 @@ private static async Task OpenPathAsync(bool forceOpenInNewTab, bool openFolderI } else { - associatedInstance.ToolbarViewModel.PathControlDisplayText = text; + associatedInstance.AddressToolbarViewModel.PathControlDisplayText = text; associatedInstance.NavigateWithArguments(associatedInstance.InstanceViewModel.FolderSettings.GetLayoutType(path), new NavigationArguments() { NavPathParam = path, diff --git a/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs b/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs index e45b930f92ff..05a9abc02ae9 100644 --- a/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs +++ b/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs @@ -27,12 +27,12 @@ public static async Task CutItemAsync(IShellPage associatedInstance) }; ConcurrentBag items = []; - if (associatedInstance.SlimContentPage.IsItemSelected) + if (associatedInstance.LayoutPage.IsItemSelected) { // First, reset DataGrid Rows that may be in "cut" command mode - associatedInstance.SlimContentPage.ItemManipulationModel.RefreshItemsOpacity(); + associatedInstance.LayoutPage.ItemManipulationModel.RefreshItemsOpacity(); - var itemsCount = associatedInstance.SlimContentPage.SelectedItems!.Count; + var itemsCount = associatedInstance.LayoutPage.SelectedItems!.Count; var banner = itemsCount > 50 ? StatusCenterHelper.AddCard_Prepare() : null; @@ -46,7 +46,7 @@ public static async Task CutItemAsync(IShellPage associatedInstance) banner.Progress.ReportStatus(FileSystemStatusCode.InProgress); } - await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachAsync(async listedItem => + await associatedInstance.LayoutPage.SelectedItems.ToList().ParallelForEachAsync(async listedItem => { if (banner is not null) { @@ -70,7 +70,7 @@ await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachA } else if (listedItem.PrimaryItemAttribute == StorageItemTypes.File || listedItem is ZipItem) { - var result = await associatedInstance.FilesystemViewModel.GetFileFromPathAsync(listedItem.ItemPath) + var result = await associatedInstance.ShellViewModel.GetFileFromPathAsync(listedItem.ItemPath) .OnSuccess(t => items.Add(t)); if (!result) @@ -78,7 +78,7 @@ await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachA } else { - var result = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(listedItem.ItemPath) + var result = await associatedInstance.ShellViewModel.GetFolderFromPathAsync(listedItem.ItemPath) .OnSuccess(t => items.Add(t)); if (!result) @@ -90,7 +90,7 @@ await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachA { if (ex.HResult == (int)FileSystemStatusCode.Unauthorized) { - string[] filePaths = associatedInstance.SlimContentPage.SelectedItems.Select(x => x.ItemPath).ToArray(); + string[] filePaths = associatedInstance.LayoutPage.SelectedItems.Select(x => x.ItemPath).ToArray(); await FileOperationsHelpers.SetClipboard(filePaths, DataPackageOperation.Move); @@ -99,7 +99,7 @@ await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachA return; } - associatedInstance.SlimContentPage.ItemManipulationModel.RefreshItemsOpacity(); + associatedInstance.LayoutPage.ItemManipulationModel.RefreshItemsOpacity(); _statusCenterViewModel.RemoveItem(banner); @@ -136,11 +136,11 @@ public static async Task CopyItemAsync(IShellPage associatedInstance) }; ConcurrentBag items = []; - if (associatedInstance.SlimContentPage.IsItemSelected) + if (associatedInstance.LayoutPage.IsItemSelected) { - associatedInstance.SlimContentPage.ItemManipulationModel.RefreshItemsOpacity(); + associatedInstance.LayoutPage.ItemManipulationModel.RefreshItemsOpacity(); - var itemsCount = associatedInstance.SlimContentPage.SelectedItems!.Count; + var itemsCount = associatedInstance.LayoutPage.SelectedItems!.Count; var banner = itemsCount > 50 ? StatusCenterHelper.AddCard_Prepare() : null; @@ -152,7 +152,7 @@ public static async Task CopyItemAsync(IShellPage associatedInstance) banner.Progress.ItemsCount = items.Count; banner.Progress.ReportStatus(FileSystemStatusCode.InProgress); } - await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachAsync(async listedItem => + await associatedInstance.LayoutPage.SelectedItems.ToList().ParallelForEachAsync(async listedItem => { if (banner is not null) { @@ -167,7 +167,7 @@ await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachA } else if (listedItem.PrimaryItemAttribute == StorageItemTypes.File || listedItem is ZipItem) { - var result = await associatedInstance.FilesystemViewModel.GetFileFromPathAsync(listedItem.ItemPath) + var result = await associatedInstance.ShellViewModel.GetFileFromPathAsync(listedItem.ItemPath) .OnSuccess(t => items.Add(t)); if (!result) @@ -175,7 +175,7 @@ await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachA } else { - var result = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(listedItem.ItemPath) + var result = await associatedInstance.ShellViewModel.GetFolderFromPathAsync(listedItem.ItemPath) .OnSuccess(t => items.Add(t)); if (!result) @@ -187,7 +187,7 @@ await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachA { if (ex.HResult == (int)FileSystemStatusCode.Unauthorized) { - string[] filePaths = associatedInstance.SlimContentPage.SelectedItems.Select(x => x.ItemPath).ToArray(); + string[] filePaths = associatedInstance.LayoutPage.SelectedItems.Select(x => x.ItemPath).ToArray(); await FileOperationsHelpers.SetClipboard(filePaths, DataPackageOperation.Copy); @@ -230,7 +230,7 @@ public static async Task PasteItemAsync(string destinationPath, IShellPage assoc if (packageView && packageView.Result is not null) { await associatedInstance.FilesystemHelpers.PerformOperationTypeAsync(packageView.Result.RequestedOperation, packageView, destinationPath, false, true); - associatedInstance.SlimContentPage?.ItemManipulationModel?.RefreshItemsOpacity(); + associatedInstance.LayoutPage?.ItemManipulationModel?.RefreshItemsOpacity(); await associatedInstance.RefreshIfNoWatcherExistsAsync(); } } @@ -263,7 +263,7 @@ public static async Task RenameFileItemAsync(StandardStorageItem item, str if (renamed == ReturnResult.Success) { - associatedInstance.ToolbarViewModel.CanGoForward = false; + associatedInstance.AddressToolbarViewModel.CanGoForward = false; await associatedInstance.RefreshIfNoWatcherExistsAsync(); return true; } @@ -281,9 +281,9 @@ public static async Task CreateFileFromDialogResultTypeAsync(AddItemDialogItemTy { string? currentPath = null; - if (associatedInstance.SlimContentPage is not null) + if (associatedInstance.LayoutPage is not null) { - currentPath = associatedInstance.FilesystemViewModel.WorkingDirectory; + currentPath = associatedInstance.ShellViewModel.WorkingDirectory; if (App.LibraryManager.TryGetLibrary(currentPath, out var library) && !library.IsEmpty && library.Folders.Count == 1) // TODO: handle libraries with multiple folders @@ -343,7 +343,7 @@ public static async Task CreateFolderWithSelectionAsync(IShellPage associatedIns { try { - var items = associatedInstance.SlimContentPage.SelectedItems.ToList().Select((item) => StorageHelpers.FromPathAndType( + var items = associatedInstance.LayoutPage.SelectedItems.ToList().Select((item) => StorageHelpers.FromPathAndType( item.ItemPath, item.PrimaryItemAttribute == StorageItemTypes.File ? FilesystemItemType.File : FilesystemItemType.Directory)); var folder = await CreateFileFromDialogResultTypeForResult(AddItemDialogItemType.Folder, null, associatedInstance); @@ -373,7 +373,7 @@ public static void SetHiddenAttributeItem(StandardStorageItem item, bool isHidde public static async Task CreateShortcutAsync(IShellPage? associatedInstance, IReadOnlyList selectedItems) { - var currentPath = associatedInstance?.FilesystemViewModel.WorkingDirectory; + var currentPath = associatedInstance?.ShellViewModel.WorkingDirectory; if (App.LibraryManager.TryGetLibrary(currentPath ?? string.Empty, out var library) && !library.IsEmpty) currentPath = library.DefaultSaveFolder; @@ -393,7 +393,7 @@ public static async Task CreateShortcutAsync(IShellPage? associatedInstance, IRe public static async Task CreateShortcutFromDialogAsync(IShellPage associatedInstance) { - var currentPath = associatedInstance.FilesystemViewModel.WorkingDirectory; + var currentPath = associatedInstance.ShellViewModel.WorkingDirectory; if (App.LibraryManager.TryGetLibrary(currentPath, out var library) && !library.IsEmpty) { diff --git a/src/Files.App/Helpers/Win32/Win32Helper.Process.cs b/src/Files.App/Helpers/Win32/Win32Helper.Process.cs index 46d3dc99e50c..f4e0feb9f228 100644 --- a/src/Files.App/Helpers/Win32/Win32Helper.Process.cs +++ b/src/Files.App/Helpers/Win32/Win32Helper.Process.cs @@ -50,13 +50,13 @@ public static async Task InvokeWin32ComponentsAsync(IEnumerable ap if (string.IsNullOrEmpty(workingDirectory)) { - workingDirectory = associatedInstance.FilesystemViewModel.WorkingDirectory; + workingDirectory = associatedInstance.ShellViewModel.WorkingDirectory; } var application = applicationPaths.FirstOrDefault(); if (string.IsNullOrEmpty(workingDirectory)) { - workingDirectory = associatedInstance?.FilesystemViewModel?.WorkingDirectory; + workingDirectory = associatedInstance?.ShellViewModel?.WorkingDirectory; } if (runAsAdmin) diff --git a/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs b/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs index 3ac7c76db6bc..9fa96dbdf297 100644 --- a/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs +++ b/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs @@ -114,7 +114,7 @@ public static async Task RestoreRecycleBinAsync() public static async Task RestoreSelectionRecycleBinAsync(IShellPage associatedInstance) { - var items = associatedInstance.SlimContentPage.SelectedItems; + var items = associatedInstance.LayoutPage.SelectedItems; if (items == null) return; var ConfirmEmptyBinDialog = new ContentDialog() @@ -153,7 +153,7 @@ public static bool RecycleBinHasItems() public static async Task RestoreItemAsync(IShellPage associatedInstance) { - var selected = associatedInstance.SlimContentPage.SelectedItems; + var selected = associatedInstance.LayoutPage.SelectedItems; if (selected == null) return; var items = selected.ToList().Where(x => x is StandardRecycleBinItem).Select((item) => new @@ -168,7 +168,7 @@ public static async Task RestoreItemAsync(IShellPage associatedInstance) public static async Task DeleteItemAsync(IShellPage associatedInstance) { - var selected = associatedInstance.SlimContentPage.SelectedItems; + var selected = associatedInstance.LayoutPage.SelectedItems; if (selected == null) return; var items = selected.ToList().Select((item) => StorageHelpers.FromPathAndType( diff --git a/src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs b/src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs index b255a215616b..794aaa92b30a 100644 --- a/src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs +++ b/src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs @@ -50,7 +50,7 @@ public static void OpenPropertiesWindow(IShellPage associatedInstance) object item; - var page = associatedInstance.SlimContentPage; + var page = associatedInstance.LayoutPage; // Item(s) selected if (page is not null && page.IsItemSelected) @@ -64,7 +64,7 @@ public static void OpenPropertiesWindow(IShellPage associatedInstance) else { // Instance's current folder - var folder = associatedInstance.FilesystemViewModel?.CurrentFolder; + var folder = associatedInstance.ShellViewModel?.CurrentFolder; if (folder is null) return; diff --git a/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs b/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs index cddcfa616ea8..654221507cff 100644 --- a/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs +++ b/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs @@ -416,7 +416,7 @@ private static void SetCurrentWorkingDirectory(StringBuilder path, char separato var subPath = path.ToString().Substring(substringIndex); path.Clear(); - path.Append(context.ShellPage?.FilesystemViewModel.WorkingDirectory); + path.Append(context.ShellPage?.ShellViewModel.WorkingDirectory); path.Append(separator); path.Append(subPath); i = -1; diff --git a/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs b/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs index fc60fa8c05d8..93e604495b20 100644 --- a/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs +++ b/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs @@ -26,7 +26,7 @@ public sealed class FilesystemHelpers : IFilesystemHelpers private readonly IWindowsJumpListService jumpListService; private ShellFilesystemOperations filesystemOperations; - private ItemManipulationModel? itemManipulationModel => associatedInstance.SlimContentPage?.ItemManipulationModel; + private ItemManipulationModel? itemManipulationModel => associatedInstance.LayoutPage?.ItemManipulationModel; private readonly CancellationToken cancellationToken; private static char[] RestrictedCharacters diff --git a/src/Files.App/Utils/Storage/Operations/FilesystemOperations.cs b/src/Files.App/Utils/Storage/Operations/FilesystemOperations.cs index 4729b7810309..1d5f420e8372 100644 --- a/src/Files.App/Utils/Storage/Operations/FilesystemOperations.cs +++ b/src/Files.App/Utils/Storage/Operations/FilesystemOperations.cs @@ -39,7 +39,7 @@ public FilesystemOperations(IShellPage associatedInstance) var newEntryInfo = await ShellNewEntryExtensions.GetNewContextMenuEntryForType(Path.GetExtension(source.Path)); if (newEntryInfo is null) { - var fsFolderResult = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(source.Path)); + var fsFolderResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(source.Path)); fsResult = fsFolderResult; if (fsResult) { @@ -71,7 +71,7 @@ public FilesystemOperations(IShellPage associatedInstance) case FilesystemItemType.Directory: { - var fsFolderResult = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(source.Path)); + var fsFolderResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(source.Path)); fsResult = fsFolderResult; if (fsResult) { @@ -164,7 +164,7 @@ await DialogDisplayHelper.ShowDialogAsync( { // CopyFileFromApp only works on file not directories var fsSourceFolder = await source.ToStorageItemResult(); - var fsDestinationFolder = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); + var fsDestinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); var fsResult = (FilesystemResult)(fsSourceFolder.ErrorCode | fsDestinationFolder.ErrorCode); if (fsResult) @@ -217,7 +217,7 @@ await DialogDisplayHelper.ShowDialogAsync( { Debug.WriteLine(System.Runtime.InteropServices.Marshal.GetLastWin32Error()); - FilesystemResult destinationResult = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); + FilesystemResult destinationResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); var sourceResult = await source.ToStorageItemResult(); fsResult = sourceResult.ErrorCode | destinationResult.ErrorCode; @@ -371,7 +371,7 @@ await DialogDisplayHelper.ShowDialogAsync( Debug.WriteLine(System.Runtime.InteropServices.Marshal.GetLastWin32Error()); var fsSourceFolder = await source.ToStorageItemResult(); - var fsDestinationFolder = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); + var fsDestinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); fsResult = fsSourceFolder.ErrorCode | fsDestinationFolder.ErrorCode; if (fsResult) @@ -430,7 +430,7 @@ await DialogDisplayHelper.ShowDialogAsync( { Debug.WriteLine(System.Runtime.InteropServices.Marshal.GetLastWin32Error()); - FilesystemResult destinationResult = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); + FilesystemResult destinationResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); var sourceResult = await source.ToStorageItemResult(); fsResult = sourceResult.ErrorCode | destinationResult.ErrorCode; @@ -471,12 +471,12 @@ await DialogDisplayHelper.ShowDialogAsync( return null; } - bool sourceInCurrentFolder = PathNormalization.TrimPath(_associatedInstance.FilesystemViewModel.CurrentFolder.ItemPath) == + bool sourceInCurrentFolder = PathNormalization.TrimPath(_associatedInstance.ShellViewModel.CurrentFolder.ItemPath) == PathNormalization.GetParentDir(source.Path); if (fsProgress.Status == FileSystemStatusCode.Success && sourceInCurrentFolder) { - await _associatedInstance.FilesystemViewModel.RemoveFileOrFolderAsync(source.Path); - await _associatedInstance.FilesystemViewModel.ApplyFilesAndFoldersChangesAsync(); + await _associatedInstance.ShellViewModel.RemoveFileOrFolderAsync(source.Path); + await _associatedInstance.ShellViewModel.ApplyFilesAndFoldersChangesAsync(); } var pathWithType = movedItem.FromStorageItem(destination, source.ItemType); @@ -510,12 +510,12 @@ public async Task DeleteAsync(IStorageItemWithPath source, IPro { if (source.ItemType == FilesystemItemType.File) { - fsResult = await _associatedInstance.FilesystemViewModel.GetFileFromPathAsync(source.Path) + fsResult = await _associatedInstance.ShellViewModel.GetFileFromPathAsync(source.Path) .OnSuccess((t) => t.DeleteAsync(permanently ? StorageDeleteOption.PermanentDelete : StorageDeleteOption.Default).AsTask()); } else if (source.ItemType == FilesystemItemType.Directory) { - fsResult = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(source.Path) + fsResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(source.Path) .OnSuccess((t) => t.DeleteAsync(permanently ? StorageDeleteOption.PermanentDelete : StorageDeleteOption.Default).AsTask()); } } @@ -537,14 +537,14 @@ public async Task DeleteAsync(IStorageItemWithPath source, IPro // Recycle bin also stores a file starting with $I for each item string iFilePath = Path.Combine(Path.GetDirectoryName(source.Path), Path.GetFileName(source.Path).Replace("$R", "$I", StringComparison.Ordinal)); - await _associatedInstance.FilesystemViewModel.GetFileFromPathAsync(iFilePath) + await _associatedInstance.ShellViewModel.GetFileFromPathAsync(iFilePath) .OnSuccess(iFile => iFile.DeleteAsync(StorageDeleteOption.PermanentDelete).AsTask()); } fsProgress.ReportStatus(fsResult); if (fsResult) { - await _associatedInstance.FilesystemViewModel.RemoveFileOrFolderAsync(source.Path); + await _associatedInstance.ShellViewModel.RemoveFileOrFolderAsync(source.Path); if (!permanently) { @@ -736,8 +736,8 @@ public async Task RestoreFromTrashAsync(IStorageItemWithPath so { if (source.ItemType == FilesystemItemType.Directory) { - FilesystemResult sourceFolder = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(source.Path); - FilesystemResult destinationFolder = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); + FilesystemResult sourceFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(source.Path); + FilesystemResult destinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); fsResult = sourceFolder.ErrorCode | destinationFolder.ErrorCode; fsProgress.ReportStatus(fsResult); @@ -757,8 +757,8 @@ public async Task RestoreFromTrashAsync(IStorageItemWithPath so } else { - FilesystemResult sourceFile = await _associatedInstance.FilesystemViewModel.GetFileFromPathAsync(source.Path); - FilesystemResult destinationFolder = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); + FilesystemResult sourceFile = await _associatedInstance.ShellViewModel.GetFileFromPathAsync(source.Path); + FilesystemResult destinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); fsResult = sourceFile.ErrorCode | destinationFolder.ErrorCode; fsProgress.ReportStatus(fsResult); @@ -780,7 +780,7 @@ public async Task RestoreFromTrashAsync(IStorageItemWithPath so // Recycle bin also stores a file starting with $I for each item string iFilePath = Path.Combine(Path.GetDirectoryName(source.Path), Path.GetFileName(source.Path).Replace("$R", "$I", StringComparison.Ordinal)); - await _associatedInstance.FilesystemViewModel.GetFileFromPathAsync(iFilePath) + await _associatedInstance.ShellViewModel.GetFileFromPathAsync(iFilePath) .OnSuccess(iFile => iFile.DeleteAsync(StorageDeleteOption.PermanentDelete).AsTask()); } diff --git a/src/Files.App/Utils/Storage/Operations/ShellFilesystemOperations.cs b/src/Files.App/Utils/Storage/Operations/ShellFilesystemOperations.cs index aab8616c71eb..bcab988dc692 100644 --- a/src/Files.App/Utils/Storage/Operations/ShellFilesystemOperations.cs +++ b/src/Files.App/Utils/Storage/Operations/ShellFilesystemOperations.cs @@ -385,7 +385,7 @@ public async Task DeleteItemsAsync(IList foreach (var item in deleteResult.Items) { - await _associatedInstance.FilesystemViewModel.RemoveFileOrFolderAsync(item.Source); + await _associatedInstance.ShellViewModel.RemoveFileOrFolderAsync(item.Source); } var recycledSources = deleteResult.Items.Where(x => x.Succeeded && x.Destination is not null && x.Source != x.Destination); diff --git a/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs b/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs index edc913be4891..550fcdbc1394 100644 --- a/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs +++ b/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs @@ -57,8 +57,8 @@ private async Task ItemPointerPressedAsync(PointerRoutedEventArgs e) e.OriginalSource is FrameworkElement { DataContext: StandardStorageItem Item } && Item.PrimaryItemAttribute == StorageItemTypes.Folder) { - _associatedInstance.SlimContentPage.IsMiddleClickToScrollEnabled = false; - _associatedInstance.SlimContentPage.IsMiddleClickToScrollEnabled = true; + _associatedInstance.LayoutPage.IsMiddleClickToScrollEnabled = false; + _associatedInstance.LayoutPage.IsMiddleClickToScrollEnabled = true; if (Item.IsShortcut) await NavigationHelpers.OpenPathInNewTab(((e.OriginalSource as FrameworkElement)?.DataContext as ShortcutItem)?.TargetPath ?? Item.ItemPath, false); @@ -105,11 +105,11 @@ public async Task DragOverAsync(DragEventArgs e) var draggedItems = await FilesystemHelpers.GetDraggedStorageItems(e.DataView); - var pwd = _associatedInstance.FilesystemViewModel.WorkingDirectory.TrimPath(); + var pwd = _associatedInstance.ShellViewModel.WorkingDirectory.TrimPath(); var folderName = Path.IsPathRooted(pwd) && Path.GetPathRoot(pwd) == pwd ? Path.GetPathRoot(pwd) : Path.GetFileName(pwd); // As long as one file doesn't already belong to this folder - if (_associatedInstance.InstanceViewModel.IsPageTypeSearchResults || draggedItems.Any() && draggedItems.AreItemsAlreadyInFolder(_associatedInstance.FilesystemViewModel.WorkingDirectory)) + if (_associatedInstance.InstanceViewModel.IsPageTypeSearchResults || draggedItems.Any() && draggedItems.AreItemsAlreadyInFolder(_associatedInstance.ShellViewModel.WorkingDirectory)) { e.AcceptedOperation = DataPackageOperation.None; } @@ -150,7 +150,7 @@ x.Item is ZipStorageFile || e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), folderName); e.AcceptedOperation = DataPackageOperation.Copy; } - else if (draggedItems.AreItemsInSameDrive(_associatedInstance.FilesystemViewModel.WorkingDirectory)) + else if (draggedItems.AreItemsInSameDrive(_associatedInstance.ShellViewModel.WorkingDirectory)) { e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), folderName); // Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well. @@ -177,7 +177,7 @@ public async Task DropAsync(DragEventArgs e) try { - await _associatedInstance.FilesystemHelpers.PerformOperationTypeAsync(e.AcceptedOperation, e.DataView, _associatedInstance.FilesystemViewModel.WorkingDirectory, false, true); + await _associatedInstance.FilesystemHelpers.PerformOperationTypeAsync(e.AcceptedOperation, e.DataView, _associatedInstance.ShellViewModel.WorkingDirectory, false, true); await _associatedInstance.RefreshIfNoWatcherExistsAsync(); } finally diff --git a/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs b/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs index e0c7fb1c8e9a..f86f9665b84d 100644 --- a/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs +++ b/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs @@ -121,7 +121,7 @@ public async Task UpdateIcon() await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => { - _appInstance?.FilesystemViewModel?.RefreshItems(null); + _appInstance?.ShellViewModel?.RefreshItems(null); }); return true; diff --git a/src/Files.App/ViewModels/Properties/Items/FileProperties.cs b/src/Files.App/ViewModels/Properties/Items/FileProperties.cs index 1f200fadfb1b..aa57316bc550 100644 --- a/src/Files.App/ViewModels/Properties/Items/FileProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/FileProperties.cs @@ -131,7 +131,7 @@ public override async Task GetSpecialPropertiesAsync() } string filePath = (Item as ShortcutItem)?.TargetPath ?? Item.ItemPath; - BaseStorageFile file = await AppInstance.FilesystemViewModel.GetFileFromPathAsync(filePath); + BaseStorageFile file = await AppInstance.ShellViewModel.GetFileFromPathAsync(filePath); // Couldn't access the file and can't load any other properties if (file is null) diff --git a/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs b/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs index 388410a4d3fd..904be0883dda 100644 --- a/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs @@ -107,7 +107,7 @@ public async override Task GetSpecialPropertiesAsync() } string folderPath = (Item as ShortcutItem)?.TargetPath ?? Item.ItemPath; - BaseStorageFolder storageFolder = await AppInstance.FilesystemViewModel.GetFolderFromPathAsync(folderPath); + BaseStorageFolder storageFolder = await AppInstance.ShellViewModel.GetFolderFromPathAsync(folderPath); if (storageFolder is not null) { diff --git a/src/Files.App/ViewModels/Properties/Items/LibraryProperties.cs b/src/Files.App/ViewModels/Properties/Items/LibraryProperties.cs index 0ae2cb2e26de..ad087f23c621 100644 --- a/src/Files.App/ViewModels/Properties/Items/LibraryProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/LibraryProperties.cs @@ -62,7 +62,7 @@ public async override Task GetSpecialPropertiesAsync() ViewModel.LoadFileIcon = true; } - BaseStorageFile libraryFile = await AppInstance.FilesystemViewModel.GetFileFromPathAsync(Library.ItemPath); + BaseStorageFile libraryFile = await AppInstance.ShellViewModel.GetFileFromPathAsync(Library.ItemPath); if (libraryFile is not null) { ViewModel.ItemCreatedTimestampReal = libraryFile.DateCreated; @@ -79,7 +79,7 @@ public async override Task GetSpecialPropertiesAsync() { foreach (var path in Library.Folders) { - BaseStorageFolder folder = await AppInstance.FilesystemViewModel.GetFolderFromPathAsync(path); + BaseStorageFolder folder = await AppInstance.ShellViewModel.GetFolderFromPathAsync(path); if (!string.IsNullOrEmpty(folder.Path)) { storageFolders.Add(folder); diff --git a/src/Files.App/Data/Models/ItemViewModel.cs b/src/Files.App/ViewModels/ShellViewModel.cs similarity index 99% rename from src/Files.App/Data/Models/ItemViewModel.cs rename to src/Files.App/ViewModels/ShellViewModel.cs index ff6c31394413..a5164a82ff67 100644 --- a/src/Files.App/Data/Models/ItemViewModel.cs +++ b/src/Files.App/ViewModels/ShellViewModel.cs @@ -23,9 +23,9 @@ using DispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue; using FileAttributes = System.IO.FileAttributes; -namespace Files.App.Data.Models +namespace Files.App.ViewModels { - public sealed class ItemViewModel : ObservableObject, IDisposable + public sealed class ShellViewModel : ObservableObject, IDisposable { private readonly SemaphoreSlim enumFolderSemaphore; private readonly SemaphoreSlim getFileOrFolderSemaphore; @@ -470,7 +470,7 @@ public bool AreFilesSortedFirst public bool HasNoWatcher { get; private set; } - public ItemViewModel(LayoutPreferencesManager folderSettingsViewModel) + public ShellViewModel(LayoutPreferencesManager folderSettingsViewModel) { folderSettings = folderSettingsViewModel; filesAndFolders = []; diff --git a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs index a652d8b893cc..a25adc33c686 100644 --- a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs @@ -587,7 +587,7 @@ private void CloseSearchBox(bool doFocus = false) { SearchBox.Query = string.Empty; - var page = Ioc.Default.GetRequiredService().ShellPage?.SlimContentPage; + var page = Ioc.Default.GetRequiredService().ShellPage?.LayoutPage; if (page is BaseGroupableLayoutPage svb && svb.IsLoaded) page.ItemManipulationModel.FocusFileList(); @@ -630,7 +630,7 @@ public async Task SetPathBoxDropDownFlyoutAsync(MenuFlyout flyout, PathBoxItem p var nextPathItemTitle = PathComponents[PathComponents.IndexOf(pathItem) + 1].Title; IList? childFolders = null; - StorageFolderWithPath folder = await shellPage.FilesystemViewModel.GetFolderWithPathFromPathAsync(pathItem.Path); + StorageFolderWithPath folder = await shellPage.ShellViewModel.GetFolderWithPathFromPathAsync(pathItem.Path); if (folder is not null) childFolders = (await FilesystemTasks.Wrap(() => folder.GetFoldersWithPathAsync(string.Empty))).Result; @@ -725,7 +725,7 @@ await DialogDisplayHelper.ShowDialogAsync("CommandNotExecutable".GetLocalizedRes if (currentSelectedPath == normalizedInput || string.IsNullOrWhiteSpace(normalizedInput)) return; - if (normalizedInput != shellPage.FilesystemViewModel.WorkingDirectory || shellPage.CurrentPageType == typeof(HomePage)) + if (normalizedInput != shellPage.ShellViewModel.WorkingDirectory || shellPage.CurrentPageType == typeof(HomePage)) { if (normalizedInput.Equals("Home", StringComparison.OrdinalIgnoreCase) || normalizedInput.Equals("Home".GetLocalizedResource(), StringComparison.OrdinalIgnoreCase)) { @@ -774,10 +774,10 @@ await DialogDisplayHelper.ShowDialogAsync("CommandNotExecutable".GetLocalizedRes else // Not a file or not accessible { var workingDir = - string.IsNullOrEmpty(shellPage.FilesystemViewModel.WorkingDirectory) || + string.IsNullOrEmpty(shellPage.ShellViewModel.WorkingDirectory) || shellPage.CurrentPageType == typeof(HomePage) ? Constants.UserEnvironmentPaths.HomePath : - shellPage.FilesystemViewModel.WorkingDirectory; + shellPage.ShellViewModel.WorkingDirectory; if (await LaunchApplicationFromPath(currentInput, workingDir)) return; @@ -797,7 +797,7 @@ await DialogDisplayHelper.ShowDialogAsync("InvalidItemDialogTitle".GetLocalizedR } } - PathControlDisplayText = shellPage.FilesystemViewModel.WorkingDirectory; + PathControlDisplayText = shellPage.ShellViewModel.WorkingDirectory; } } @@ -823,7 +823,7 @@ private static async Task LaunchApplicationFromPath(string currentInput, s public async Task SetAddressBarSuggestionsAsync(AutoSuggestBox sender, IShellPage shellpage) { - if (sender.Text is not null && shellpage.FilesystemViewModel is not null) + if (sender.Text is not null && shellpage.ShellViewModel is not null) { if (!await SafetyExtensions.IgnoreExceptions(async () => { @@ -870,7 +870,7 @@ public async Task SetAddressBarSuggestionsAsync(AutoSuggestBox sender, IShellPag currentInput = NormalizePathInput(currentInput, isFtp); var expandedPath = StorageFileExtensions.GetResolvedPath(currentInput, isFtp); var folderPath = PathNormalization.GetParentDir(expandedPath) ?? expandedPath; - StorageFolderWithPath folder = await shellpage.FilesystemViewModel.GetFolderWithPathFromPathAsync(folderPath); + StorageFolderWithPath folder = await shellpage.ShellViewModel.GetFolderWithPathFromPathAsync(folderPath); if (folder is null) return false; @@ -904,7 +904,7 @@ public async Task SetAddressBarSuggestionsAsync(AutoSuggestBox sender, IShellPag if (suggestions is null || suggestions.Count == 0) { suggestions = new List() { new NavigationBarSuggestionItem() { - Text = shellpage.FilesystemViewModel.WorkingDirectory, + Text = shellpage.ShellViewModel.WorkingDirectory, PrimaryDisplay = "NavigationToolbarVisiblePathNoResults".GetLocalizedResource() } }; } @@ -956,7 +956,7 @@ public async Task SetAddressBarSuggestionsAsync(AutoSuggestBox sender, IShellPag NavigationBarSuggestions.Clear(); NavigationBarSuggestions.Add(new NavigationBarSuggestionItem() { - Text = shellpage.FilesystemViewModel.WorkingDirectory, + Text = shellpage.ShellViewModel.WorkingDirectory, PrimaryDisplay = "NavigationToolbarVisiblePathNoResults".GetLocalizedResource() }); }); diff --git a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs index 3ae452ee053c..085467f7637b 100644 --- a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs @@ -906,10 +906,10 @@ private void OpenProperties(CommandBarFlyout menu) if (!string.Equals(locationItem.Path, Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.OrdinalIgnoreCase)) { - BaseStorageFolder matchingStorageFolder = await PaneHolder.ActivePane.FilesystemViewModel.GetFolderFromPathAsync(locationItem.Path); + BaseStorageFolder matchingStorageFolder = await PaneHolder.ActivePane.ShellViewModel.GetFolderFromPathAsync(locationItem.Path); if (matchingStorageFolder is not null) { - var syncStatus = await PaneHolder.ActivePane.FilesystemViewModel.CheckCloudDriveSyncStatusAsync(matchingStorageFolder); + var syncStatus = await PaneHolder.ActivePane.ShellViewModel.CheckCloudDriveSyncStatusAsync(matchingStorageFolder); listedItem.SyncStatusUI = CloudDriveSyncStatusUI.FromCloudDriveSyncStatus(syncStatus); } } diff --git a/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs b/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs index ffa459202e75..a40b73666fa2 100644 --- a/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs @@ -282,10 +282,10 @@ private void ExecuteOpenPropertiesCommand(WidgetFolderCardItem? item) if (!string.Equals(item.Item.Path, Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.OrdinalIgnoreCase)) { - BaseStorageFolder matchingStorageFolder = await ContentPageContext.ShellPage!.FilesystemViewModel.GetFolderFromPathAsync(item.Item.Path); + BaseStorageFolder matchingStorageFolder = await ContentPageContext.ShellPage!.ShellViewModel.GetFolderFromPathAsync(item.Item.Path); if (matchingStorageFolder is not null) { - var syncStatus = await ContentPageContext.ShellPage!.FilesystemViewModel.CheckCloudDriveSyncStatusAsync(matchingStorageFolder); + var syncStatus = await ContentPageContext.ShellPage!.ShellViewModel.CheckCloudDriveSyncStatusAsync(matchingStorageFolder); listedItem.SyncStatusUI = CloudDriveSyncStatusUI.FromCloudDriveSyncStatus(syncStatus); } } diff --git a/src/Files.App/Views/HomePage.xaml.cs b/src/Files.App/Views/HomePage.xaml.cs index 1e29c086924f..38bd4547064d 100644 --- a/src/Files.App/Views/HomePage.xaml.cs +++ b/src/Files.App/Views/HomePage.xaml.cs @@ -42,20 +42,20 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) AppInstance.InstanceViewModel.IsPageTypeLibrary = false; AppInstance.InstanceViewModel.GitRepositoryPath = null; AppInstance.InstanceViewModel.IsGitRepository = false; - AppInstance.ToolbarViewModel.CanRefresh = true; - AppInstance.ToolbarViewModel.CanGoBack = AppInstance.CanNavigateBackward; - AppInstance.ToolbarViewModel.CanGoForward = AppInstance.CanNavigateForward; - AppInstance.ToolbarViewModel.CanNavigateToParent = false; + AppInstance.AddressToolbarViewModel.CanRefresh = true; + AppInstance.AddressToolbarViewModel.CanGoBack = AppInstance.CanNavigateBackward; + AppInstance.AddressToolbarViewModel.CanGoForward = AppInstance.CanNavigateForward; + AppInstance.AddressToolbarViewModel.CanNavigateToParent = false; - AppInstance.ToolbarViewModel.RefreshRequested -= ToolbarViewModel_RefreshRequested; - AppInstance.ToolbarViewModel.RefreshRequested += ToolbarViewModel_RefreshRequested; + AppInstance.AddressToolbarViewModel.RefreshRequested -= ToolbarViewModel_RefreshRequested; + AppInstance.AddressToolbarViewModel.RefreshRequested += ToolbarViewModel_RefreshRequested; // Set path of working directory empty - await AppInstance.FilesystemViewModel.SetWorkingDirectoryAsync("Home"); + await AppInstance.ShellViewModel.SetWorkingDirectoryAsync("Home"); - AppInstance.SlimContentPage?.StatusBarViewModel.UpdateGitInfo(false, string.Empty, null); + AppInstance.LayoutPage?.StatusBarViewModel.UpdateGitInfo(false, string.Empty, null); - AppInstance.ToolbarViewModel.PathComponents.Clear(); + AppInstance.AddressToolbarViewModel.PathComponents.Clear(); string componentLabel = parameters?.NavPathParam == "Home" @@ -71,7 +71,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) Path = tag, }; - AppInstance.ToolbarViewModel.PathComponents.Add(item); + AppInstance.AddressToolbarViewModel.PathComponents.Add(item); base.OnNavigatedTo(e); } @@ -83,18 +83,18 @@ protected override void OnNavigatedFrom(NavigationEventArgs e) private async void ToolbarViewModel_RefreshRequested(object? sender, EventArgs e) { - AppInstance.ToolbarViewModel.CanRefresh = false; + AppInstance.AddressToolbarViewModel.CanRefresh = false; await Task.WhenAll(ViewModel.WidgetItems.Select(w => w.WidgetItemModel.RefreshWidgetAsync())); - AppInstance.ToolbarViewModel.CanRefresh = true; + AppInstance.AddressToolbarViewModel.CanRefresh = true; } // Disposer public void Dispose() { - AppInstance.ToolbarViewModel.RefreshRequested -= ToolbarViewModel_RefreshRequested; + AppInstance.AddressToolbarViewModel.RefreshRequested -= ToolbarViewModel_RefreshRequested; ViewModel?.Dispose(); } } diff --git a/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs b/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs index 5453ca9ed82e..4253317fa8fb 100644 --- a/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs +++ b/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs @@ -128,40 +128,40 @@ protected virtual async void ItemManipulationModel_RefreshItemThumbnail(object? protected virtual async Task ReloadSelectedItemIconAsync() { - if (ParentShellPageInstance?.SlimContentPage?.SelectedItem is null) + if (ParentShellPageInstance?.LayoutPage?.SelectedItem is null) return; - ParentShellPageInstance.FilesystemViewModel.CancelExtendedPropertiesLoading(); - ParentShellPageInstance.SlimContentPage.SelectedItem.ItemPropertiesInitialized = false; + ParentShellPageInstance.ShellViewModel.CancelExtendedPropertiesLoading(); + ParentShellPageInstance.LayoutPage.SelectedItem.ItemPropertiesInitialized = false; - await ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemPropertiesAsync(ParentShellPageInstance.SlimContentPage.SelectedItem); + await ParentShellPageInstance.ShellViewModel.LoadExtendedItemPropertiesAsync(ParentShellPageInstance.LayoutPage.SelectedItem); - if (ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties is not GitProperties.None && - ParentShellPageInstance.SlimContentPage.SelectedItem is GitItem gitItem) + if (ParentShellPageInstance.ShellViewModel.EnabledGitProperties is not GitProperties.None && + ParentShellPageInstance.LayoutPage.SelectedItem is GitItem gitItem) { - await ParentShellPageInstance.FilesystemViewModel.LoadGitPropertiesAsync(gitItem); + await ParentShellPageInstance.ShellViewModel.LoadGitPropertiesAsync(gitItem); } } protected virtual async Task ReloadSelectedItemsIconAsync() { - if (ParentShellPageInstance?.SlimContentPage?.SelectedItems is null) + if (ParentShellPageInstance?.LayoutPage?.SelectedItems is null) return; - ParentShellPageInstance.FilesystemViewModel.CancelExtendedPropertiesLoading(); + ParentShellPageInstance.ShellViewModel.CancelExtendedPropertiesLoading(); - foreach (var selectedItem in ParentShellPageInstance.SlimContentPage.SelectedItems) + foreach (var selectedItem in ParentShellPageInstance.LayoutPage.SelectedItems) { selectedItem.ItemPropertiesInitialized = false; - await ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemPropertiesAsync(selectedItem); + await ParentShellPageInstance.ShellViewModel.LoadExtendedItemPropertiesAsync(selectedItem); } - if (ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties is not GitProperties.None) + if (ParentShellPageInstance.ShellViewModel.EnabledGitProperties is not GitProperties.None) { - await Task.WhenAll(ParentShellPageInstance.SlimContentPage.SelectedItems.Select(item => + await Task.WhenAll(ParentShellPageInstance.LayoutPage.SelectedItems.Select(item => { if (item is GitItem gitItem) - return ParentShellPageInstance.FilesystemViewModel.LoadGitPropertiesAsync(gitItem); + return ParentShellPageInstance.ShellViewModel.LoadGitPropertiesAsync(gitItem); return Task.CompletedTask; })); diff --git a/src/Files.App/Views/Layouts/BaseLayoutPage.cs b/src/Files.App/Views/Layouts/BaseLayoutPage.cs index 362a0a946150..a92c8acd7790 100644 --- a/src/Files.App/Views/Layouts/BaseLayoutPage.cs +++ b/src/Files.App/Views/Layouts/BaseLayoutPage.cs @@ -186,7 +186,7 @@ public string JumpString if (previouslySelectedItem is not null) { // Use FilesAndFolders because only displayed entries should be jumped to - IEnumerable candidateItems = ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders.ToList() + IEnumerable candidateItems = ParentShellPageInstance!.ShellViewModel.FilesAndFolders.ToList() .SkipWhile(x => x != previouslySelectedItem) .Skip(value.Length == 1 ? 1 : 0) // User is trying to cycle through items starting with the same letter .Where(f => f.Name.Length >= value.Length && string.Equals(f.Name.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase)); @@ -196,7 +196,7 @@ public string JumpString if (jumpedToItem is null) { // Use FilesAndFolders because only displayed entries should be jumped to - IEnumerable candidateItems = ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders.ToList() + IEnumerable candidateItems = ParentShellPageInstance!.ShellViewModel.FilesAndFolders.ToList() .Where(f => f.Name.Length >= value.Length && string.Equals(f.Name.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase)); jumpedToItem = candidateItems.FirstOrDefault(); } @@ -262,7 +262,7 @@ internal set NotifyPropertyChanged(nameof(SelectedItems)); } - ParentShellPageInstance!.ToolbarViewModel.SelectedItems = value; + ParentShellPageInstance!.AddressToolbarViewModel.SelectedItems = value; } } @@ -346,9 +346,9 @@ public virtual void ResetItemOpacity() protected virtual void BaseFolderSettings_LayoutModeChangeRequested(object? sender, LayoutModeEventArgs e) { - if (ParentShellPageInstance?.SlimContentPage is not null) + if (ParentShellPageInstance?.LayoutPage is not null) { - var layoutType = FolderSettings!.GetLayoutType(ParentShellPageInstance.FilesystemViewModel.WorkingDirectory); + var layoutType = FolderSettings!.GetLayoutType(ParentShellPageInstance.ShellViewModel.WorkingDirectory); if (layoutType != ParentShellPageInstance.CurrentPageType) { @@ -367,7 +367,7 @@ protected virtual void BaseFolderSettings_LayoutModeChangeRequested(object? send ParentShellPageInstance.ResetNavigationStackLayoutMode(); } - ParentShellPageInstance.FilesystemViewModel.UpdateEmptyTextType(); + ParentShellPageInstance.ShellViewModel.UpdateEmptyTextType(); } } @@ -387,7 +387,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) ParentShellPageInstance = navigationArguments.AssociatedTabInstance; // Git properties are not loaded by default - ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties = GitProperties.None; + ParentShellPageInstance.ShellViewModel.EnabledGitProperties = GitProperties.None; InitializeCommandsViewModel(); @@ -398,30 +398,30 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) FolderSettings.GroupDirectionPreferenceUpdated += FolderSettings_GroupDirectionPreferenceUpdated; FolderSettings.GroupByDateUnitPreferenceUpdated += FolderSettings_GroupByDateUnitPreferenceUpdated; - ParentShellPageInstance.FilesystemViewModel.EmptyTextType = EmptyTextType.None; - ParentShellPageInstance.ToolbarViewModel.CanRefresh = true; + ParentShellPageInstance.ShellViewModel.EmptyTextType = EmptyTextType.None; + ParentShellPageInstance.AddressToolbarViewModel.CanRefresh = true; if (!navigationArguments.IsSearchResultPage) { - var previousDir = ParentShellPageInstance.FilesystemViewModel.WorkingDirectory; - await ParentShellPageInstance.FilesystemViewModel.SetWorkingDirectoryAsync(navigationArguments.NavPathParam); + var previousDir = ParentShellPageInstance.ShellViewModel.WorkingDirectory; + await ParentShellPageInstance.ShellViewModel.SetWorkingDirectoryAsync(navigationArguments.NavPathParam); // pathRoot will be empty on recycle bin path - var workingDir = ParentShellPageInstance.FilesystemViewModel.WorkingDirectory ?? string.Empty; + var workingDir = ParentShellPageInstance.ShellViewModel.WorkingDirectory ?? string.Empty; var pathRoot = GetPathRoot(workingDir); var isRecycleBin = workingDir.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal); ParentShellPageInstance.InstanceViewModel.IsPageTypeRecycleBin = isRecycleBin; // Can't go up from recycle bin - ParentShellPageInstance.ToolbarViewModel.CanNavigateToParent = !(string.IsNullOrEmpty(pathRoot) || isRecycleBin); + ParentShellPageInstance.AddressToolbarViewModel.CanNavigateToParent = !(string.IsNullOrEmpty(pathRoot) || isRecycleBin); ParentShellPageInstance.InstanceViewModel.IsPageTypeMtpDevice = workingDir.StartsWith("\\\\?\\", StringComparison.Ordinal); ParentShellPageInstance.InstanceViewModel.IsPageTypeFtp = FtpHelpers.IsFtpPath(workingDir); ParentShellPageInstance.InstanceViewModel.IsPageTypeZipFolder = ZipStorageFolder.IsZipPath(workingDir); ParentShellPageInstance.InstanceViewModel.IsPageTypeLibrary = LibraryManager.IsLibraryPath(workingDir); ParentShellPageInstance.InstanceViewModel.IsPageTypeSearchResults = false; - ParentShellPageInstance.ToolbarViewModel.PathControlDisplayText = navigationArguments.NavPathParam; + ParentShellPageInstance.AddressToolbarViewModel.PathControlDisplayText = navigationArguments.NavPathParam; if (ParentShellPageInstance.InstanceViewModel.FolderSettings.DirectorySortOption == SortOption.Path) ParentShellPageInstance.InstanceViewModel.FolderSettings.DirectorySortOption = SortOption.Name; @@ -431,22 +431,22 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) ParentShellPageInstance.InstanceViewModel.FolderSettings.DirectoryGroupOption = GroupOption.None; if (!navigationArguments.IsLayoutSwitch || previousDir != workingDir) - ParentShellPageInstance.FilesystemViewModel.RefreshItems(previousDir, SetSelectedItemsOnNavigation); + ParentShellPageInstance.ShellViewModel.RefreshItems(previousDir, SetSelectedItemsOnNavigation); else - ParentShellPageInstance.ToolbarViewModel.CanGoForward = false; + ParentShellPageInstance.AddressToolbarViewModel.CanGoForward = false; } else { - await ParentShellPageInstance.FilesystemViewModel.SetWorkingDirectoryAsync(navigationArguments.SearchPathParam); + await ParentShellPageInstance.ShellViewModel.SetWorkingDirectoryAsync(navigationArguments.SearchPathParam); - ParentShellPageInstance.ToolbarViewModel.CanGoForward = false; + ParentShellPageInstance.AddressToolbarViewModel.CanGoForward = false; // Impose no artificial restrictions on back navigation. Even in a search results page. - ParentShellPageInstance.ToolbarViewModel.CanGoBack = true; + ParentShellPageInstance.AddressToolbarViewModel.CanGoBack = true; - ParentShellPageInstance.ToolbarViewModel.CanNavigateToParent = false; + ParentShellPageInstance.AddressToolbarViewModel.CanNavigateToParent = false; - var workingDir = ParentShellPageInstance.FilesystemViewModel.WorkingDirectory ?? string.Empty; + var workingDir = ParentShellPageInstance.ShellViewModel.WorkingDirectory ?? string.Empty; ParentShellPageInstance.InstanceViewModel.IsPageTypeRecycleBin = workingDir.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal); ParentShellPageInstance.InstanceViewModel.IsPageTypeMtpDevice = workingDir.StartsWith("\\\\?\\", StringComparison.Ordinal); @@ -466,13 +466,13 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) ThumbnailSize = InstanceViewModel!.FolderSettings.GetRoundedIconSize(), }; - _ = ParentShellPageInstance.FilesystemViewModel.SearchAsync(searchInstance); + _ = ParentShellPageInstance.ShellViewModel.SearchAsync(searchInstance); } } // Show controls that were hidden on the home page ParentShellPageInstance.InstanceViewModel.IsPageTypeNotHome = true; - ParentShellPageInstance.FilesystemViewModel.UpdateGroupOptions(); + ParentShellPageInstance.ShellViewModel.UpdateGroupOptions(); UpdateCollectionViewSource(); FolderSettings.IsLayoutModeChanging = false; @@ -493,7 +493,7 @@ navigationArguments.SelectItems is not null && { List listedItemsToSelect = [ - .. ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders.ToList().Where((li) => navigationArguments.SelectItems.Contains(li.ItemNameRaw)), + .. ParentShellPageInstance!.ShellViewModel.FilesAndFolders.ToList().Where((li) => navigationArguments.SelectItems.Contains(li.ItemNameRaw)), ]; ItemManipulationModel.SetSelectedItems(listedItemsToSelect); @@ -530,11 +530,11 @@ private async Task GroupPreferenceUpdatedAsync() groupingCancellationToken = new CancellationTokenSource(); var token = groupingCancellationToken.Token; - await ParentShellPageInstance!.FilesystemViewModel.GroupOptionsUpdatedAsync(token); + await ParentShellPageInstance!.ShellViewModel.GroupOptionsUpdatedAsync(token); UpdateCollectionViewSource(); - await ParentShellPageInstance.FilesystemViewModel.ReloadItemGroupHeaderImagesAsync(); + await ParentShellPageInstance.ShellViewModel.ReloadItemGroupHeaderImagesAsync(); } protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) @@ -552,7 +552,7 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) var parameter = e.Parameter as NavigationArguments; if (parameter is not null && !parameter.IsLayoutSwitch) - ParentShellPageInstance!.FilesystemViewModel.CancelLoadAndClearFiles(); + ParentShellPageInstance!.ShellViewModel.CancelLoadAndClearFiles(); } private async void ItemContextFlyout_Opening(object? sender, object e) @@ -600,7 +600,7 @@ private async void ItemContextFlyout_Opening(object? sender, object e) if (!InstanceViewModel.IsPageTypeZipFolder && !InstanceViewModel.IsPageTypeFtp) { - var shellMenuItems = await ContentPageContextFlyoutFactory.GetItemContextShellCommandsAsync(workingDir: ParentShellPageInstance.FilesystemViewModel.WorkingDirectory, selectedItems: SelectedItems!, shiftPressed: shiftPressed, showOpenMenu: false, shellContextMenuItemCancellationToken.Token); + var shellMenuItems = await ContentPageContextFlyoutFactory.GetItemContextShellCommandsAsync(workingDir: ParentShellPageInstance.ShellViewModel.WorkingDirectory, selectedItems: SelectedItems!, shiftPressed: shiftPressed, showOpenMenu: false, shellContextMenuItemCancellationToken.Token); if (shellMenuItems.Any()) await AddShellMenuItemsAsync(shellMenuItems, ItemContextMenuFlyout, shiftPressed); else @@ -642,7 +642,7 @@ private async void BaseContextFlyout_Opening(object? sender, object e) shellContextMenuItemCancellationToken = new CancellationTokenSource(); shiftPressed = Microsoft.UI.Input.InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Shift).HasFlag(Windows.UI.Core.CoreVirtualKeyStates.Down); - var items = ContentPageContextFlyoutFactory.GetItemContextCommandsWithoutShellItems(currentInstanceViewModel: InstanceViewModel!, selectedItems: [ParentShellPageInstance!.FilesystemViewModel.CurrentFolder], commandsViewModel: CommandsViewModel!, shiftPressed: shiftPressed, itemViewModel: ParentShellPageInstance!.FilesystemViewModel, selectedItemsPropertiesViewModel: null); + var items = ContentPageContextFlyoutFactory.GetItemContextCommandsWithoutShellItems(currentInstanceViewModel: InstanceViewModel!, selectedItems: [ParentShellPageInstance!.ShellViewModel.CurrentFolder], commandsViewModel: CommandsViewModel!, shiftPressed: shiftPressed, itemViewModel: ParentShellPageInstance!.ShellViewModel, selectedItemsPropertiesViewModel: null); BaseContextMenuFlyout.PrimaryCommands.Clear(); BaseContextMenuFlyout.SecondaryCommands.Clear(); @@ -659,7 +659,7 @@ private async void BaseContextFlyout_Opening(object? sender, object e) if (!InstanceViewModel!.IsPageTypeSearchResults && !InstanceViewModel.IsPageTypeZipFolder && !InstanceViewModel.IsPageTypeFtp) { - var shellMenuItems = await ContentPageContextFlyoutFactory.GetItemContextShellCommandsAsync(workingDir: ParentShellPageInstance.FilesystemViewModel.WorkingDirectory, selectedItems: [], shiftPressed: shiftPressed, showOpenMenu: false, shellContextMenuItemCancellationToken.Token); + var shellMenuItems = await ContentPageContextFlyoutFactory.GetItemContextShellCommandsAsync(workingDir: ParentShellPageInstance.ShellViewModel.WorkingDirectory, selectedItems: [], shiftPressed: shiftPressed, showOpenMenu: false, shellContextMenuItemCancellationToken.Token); if (shellMenuItems.Any()) await AddShellMenuItemsAsync(shellMenuItems, BaseContextMenuFlyout, shiftPressed); else @@ -1157,7 +1157,7 @@ private void RefreshItem(SelectorItem container, object item, bool inRecycleQueu if (inRecycleQueue) { - ParentShellPageInstance!.FilesystemViewModel.CancelExtendedPropertiesLoadingForItem(listedItem); + ParentShellPageInstance!.ShellViewModel.CancelExtendedPropertiesLoadingForItem(listedItem); } else { @@ -1168,9 +1168,9 @@ private void RefreshItem(SelectorItem container, object item, bool inRecycleQueu uint callbackPhase = 3; args.RegisterUpdateCallback(callbackPhase, async (s, c) => { - await ParentShellPageInstance!.FilesystemViewModel.LoadExtendedItemPropertiesAsync(listedItem); - if (ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties is not GitProperties.None && listedItem is GitItem gitItem) - await ParentShellPageInstance.FilesystemViewModel.LoadGitPropertiesAsync(gitItem); + await ParentShellPageInstance!.ShellViewModel.LoadExtendedItemPropertiesAsync(listedItem); + if (ParentShellPageInstance.ShellViewModel.EnabledGitProperties is not GitProperties.None && listedItem is GitItem gitItem) + await ParentShellPageInstance.ShellViewModel.LoadGitPropertiesAsync(gitItem); }); } } @@ -1303,12 +1303,12 @@ private void UpdateCollectionViewSource() if (ParentShellPageInstance is null) return; - if (ParentShellPageInstance.FilesystemViewModel.FilesAndFolders.IsGrouped) + if (ParentShellPageInstance.ShellViewModel.FilesAndFolders.IsGrouped) { var newSource = new CollectionViewSource() { IsSourceGrouped = true, - Source = ParentShellPageInstance.FilesystemViewModel.FilesAndFolders.GroupedCollection + Source = ParentShellPageInstance.ShellViewModel.FilesAndFolders.GroupedCollection }; CollectionViewSource = newSource; } @@ -1317,7 +1317,7 @@ private void UpdateCollectionViewSource() var newSource = new CollectionViewSource() { IsSourceGrouped = false, - Source = ParentShellPageInstance.FilesystemViewModel.FilesAndFolders + Source = ParentShellPageInstance.ShellViewModel.FilesAndFolders }; CollectionViewSource = newSource; } @@ -1373,7 +1373,7 @@ private void ItemManipulationModel_RefreshItemsOpacityInvoked(object? sender, Ev private void View_VectorChanged(IObservableVector sender, IVectorChangedEventArgs @event) { if (ParentShellPageInstance is not null) - ParentShellPageInstance.ToolbarViewModel.HasItem = CollectionViewSource.View.Any(); + ParentShellPageInstance.AddressToolbarViewModel.HasItem = CollectionViewSource.View.Any(); } virtual public void StartRenameItem() diff --git a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs index 6020a6785600..74d577ffc202 100644 --- a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs @@ -307,7 +307,7 @@ protected override void FileList_SelectionChanged(object sender, SelectionChange else if (SelectedItems?.Count > 1 || SelectedItem?.PrimaryItemAttribute is StorageItemTypes.File || openedFolderPresenter != null && ParentShellPageInstance != null - && !ParentShellPageInstance.FilesystemViewModel.FilesAndFolders.ToList().Contains(FileList.ItemFromContainer(openedFolderPresenter)) + && !ParentShellPageInstance.ShellViewModel.FilesAndFolders.ToList().Contains(FileList.ItemFromContainer(openedFolderPresenter)) && !isDraggingSelectionRectangle) // Skip closing if dragging since nothing should be open { CloseFolder(); @@ -363,7 +363,7 @@ ParentShellPageInstance is null || } else if (e.Key == VirtualKey.Space) { - if (!ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) + if (!ParentShellPageInstance.AddressToolbarViewModel.IsEditModeEnabled) e.Handled = true; } else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up)) @@ -389,7 +389,7 @@ ParentShellPageInstance is null || } else if (e.Key == VirtualKey.Left) // Left arrow: select parent folder (previous column) { - if (ParentShellPageInstance is not null && ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) + if (ParentShellPageInstance is not null && ParentShellPageInstance.AddressToolbarViewModel.IsEditModeEnabled) return; var currentBladeIndex = (ParentShellPageInstance is ColumnShellPage associatedColumnShellPage) ? associatedColumnShellPage.ColumnParams.Column : 0; @@ -400,7 +400,7 @@ ParentShellPageInstance is null || } else if (e.Key == VirtualKey.Right) // Right arrow: switch focus to next column { - if (ParentShellPageInstance is not null && ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) + if (ParentShellPageInstance is not null && ParentShellPageInstance.AddressToolbarViewModel.IsEditModeEnabled) return; var currentBladeIndex = (ParentShellPageInstance is ColumnShellPage associatedColumnShellPage) ? associatedColumnShellPage.ColumnParams.Column : 0; diff --git a/src/Files.App/Views/Layouts/ColumnsLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/ColumnsLayoutPage.xaml.cs index 2ec35c81c91c..9d5c9d902c67 100644 --- a/src/Files.App/Views/Layouts/ColumnsLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/ColumnsLayoutPage.xaml.cs @@ -63,7 +63,7 @@ private void ColumnViewBase_ItemInvoked(object? sender, EventArgs e) var nextBladeIndex = ColumnHost.ActiveBlades.IndexOf(column.ListView.FindAscendant()) + 1; var nextBlade = ColumnHost.ActiveBlades.ToList().ElementAtOrDefault(nextBladeIndex); - var arePathsDifferent = ((nextBlade?.Content as Frame)?.Content as IShellPage)?.FilesystemViewModel?.WorkingDirectory != column.NavPathParam; + var arePathsDifferent = ((nextBlade?.Content as Frame)?.Content as IShellPage)?.ShellViewModel?.WorkingDirectory != column.NavPathParam; if (nextBlade is null || arePathsDifferent) { @@ -158,7 +158,7 @@ public override void Dispose() if (frame?.Content is ColumnShellPage shPage) { shPage.ContentChanged -= ColumnViewBrowser_ContentChanged; - if (shPage.SlimContentPage is ColumnLayoutPage viewBase) + if (shPage.LayoutPage is ColumnLayoutPage viewBase) { viewBase.ItemInvoked -= ColumnViewBase_ItemInvoked; viewBase.ItemTapped -= ColumnViewBase_ItemTapped; @@ -200,7 +200,7 @@ public void DismissOtherBlades(int index) if (frame?.Content is IDisposable disposableContent) disposableContent.Dispose(); - if ((frame?.Content as ColumnShellPage)?.SlimContentPage is ColumnLayoutPage columnLayout) + if ((frame?.Content as ColumnShellPage)?.LayoutPage is ColumnLayoutPage columnLayout) { columnLayout.ItemInvoked -= ColumnViewBase_ItemInvoked; columnLayout.ItemTapped -= ColumnViewBase_ItemTapped; @@ -216,8 +216,8 @@ public void DismissOtherBlades(int index) if ((ColumnHost.ActiveBlades[index].Content as Frame)?.Content is ColumnShellPage s) { - navigationArguments.NavPathParam = s.FilesystemViewModel.WorkingDirectory; - ParentShellPageInstance.TabBarItemParameter.NavigationParameter = s.FilesystemViewModel.WorkingDirectory; + navigationArguments.NavPathParam = s.ShellViewModel.WorkingDirectory; + ParentShellPageInstance.TabBarItemParameter.NavigationParameter = s.ShellViewModel.WorkingDirectory; } }); } @@ -256,7 +256,7 @@ private void ColumnViewBrowser_GotFocus(object sender, RoutedEventArgs e) private void ColumnViewBrowser_ContentChanged(object sender, TabBarItemParameter e) { var c = sender as IShellPage; - var columnView = c?.SlimContentPage as ColumnLayoutPage; + var columnView = c?.LayoutPage as ColumnLayoutPage; if (columnView is not null) { columnView.ItemInvoked -= ColumnViewBase_ItemInvoked; @@ -273,7 +273,7 @@ private void ColumnViewBrowser_ContentChanged(object sender, TabBarItemParameter private void ColumnViewBase_KeyUp(object sender, Microsoft.UI.Xaml.Input.KeyRoutedEventArgs e) { var shPage = ActiveColumnShellPage as ColumnShellPage; - if (shPage?.SlimContentPage?.SelectedItem?.PrimaryItemAttribute is not StorageItemTypes.Folder) + if (shPage?.LayoutPage?.SelectedItem?.PrimaryItemAttribute is not StorageItemTypes.Folder) CloseUnnecessaryColumns(shPage?.ColumnParams); } @@ -293,7 +293,7 @@ public void NavigateUp() DismissOtherBlades(ColumnHost.ActiveBlades[ColumnHost.ActiveBlades.Count - 2]); else { - var workingDirectory = ((ColumnHost.ActiveBlades?.ToList().FirstOrDefault()?.Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel.WorkingDirectory; + var workingDirectory = ((ColumnHost.ActiveBlades?.ToList().FirstOrDefault()?.Content as Frame)?.Content as ColumnShellPage)?.ShellViewModel.WorkingDirectory; if (workingDirectory is null || string.Equals(workingDirectory, GetPathRoot(workingDirectory), StringComparison.OrdinalIgnoreCase)) ParentShellPageInstance?.NavigateHome(); else @@ -344,7 +344,7 @@ public void MoveFocusToNextBlade(int currentBladeIndex) activeBladeFrame.Content is not ColumnShellPage activeBladePage) return null; - return activeBladePage.SlimContentPage as ColumnLayoutPage; + return activeBladePage.LayoutPage as ColumnLayoutPage; } public void SetSelectedPathOrNavigate(string navigationPath, Type sourcePageType, NavigationArguments navArgs = null) @@ -356,8 +356,8 @@ public void SetSelectedPathOrNavigate(string navigationPath, Type sourcePageType } var destPath = navArgs is not null ? navArgs.NavPathParam : navigationPath; - var columnPath = ((ColumnHost.ActiveBlades.ToList().LastOrDefault()?.Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel.WorkingDirectory; - var columnFirstPath = ((ColumnHost.ActiveBlades.ToList().FirstOrDefault()?.Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel.WorkingDirectory; + var columnPath = ((ColumnHost.ActiveBlades.ToList().LastOrDefault()?.Content as Frame)?.Content as ColumnShellPage)?.ShellViewModel.WorkingDirectory; + var columnFirstPath = ((ColumnHost.ActiveBlades.ToList().FirstOrDefault()?.Content as Frame)?.Content as ColumnShellPage)?.ShellViewModel.WorkingDirectory; if (string.IsNullOrEmpty(destPath) || string.IsNullOrEmpty(columnPath) || string.IsNullOrEmpty(columnFirstPath)) { @@ -404,7 +404,7 @@ public void SetSelectedPathOrNavigate(PathNavigationEventArgs e) foreach (var item in ColumnHost.ActiveBlades.ToList()) { if ((item.Content as Frame)?.Content is ColumnShellPage s && - NormalizePath(s.FilesystemViewModel?.WorkingDirectory) == NormalizePath(e.ItemPath)) + NormalizePath(s.ShellViewModel?.WorkingDirectory) == NormalizePath(e.ItemPath)) { DismissOtherBlades(item); return; @@ -415,7 +415,7 @@ public void SetSelectedPathOrNavigate(PathNavigationEventArgs e) if (ParentShellPageInstance is null) return; - if (NormalizePath(ParentShellPageInstance.FilesystemViewModel?.WorkingDirectory) != NormalizePath(e.ItemPath)) + if (NormalizePath(ParentShellPageInstance.ShellViewModel?.WorkingDirectory) != NormalizePath(e.ItemPath)) ParentShellPageInstance.NavigateToPath(e.ItemPath); else DismissOtherBlades(0); @@ -466,7 +466,7 @@ private void CloseUnnecessaryColumns(ColumnParam column) { // Get the index of the blade with the same path as the requested var blade = ColumnHost.ActiveBlades.ToList().FirstOrDefault(b => - column.NavPathParam.Equals(((b.Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel?.WorkingDirectory)); + column.NavPathParam.Equals(((b.Content as Frame)?.Content as ColumnShellPage)?.ShellViewModel?.WorkingDirectory)); if (blade is not null) relativeIndex = ColumnHost.ActiveBlades.IndexOf(blade); diff --git a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs index b5a7da48beb1..15491f85199e 100644 --- a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs @@ -156,13 +156,13 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs) ColumnsViewModel.GitLastCommitShaColumn = FolderSettings.ColumnsViewModel.GitLastCommitShaColumn; } - ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties = GetEnabledGitProperties(ColumnsViewModel); + ParentShellPageInstance.ShellViewModel.EnabledGitProperties = GetEnabledGitProperties(ColumnsViewModel); FolderSettings.LayoutModeChangeRequested += FolderSettings_LayoutModeChangeRequested; FolderSettings.GroupOptionPreferenceUpdated += ZoomIn; FolderSettings.SortDirectionPreferenceUpdated += FolderSettings_SortDirectionPreferenceUpdated; FolderSettings.SortOptionPreferenceUpdated += FolderSettings_SortOptionPreferenceUpdated; - ParentShellPageInstance.FilesystemViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated; + ParentShellPageInstance.ShellViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated; UserSettingsService.LayoutSettingsService.PropertyChanged += LayoutSettingsService_PropertyChanged; var parameters = (NavigationArguments)eventArgs.Parameter; @@ -189,7 +189,7 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) FolderSettings.GroupOptionPreferenceUpdated -= ZoomIn; FolderSettings.SortDirectionPreferenceUpdated -= FolderSettings_SortDirectionPreferenceUpdated; FolderSettings.SortOptionPreferenceUpdated -= FolderSettings_SortOptionPreferenceUpdated; - ParentShellPageInstance.FilesystemViewModel.PageTypeUpdated -= FilesystemViewModel_PageTypeUpdated; + ParentShellPageInstance.ShellViewModel.PageTypeUpdated -= FilesystemViewModel_PageTypeUpdated; UserSettingsService.LayoutSettingsService.PropertyChanged -= LayoutSettingsService_PropertyChanged; } @@ -410,7 +410,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv if (ctrlPressed && !shiftPressed) { - var folders = ParentShellPageInstance?.SlimContentPage.SelectedItems?.Where(file => file.PrimaryItemAttribute == StorageItemTypes.Folder); + var folders = ParentShellPageInstance?.LayoutPage.SelectedItems?.Where(file => file.PrimaryItemAttribute == StorageItemTypes.Folder); if (folders is not null) { foreach (StandardStorageItem folder in folders) @@ -431,7 +431,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv } else if (e.Key == VirtualKey.Space) { - if (!ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) + if (!ParentShellPageInstance.AddressToolbarViewModel.IsEditModeEnabled) e.Handled = true; } else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up)) @@ -446,7 +446,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv } else if (e.Key == VirtualKey.Down) { - if (isHeaderFocused && !ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) + if (isHeaderFocused && !ParentShellPageInstance.AddressToolbarViewModel.IsEditModeEnabled) { var selectIndex = FileList.SelectedIndex < 0 ? 0 : FileList.SelectedIndex; if (FileList.ContainerFromIndex(selectIndex) is ListViewItem item) @@ -469,24 +469,24 @@ private async Task ReloadItemIconsAsync() if (ParentShellPageInstance is null) return; - ParentShellPageInstance.FilesystemViewModel.CancelExtendedPropertiesLoading(); - var filesAndFolders = ParentShellPageInstance.FilesystemViewModel.FilesAndFolders.ToList(); + ParentShellPageInstance.ShellViewModel.CancelExtendedPropertiesLoading(); + var filesAndFolders = ParentShellPageInstance.ShellViewModel.FilesAndFolders.ToList(); await Task.WhenAll(filesAndFolders.Select(listedItem => { listedItem.ItemPropertiesInitialized = false; if (FileList.ContainerFromItem(listedItem) is not null) - return ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemPropertiesAsync(listedItem); + return ParentShellPageInstance.ShellViewModel.LoadExtendedItemPropertiesAsync(listedItem); else return Task.CompletedTask; })); - if (ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties is not GitProperties.None) + if (ParentShellPageInstance.ShellViewModel.EnabledGitProperties is not GitProperties.None) { await Task.WhenAll(filesAndFolders.Select(item => { if (item is GitItem gitItem) - return ParentShellPageInstance.FilesystemViewModel.LoadGitPropertiesAsync(gitItem); + return ParentShellPageInstance.ShellViewModel.LoadGitPropertiesAsync(gitItem); return Task.CompletedTask; })); @@ -644,7 +644,7 @@ private void GridSplitter_Loaded(object sender, RoutedEventArgs e) private void ToggleMenuFlyoutItem_Click(object sender, RoutedEventArgs e) { FolderSettings.ColumnsViewModel = ColumnsViewModel; - ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties = GetEnabledGitProperties(ColumnsViewModel); + ParentShellPageInstance.ShellViewModel.EnabledGitProperties = GetEnabledGitProperties(ColumnsViewModel); } private void GridSplitter_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs index e2a704a81535..936dc34b4b4b 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs @@ -138,7 +138,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs) // Set ItemTemplate SetItemTemplate(); SetItemContainerStyle(); - FileList.ItemsSource ??= ParentShellPageInstance.FilesystemViewModel.FilesAndFolders; + FileList.ItemsSource ??= ParentShellPageInstance.ShellViewModel.FilesAndFolders; var parameters = (NavigationArguments)eventArgs.Parameter; if (parameters.IsLayoutSwitch) @@ -443,7 +443,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv if (ctrlPressed && !shiftPressed) { - var folders = ParentShellPageInstance?.SlimContentPage.SelectedItems?.Where(file => file.PrimaryItemAttribute == StorageItemTypes.Folder); + var folders = ParentShellPageInstance?.LayoutPage.SelectedItems?.Where(file => file.PrimaryItemAttribute == StorageItemTypes.Folder); foreach (StandardStorageItem? folder in folders) { if (folder is not null) @@ -462,7 +462,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv } else if (e.Key == VirtualKey.Space) { - if (!ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) + if (!ParentShellPageInstance.AddressToolbarViewModel.IsEditModeEnabled) e.Handled = true; } else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up)) @@ -508,21 +508,21 @@ private async Task ReloadItemIconsAsync() if (ParentShellPageInstance is null) return; - ParentShellPageInstance.FilesystemViewModel.CancelExtendedPropertiesLoading(); - var filesAndFolders = ParentShellPageInstance.FilesystemViewModel.FilesAndFolders.ToList(); + ParentShellPageInstance.ShellViewModel.CancelExtendedPropertiesLoading(); + var filesAndFolders = ParentShellPageInstance.ShellViewModel.FilesAndFolders.ToList(); foreach (StandardStorageItem listedItem in filesAndFolders) { listedItem.ItemPropertiesInitialized = false; if (FileList.ContainerFromItem(listedItem) is not null) - await ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemPropertiesAsync(listedItem); + await ParentShellPageInstance.ShellViewModel.LoadExtendedItemPropertiesAsync(listedItem); } - if (ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties is not GitProperties.None) + if (ParentShellPageInstance.ShellViewModel.EnabledGitProperties is not GitProperties.None) { await Task.WhenAll(filesAndFolders.Select(item => { if (item is GitItem gitItem) - return ParentShellPageInstance.FilesystemViewModel.LoadGitPropertiesAsync(gitItem); + return ParentShellPageInstance.ShellViewModel.LoadGitPropertiesAsync(gitItem); return Task.CompletedTask; })); @@ -699,7 +699,7 @@ private void SelectionCheckbox_PointerCanceled(object sender, PointerRoutedEvent // To avoid crashes, disable scrolling when drag-and-drop if grouped. (#14484) private bool ShouldDisableScrollingWhenDragAndDrop => FolderSettings?.LayoutMode is FolderLayoutModes.GridView or FolderLayoutModes.TilesView && - (ParentShellPageInstance?.FilesystemViewModel.FilesAndFolders.IsGrouped ?? false); + (ParentShellPageInstance?.ShellViewModel.FilesAndFolders.IsGrouped ?? false); protected override void FileList_DragItemsStarting(object sender, DragItemsStartingEventArgs e) { diff --git a/src/Files.App/Views/MainPage.xaml.cs b/src/Files.App/Views/MainPage.xaml.cs index e6dc0621e687..2828f2f26b06 100644 --- a/src/Files.App/Views/MainPage.xaml.cs +++ b/src/Files.App/Views/MainPage.xaml.cs @@ -185,8 +185,8 @@ public async void MultitaskingControl_CurrentInstanceChanged(object? sender, Cur } SidebarAdaptiveViewModel.NotifyInstanceRelatedPropertiesChanged((navArgs as PaneNavigationArguments)?.LeftPaneNavPathParam); - if (SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.SlimContentPage?.StatusBarViewModel is not null) - SidebarAdaptiveViewModel.PaneHolder.ActivePaneOrColumn.SlimContentPage.StatusBarViewModel.ShowLocals = true; + if (SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.LayoutPage?.StatusBarViewModel is not null) + SidebarAdaptiveViewModel.PaneHolder.ActivePaneOrColumn.LayoutPage.StatusBarViewModel.ShowLocals = true; UpdateStatusBarProperties(); UpdateNavToolbarProperties(); @@ -210,18 +210,18 @@ private void UpdateStatusBarProperties() { if (StatusBar is not null) { - StatusBar.StatusBarViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.SlimContentPage?.StatusBarViewModel; - StatusBar.SelectedItemsPropertiesViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.SlimContentPage?.SelectedItemsPropertiesViewModel; + StatusBar.StatusBarViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.LayoutPage?.StatusBarViewModel; + StatusBar.SelectedItemsPropertiesViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.LayoutPage?.SelectedItemsPropertiesViewModel; } } private void UpdateNavToolbarProperties() { if (NavToolbar is not null) - NavToolbar.ViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.ToolbarViewModel; + NavToolbar.ViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.AddressToolbarViewModel; if (InnerNavigationToolbar is not null) - InnerNavigationToolbar.ViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.ToolbarViewModel; + InnerNavigationToolbar.ViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.AddressToolbarViewModel; } protected override void OnNavigatedTo(NavigationEventArgs e) diff --git a/src/Files.App/Views/Properties/GeneralPage.xaml.cs b/src/Files.App/Views/Properties/GeneralPage.xaml.cs index 3f4cd3037aa2..680a31f1a9b2 100644 --- a/src/Files.App/Views/Properties/GeneralPage.xaml.cs +++ b/src/Files.App/Views/Properties/GeneralPage.xaml.cs @@ -80,7 +80,7 @@ bool GetNewName(out string newName) bool SaveDrive(DriveItem drive) { - var fsVM = AppInstance.FilesystemViewModel; + var fsVM = AppInstance.ShellViewModel; if (!GetNewName(out var newName) || fsVM is null) return false; @@ -101,7 +101,7 @@ bool SaveDrive(DriveItem drive) async Task SaveLibraryAsync(LibraryItem library) { - var fsVM = AppInstance.FilesystemViewModel; + var fsVM = AppInstance.ShellViewModel; if (!GetNewName(out var newName) || fsVM is null || !App.LibraryManager.CanCreateLibrary(newName).result) return false; @@ -125,7 +125,7 @@ async Task SaveLibraryAsync(LibraryItem library) async Task SaveCombinedAsync(IList fileOrFolders) { // Handle the visibility attribute for multiple files - var itemMM = AppInstance?.SlimContentPage?.ItemManipulationModel; + var itemMM = AppInstance?.LayoutPage?.ItemManipulationModel; if (itemMM is not null) // null on homepage { foreach (var fileOrFolder in fileOrFolders) @@ -147,7 +147,7 @@ await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => { - AppInstance?.FilesystemViewModel?.RefreshItems(null); + AppInstance?.ShellViewModel?.RefreshItems(null); }); } } @@ -158,7 +158,7 @@ await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => async Task SaveBaseAsync(StandardStorageItem item) { // Handle the visibility attribute for a single file - var itemMM = AppInstance?.SlimContentPage?.ItemManipulationModel; + var itemMM = AppInstance?.LayoutPage?.ItemManipulationModel; if (itemMM is not null && ViewModel.IsHiddenEditedValue is not null) // null on homepage { await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => @@ -175,7 +175,7 @@ await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => { - AppInstance?.FilesystemViewModel?.RefreshItems(null); + AppInstance?.ShellViewModel?.RefreshItems(null); }); } diff --git a/src/Files.App/Views/ShellPanesPage.xaml.cs b/src/Files.App/Views/ShellPanesPage.xaml.cs index 124d1994ff59..1275a5470e20 100644 --- a/src/Files.App/Views/ShellPanesPage.xaml.cs +++ b/src/Files.App/Views/ShellPanesPage.xaml.cs @@ -54,7 +54,7 @@ public IShellPage ActivePaneOrColumn get { // Active shell is column view - if (ActivePane is not null && ActivePane.IsColumnView && ActivePane.SlimContentPage is ColumnsLayoutPage columnLayoutPage) + if (ActivePane is not null && ActivePane.IsColumnView && ActivePane.LayoutPage is ColumnsLayoutPage columnLayoutPage) return columnLayoutPage.ActiveColumnShellPage; return ActivePane ?? GetPane(0)!; @@ -470,18 +470,18 @@ private void Pane_GotFocus(object sender, RoutedEventArgs e) var isLeftPane = sender == (GetPane(0) as IShellPage); // Clear selection in left pane - if (isLeftPane && GetPane(1) is ModernShellPage secondShellPage && (secondShellPage.SlimContentPage?.IsItemSelected ?? false)) + if (isLeftPane && GetPane(1) is ModernShellPage secondShellPage && (secondShellPage.LayoutPage?.IsItemSelected ?? false)) { - secondShellPage.SlimContentPage.LockPreviewPaneContent = true; - secondShellPage.SlimContentPage.ItemManipulationModel.ClearSelection(); - secondShellPage.SlimContentPage.LockPreviewPaneContent = false; + secondShellPage.LayoutPage.LockPreviewPaneContent = true; + secondShellPage.LayoutPage.ItemManipulationModel.ClearSelection(); + secondShellPage.LayoutPage.LockPreviewPaneContent = false; } // Clear selection in right pane - else if (!isLeftPane && GetPane(0) is ModernShellPage firstShellPage && (firstShellPage.SlimContentPage?.IsItemSelected ?? false)) + else if (!isLeftPane && GetPane(0) is ModernShellPage firstShellPage && (firstShellPage.LayoutPage?.IsItemSelected ?? false)) { - firstShellPage.SlimContentPage.LockPreviewPaneContent = true; - firstShellPage.SlimContentPage.ItemManipulationModel.ClearSelection(); - firstShellPage.SlimContentPage.LockPreviewPaneContent = false; + firstShellPage.LayoutPage.LockPreviewPaneContent = true; + firstShellPage.LayoutPage.ItemManipulationModel.ClearSelection(); + firstShellPage.LayoutPage.LockPreviewPaneContent = false; } var newActivePane = isLeftPane ? GetPane(0) : GetPane(1); @@ -491,7 +491,7 @@ private void Pane_GotFocus(object sender, RoutedEventArgs e) private void Pane_RightTapped(object sender, RoutedEventArgs e) { - if (sender != ActivePane && sender is IShellPage shellPage && shellPage.SlimContentPage is not ColumnsLayoutPage) + if (sender != ActivePane && sender is IShellPage shellPage && shellPage.LayoutPage is not ColumnsLayoutPage) ((UIElement)sender).Focus(FocusState.Programmatic); } diff --git a/src/Files.App/Views/Shells/BaseShellPage.cs b/src/Files.App/Views/Shells/BaseShellPage.cs index 67d7aeb6b3f4..e9283834f2dd 100644 --- a/src/Files.App/Views/Shells/BaseShellPage.cs +++ b/src/Files.App/Views/Shells/BaseShellPage.cs @@ -18,13 +18,24 @@ namespace Files.App.Views.Shells { public abstract class BaseShellPage : Page, IShellPage, INotifyPropertyChanged { + // Dependency injections + + protected DrivesViewModel drivesViewModel { get; } = Ioc.Default.GetRequiredService(); + protected IDialogService dialogService { get; } = Ioc.Default.GetRequiredService(); + protected IUserSettingsService userSettingsService { get; } = Ioc.Default.GetRequiredService(); + protected IUpdateService updateSettingsService { get; } = Ioc.Default.GetRequiredService(); + protected ICommandManager commands { get; } = Ioc.Default.GetRequiredService(); + public AddressToolbarViewModel AddressToolbarViewModel { get; } = new AddressToolbarViewModel(); + private readonly DispatcherQueueTimer _updateDateDisplayTimer; private DateTimeFormats _lastDateTimeFormats; private Task _gitFetch = Task.CompletedTask; - private CancellationTokenSource _gitFetchToken = new CancellationTokenSource(); + private CancellationTokenSource _gitFetchToken = new(); + + protected readonly CancellationTokenSource cancellationTokenSource; public static readonly DependencyProperty NavParamsProperty = DependencyProperty.Register( @@ -35,21 +46,7 @@ public abstract class BaseShellPage : Page, IShellPage, INotifyPropertyChanged public StorageHistoryHelpers StorageHistoryHelpers { get; } - protected readonly CancellationTokenSource cancellationTokenSource; - - protected readonly DrivesViewModel drivesViewModel = Ioc.Default.GetRequiredService(); - - protected readonly IDialogService dialogService = Ioc.Default.GetRequiredService(); - - protected readonly IUserSettingsService userSettingsService = Ioc.Default.GetRequiredService(); - - protected readonly IUpdateService updateSettingsService = Ioc.Default.GetRequiredService(); - - protected readonly ICommandManager commands = Ioc.Default.GetRequiredService(); - - public AddressToolbarViewModel ToolbarViewModel { get; } = new AddressToolbarViewModel(); - - public IBaseLayoutPage SlimContentPage => ContentPage; + public IBaseLayoutPage LayoutPage => ContentPage; public IFilesystemHelpers FilesystemHelpers { get; protected set; } @@ -57,17 +54,15 @@ public abstract class BaseShellPage : Page, IShellPage, INotifyPropertyChanged public LayoutPreferencesManager FolderSettings => InstanceViewModel.FolderSettings; - public AppModel AppModel => App.AppModel; - protected abstract Frame ItemDisplay { get; } public abstract bool CanNavigateForward { get; } public abstract bool CanNavigateBackward { get; } - public bool IsColumnView => SlimContentPage is ColumnsLayoutPage; + public bool IsColumnView => LayoutPage is ColumnsLayoutPage; - public ItemViewModel FilesystemViewModel { get; protected set; } + public ShellViewModel ShellViewModel { get; protected set; } public CurrentInstanceViewModel InstanceViewModel { get; } @@ -85,7 +80,7 @@ public BaseLayoutPage ContentPage _ContentPage = value; NotifyPropertyChanged(nameof(ContentPage)); - NotifyPropertyChanged(nameof(SlimContentPage)); + NotifyPropertyChanged(nameof(LayoutPage)); if (value is not null) _ContentPage.StatusBarViewModel.CheckoutRequested += GitCheckout_Required; } @@ -123,6 +118,7 @@ public TabBarItemParameter TabBarItemParameter } protected TaskCompletionSource _IsCurrentInstanceTCS = new(); + protected bool _IsCurrentInstance = false; public bool IsCurrentInstance { @@ -133,8 +129,8 @@ public bool IsCurrentInstance { _IsCurrentInstance = value; - if (!value && SlimContentPage is not ColumnsLayoutPage) - ToolbarViewModel.IsEditModeEnabled = false; + if (!value && LayoutPage is not ColumnsLayoutPage) + AddressToolbarViewModel.IsEditModeEnabled = false; if (value) _IsCurrentInstanceTCS.TrySetResult(); @@ -154,10 +150,13 @@ public bool IsCurrentInstance public virtual Task WhenIsCurrent() => _IsCurrentInstanceTCS.Task; - public event PropertyChangedEventHandler PropertyChanged; + // Events + public event PropertyChangedEventHandler PropertyChanged; public event EventHandler ContentChanged; + // Constructor + public BaseShellPage(CurrentInstanceViewModel instanceViewModel) { InstanceViewModel = instanceViewModel; @@ -166,7 +165,7 @@ public BaseShellPage(CurrentInstanceViewModel instanceViewModel) FilesystemHelpers = new FilesystemHelpers(this, cancellationTokenSource.Token); StorageHistoryHelpers = new StorageHistoryHelpers(new StorageHistoryOperations(this, cancellationTokenSource.Token)); - ToolbarViewModel.InstanceViewModel = InstanceViewModel; + AddressToolbarViewModel.InstanceViewModel = InstanceViewModel; InitToolbarCommands(); @@ -175,18 +174,18 @@ public BaseShellPage(CurrentInstanceViewModel instanceViewModel) if (FilePropertiesHelpers.FlowDirectionSettingIsRightToLeft) FlowDirection = FlowDirection.RightToLeft; - ToolbarViewModel.ToolbarPathItemInvoked += ShellPage_NavigationRequested; - ToolbarViewModel.ToolbarFlyoutOpened += ShellPage_ToolbarFlyoutOpened; - ToolbarViewModel.ToolbarPathItemLoaded += ShellPage_ToolbarPathItemLoaded; - ToolbarViewModel.AddressBarTextEntered += ShellPage_AddressBarTextEntered; - ToolbarViewModel.PathBoxItemDropped += ShellPage_PathBoxItemDropped; + AddressToolbarViewModel.ToolbarPathItemInvoked += ShellPage_NavigationRequested; + AddressToolbarViewModel.ToolbarFlyoutOpened += ShellPage_ToolbarFlyoutOpened; + AddressToolbarViewModel.ToolbarPathItemLoaded += ShellPage_ToolbarPathItemLoaded; + AddressToolbarViewModel.AddressBarTextEntered += ShellPage_AddressBarTextEntered; + AddressToolbarViewModel.PathBoxItemDropped += ShellPage_PathBoxItemDropped; - ToolbarViewModel.RefreshRequested += ShellPage_RefreshRequested; - ToolbarViewModel.EditModeEnabled += NavigationToolbar_EditModeEnabled; - ToolbarViewModel.ItemDraggedOverPathItem += ShellPage_NavigationRequested; - ToolbarViewModel.PathBoxQuerySubmitted += NavigationToolbar_QuerySubmitted; - ToolbarViewModel.SearchBox.TextChanged += ShellPage_TextChanged; - ToolbarViewModel.SearchBox.QuerySubmitted += ShellPage_QuerySubmitted; + AddressToolbarViewModel.RefreshRequested += ShellPage_RefreshRequested; + AddressToolbarViewModel.EditModeEnabled += NavigationToolbar_EditModeEnabled; + AddressToolbarViewModel.ItemDraggedOverPathItem += ShellPage_NavigationRequested; + AddressToolbarViewModel.PathBoxQuerySubmitted += NavigationToolbar_QuerySubmitted; + AddressToolbarViewModel.SearchBox.TextChanged += ShellPage_TextChanged; + AddressToolbarViewModel.SearchBox.QuerySubmitted += ShellPage_QuerySubmitted; InstanceViewModel.FolderSettings.SortDirectionPreferenceUpdated += AppSettings_SortDirectionPreferenceUpdated; InstanceViewModel.FolderSettings.SortOptionPreferenceUpdated += AppSettings_SortOptionPreferenceUpdated; @@ -208,6 +207,8 @@ public BaseShellPage(CurrentInstanceViewModel instanceViewModel) _updateDateDisplayTimer.Start(); } + // Methods + protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "") { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); @@ -230,16 +231,16 @@ protected async void FilesystemViewModel_DirectoryInfoUpdated(object sender, Eve if (ContentPage is null) return; - var directoryItemCountLocalization = "Items".GetLocalizedFormatResource(FilesystemViewModel.FilesAndFolders.Count); + var directoryItemCountLocalization = "Items".GetLocalizedFormatResource(ShellViewModel.FilesAndFolders.Count); BranchItem? headBranch = headBranch = InstanceViewModel.IsGitRepository ? await GitHelpers.GetRepositoryHead(InstanceViewModel.GitRepositoryPath) : null; - if (InstanceViewModel.GitRepositoryPath != FilesystemViewModel.GitDirectory) + if (InstanceViewModel.GitRepositoryPath != ShellViewModel.GitDirectory) { - InstanceViewModel.GitRepositoryPath = FilesystemViewModel.GitDirectory; - InstanceViewModel.IsGitRepository = FilesystemViewModel.IsValidGitDirectory; + InstanceViewModel.GitRepositoryPath = ShellViewModel.GitDirectory; + InstanceViewModel.IsGitRepository = ShellViewModel.IsValidGitDirectory; InstanceViewModel.GitBranchName = headBranch is not null ? headBranch.Name @@ -271,7 +272,7 @@ protected async void FilesystemViewModel_DirectoryInfoUpdated(object sender, Eve headBranch); } - contentPage.StatusBarViewModel.DirectoryItemCount = $"{FilesystemViewModel.FilesAndFolders.Count} {directoryItemCountLocalization}"; + contentPage.StatusBarViewModel.DirectoryItemCount = $"{ShellViewModel.FilesAndFolders.Count} {directoryItemCountLocalization}"; contentPage.UpdateSelectionSize(); } @@ -296,7 +297,7 @@ protected async void FilesystemViewModel_GitDirectoryUpdated(object sender, Even protected async void GitCheckout_Required(object? sender, string branchName) { - if (!await GitHelpers.Checkout(FilesystemViewModel.GitDirectory, branchName)) + if (!await GitHelpers.Checkout(ShellViewModel.GitDirectory, branchName)) { _ContentPage.StatusBarViewModel.ShowLocals = true; _ContentPage.StatusBarViewModel.SelectedBranchIndex = StatusBarViewModel.ACTIVE_BRANCH_INDEX; @@ -355,15 +356,15 @@ protected async void ShellPage_TextChanged(ISearchBoxViewModel sender, SearchBox if (e.Reason != SearchBoxTextChangeReason.UserInput) return; - FilesystemViewModel.FilesAndFoldersFilter = sender.Query; - await FilesystemViewModel.ApplyFilesAndFoldersChangesAsync(); + ShellViewModel.FilesAndFoldersFilter = sender.Query; + await ShellViewModel.ApplyFilesAndFoldersChangesAsync(); if (!string.IsNullOrWhiteSpace(sender.Query)) { var search = new FolderSearch { Query = sender.Query, - Folder = FilesystemViewModel.WorkingDirectory, + Folder = ShellViewModel.WorkingDirectory, MaxItemCount = 10, }; @@ -382,22 +383,22 @@ protected async void ShellPage_RefreshRequested(object sender, EventArgs e) protected void AppSettings_SortDirectionPreferenceUpdated(object sender, SortDirection e) { - FilesystemViewModel?.UpdateSortDirectionStatusAsync(); + ShellViewModel?.UpdateSortDirectionStatusAsync(); } protected void AppSettings_SortOptionPreferenceUpdated(object sender, SortOption e) { - FilesystemViewModel?.UpdateSortOptionStatusAsync(); + ShellViewModel?.UpdateSortOptionStatusAsync(); } protected void AppSettings_SortDirectoriesAlongsideFilesPreferenceUpdated(object sender, bool e) { - FilesystemViewModel?.UpdateSortDirectoriesAlongsideFilesAsync(); + ShellViewModel?.UpdateSortDirectoriesAlongsideFilesAsync(); } protected void AppSettings_SortFilesFirstPreferenceUpdated(object sender, bool e) { - FilesystemViewModel?.UpdateSortFilesFirstAsync(); + ShellViewModel?.UpdateSortFilesFirstAsync(); } protected void CoreWindow_PointerPressed(object sender, PointerRoutedEventArgs args) @@ -419,12 +420,12 @@ protected async void ShellPage_PathBoxItemDropped(object sender, PathBoxItemDrop protected async void ShellPage_AddressBarTextEntered(object sender, AddressBarTextEnteredEventArgs e) { - await ToolbarViewModel.SetAddressBarSuggestionsAsync(e.AddressBarTextField, this); + await AddressToolbarViewModel.SetAddressBarSuggestionsAsync(e.AddressBarTextField, this); } protected async void ShellPage_ToolbarPathItemLoaded(object sender, ToolbarPathItemLoadedEventArgs e) { - await ToolbarViewModel.SetPathBoxDropDownFlyoutAsync(e.OpenedFlyout, e.Item, this); + await AddressToolbarViewModel.SetPathBoxDropDownFlyoutAsync(e.OpenedFlyout, e.Item, this); } protected async void ShellPage_ToolbarFlyoutOpened(object sender, ToolbarFlyoutOpenedEventArgs e) @@ -432,21 +433,21 @@ protected async void ShellPage_ToolbarFlyoutOpened(object sender, ToolbarFlyoutO var pathBoxItem = ((Button)e.OpenedFlyout.Target).DataContext as PathBoxItem; if (pathBoxItem is not null) - await ToolbarViewModel.SetPathBoxDropDownFlyoutAsync(e.OpenedFlyout, pathBoxItem, this); + await AddressToolbarViewModel.SetPathBoxDropDownFlyoutAsync(e.OpenedFlyout, pathBoxItem, this); } protected async void NavigationToolbar_QuerySubmitted(object sender, ToolbarQuerySubmittedEventArgs e) { - await ToolbarViewModel.CheckPathInputAsync(e.QueryText, ToolbarViewModel.PathComponents.LastOrDefault()?.Path, this); + await AddressToolbarViewModel.CheckPathInputAsync(e.QueryText, AddressToolbarViewModel.PathComponents.LastOrDefault()?.Path, this); } protected void NavigationToolbar_EditModeEnabled(object sender, EventArgs e) { - ToolbarViewModel.ManualEntryBoxLoaded = true; - ToolbarViewModel.ClickablePathLoaded = false; - ToolbarViewModel.PathText = string.IsNullOrEmpty(FilesystemViewModel?.WorkingDirectory) + AddressToolbarViewModel.ManualEntryBoxLoaded = true; + AddressToolbarViewModel.ClickablePathLoaded = false; + AddressToolbarViewModel.PathText = string.IsNullOrEmpty(ShellViewModel?.WorkingDirectory) ? Constants.UserEnvironmentPaths.HomePath - : FilesystemViewModel.WorkingDirectory; + : ShellViewModel.WorkingDirectory; } protected async void DrivesManager_PropertyChanged(object sender, PropertyChangedEventArgs e) @@ -472,40 +473,40 @@ public async Task UpdatePathUIToWorkingDirectoryAsync(string newWorkingDir, stri if (cts.IsCancellationRequested) return; - ToolbarViewModel.PathComponents.Clear(); + AddressToolbarViewModel.PathComponents.Clear(); foreach (var component in components) - ToolbarViewModel.PathComponents.Add(component); + AddressToolbarViewModel.PathComponents.Add(component); } else { cts?.Cancel(); // Clear the path UI - ToolbarViewModel.PathComponents.Clear(); - ToolbarViewModel.IsSingleItemOverride = true; - ToolbarViewModel.PathComponents.Add(new PathBoxItem() { Path = null, Title = singleItemOverride }); + AddressToolbarViewModel.PathComponents.Clear(); + AddressToolbarViewModel.IsSingleItemOverride = true; + AddressToolbarViewModel.PathComponents.Add(new PathBoxItem() { Path = null, Title = singleItemOverride }); } } public void SubmitSearch(string query) { - FilesystemViewModel.CancelSearch(); + ShellViewModel.CancelSearch(); InstanceViewModel.CurrentSearchQuery = query; var args = new NavigationArguments() { AssociatedTabInstance = this, IsSearchResultPage = true, - SearchPathParam = FilesystemViewModel.WorkingDirectory, + SearchPathParam = ShellViewModel.WorkingDirectory, SearchQuery = query, }; - var layout = InstanceViewModel.FolderSettings.GetLayoutType(FilesystemViewModel.WorkingDirectory); + var layout = InstanceViewModel.FolderSettings.GetLayoutType(ShellViewModel.WorkingDirectory); if (layout == typeof(ColumnsLayoutPage)) - NavigateToPath(FilesystemViewModel.WorkingDirectory, typeof(DetailsLayoutPage), args); + NavigateToPath(ShellViewModel.WorkingDirectory, typeof(DetailsLayoutPage), args); else - NavigateToPath(FilesystemViewModel.WorkingDirectory, layout, args); + NavigateToPath(ShellViewModel.WorkingDirectory, layout, args); } public void NavigateWithArguments(Type sourcePageType, NavigationArguments navArgs) @@ -526,17 +527,17 @@ public void NavigateToPath(string navigationPath, NavigationArguments? navArgs = public Task TabItemDragOver(object sender, DragEventArgs e) { - return SlimContentPage?.CommandsViewModel.DragOverAsync(e); + return LayoutPage?.CommandsViewModel.DragOverAsync(e); } public Task TabItemDrop(object sender, DragEventArgs e) { - return SlimContentPage?.CommandsViewModel.DropAsync(e); + return LayoutPage?.CommandsViewModel.DropAsync(e); } public async Task RefreshIfNoWatcherExistsAsync() { - if (FilesystemViewModel.HasNoWatcher) + if (ShellViewModel.HasNoWatcher) await Refresh_Click(); } @@ -544,20 +545,20 @@ public async Task Refresh_Click() { if (InstanceViewModel.IsPageTypeSearchResults) { - ToolbarViewModel.CanRefresh = false; + AddressToolbarViewModel.CanRefresh = false; var searchInstance = new FolderSearch { Query = InstanceViewModel.CurrentSearchQuery ?? (string)TabBarItemParameter.NavigationParameter, - Folder = FilesystemViewModel.WorkingDirectory, + Folder = ShellViewModel.WorkingDirectory, ThumbnailSize = InstanceViewModel.FolderSettings.GetRoundedIconSize(), }; - await FilesystemViewModel.SearchAsync(searchInstance); + await ShellViewModel.SearchAsync(searchInstance); } else if (CurrentPageType != typeof(HomePage)) { - ToolbarViewModel.CanRefresh = false; - FilesystemViewModel?.RefreshItems(null); + AddressToolbarViewModel.CanRefresh = false; + ShellViewModel?.RefreshItems(null); } } @@ -630,19 +631,19 @@ protected void FilesystemViewModel_ItemLoadStatusChanged(object sender, ItemLoad switch (e.Status) { case ItemLoadStatusChangedEventArgs.ItemLoadStatus.Starting: - ToolbarViewModel.CanRefresh = false; + AddressToolbarViewModel.CanRefresh = false; SetLoadingIndicatorForTabs(true); break; case ItemLoadStatusChangedEventArgs.ItemLoadStatus.InProgress: var columnCanNavigateBackward = false; var columnCanNavigateForward = false; - if (SlimContentPage is ColumnsLayoutPage browser) + if (LayoutPage is ColumnsLayoutPage browser) { columnCanNavigateBackward = browser.ParentShellPageInstance?.CanNavigateBackward ?? false; columnCanNavigateForward = browser.ParentShellPageInstance?.CanNavigateForward ?? false; } - ToolbarViewModel.CanGoBack = ItemDisplay.CanGoBack || columnCanNavigateBackward; - ToolbarViewModel.CanGoForward = ItemDisplay.CanGoForward || columnCanNavigateForward; + AddressToolbarViewModel.CanGoBack = ItemDisplay.CanGoBack || columnCanNavigateBackward; + AddressToolbarViewModel.CanGoForward = ItemDisplay.CanGoForward || columnCanNavigateForward; SetLoadingIndicatorForTabs(true); break; case ItemLoadStatusChangedEventArgs.ItemLoadStatus.Complete: @@ -651,7 +652,7 @@ protected void FilesystemViewModel_ItemLoadStatusChanged(object sender, ItemLoad if (ContentPage is not null) ContentPage.ItemManipulationModel.ScrollToTop(); - ToolbarViewModel.CanRefresh = true; + AddressToolbarViewModel.CanRefresh = true; // Select previous directory if (!string.IsNullOrWhiteSpace(e.PreviousDirectory) && e.PreviousDirectory.Contains(e.Path, StringComparison.Ordinal) && @@ -684,7 +685,7 @@ protected void FilesystemViewModel_ItemLoadStatusChanged(object sender, ItemLoad if (folderToSelect.EndsWith(separator)) folderToSelect = folderToSelect.Remove(folderToSelect.Length - 1, 1); - var itemToSelect = FilesystemViewModel.FilesAndFolders.ToList().FirstOrDefault((item) => item.ItemPath == folderToSelect); + var itemToSelect = ShellViewModel.FilesAndFolders.ToList().FirstOrDefault((item) => item.ItemPath == folderToSelect); if (itemToSelect is not null && ContentPage is not null && userSettingsService.FoldersSettingsService.ScrollToPreviousFolderWhenNavigatingUp) { @@ -714,9 +715,9 @@ protected virtual void ShellPage_NavigationRequested(object sender, PathNavigati protected void InitToolbarCommands() { - ToolbarViewModel.OpenNewWindowCommand = new AsyncRelayCommand(NavigationHelpers.LaunchNewWindowAsync); - ToolbarViewModel.CreateNewFileCommand = new RelayCommand(x => UIFilesystemHelpers.CreateFileFromDialogResultTypeAsync(AddItemDialogItemType.File, x, this)); - ToolbarViewModel.UpdateCommand = new AsyncRelayCommand(async () => await updateSettingsService.DownloadUpdatesAsync()); + AddressToolbarViewModel.OpenNewWindowCommand = new AsyncRelayCommand(NavigationHelpers.LaunchNewWindowAsync); + AddressToolbarViewModel.CreateNewFileCommand = new RelayCommand(x => UIFilesystemHelpers.CreateFileFromDialogResultTypeAsync(AddItemDialogItemType.File, x, this)); + AddressToolbarViewModel.UpdateCommand = new AsyncRelayCommand(async () => await updateSettingsService.DownloadUpdatesAsync()); } protected async Task GetContentOrNullAsync() @@ -751,7 +752,7 @@ await DispatcherQueue.EnqueueOrInvokeAsync(async () => protected void SelectSidebarItemFromPath(Type incomingSourcePageType = null) { if (incomingSourcePageType == typeof(HomePage) && incomingSourcePageType is not null) - ToolbarViewModel.PathControlDisplayText = "Home".GetLocalizedResource(); + AddressToolbarViewModel.PathControlDisplayText = "Home".GetLocalizedResource(); } protected void SetLoadingIndicatorForTabs(bool isLoading) @@ -797,11 +798,11 @@ private void UpdateDateDisplayTimer_Tick(object sender, object e) if (userSettingsService.GeneralSettingsService.DateTimeFormat != _lastDateTimeFormats) { _lastDateTimeFormats = userSettingsService.GeneralSettingsService.DateTimeFormat; - FilesystemViewModel?.UpdateDateDisplay(true); + ShellViewModel?.UpdateDateDisplay(true); } else if (userSettingsService.GeneralSettingsService.DateTimeFormat == DateTimeFormats.Application) { - FilesystemViewModel?.UpdateDateDisplay(false); + ShellViewModel?.UpdateDateDisplay(false); } } @@ -811,16 +812,16 @@ public virtual void Dispose() PointerPressed -= CoreWindow_PointerPressed; drivesViewModel.PropertyChanged -= DrivesManager_PropertyChanged; - ToolbarViewModel.ToolbarPathItemInvoked -= ShellPage_NavigationRequested; - ToolbarViewModel.ToolbarFlyoutOpened -= ShellPage_ToolbarFlyoutOpened; - ToolbarViewModel.ToolbarPathItemLoaded -= ShellPage_ToolbarPathItemLoaded; - ToolbarViewModel.AddressBarTextEntered -= ShellPage_AddressBarTextEntered; - ToolbarViewModel.PathBoxItemDropped -= ShellPage_PathBoxItemDropped; - ToolbarViewModel.RefreshRequested -= ShellPage_RefreshRequested; - ToolbarViewModel.EditModeEnabled -= NavigationToolbar_EditModeEnabled; - ToolbarViewModel.ItemDraggedOverPathItem -= ShellPage_NavigationRequested; - ToolbarViewModel.PathBoxQuerySubmitted -= NavigationToolbar_QuerySubmitted; - ToolbarViewModel.SearchBox.TextChanged -= ShellPage_TextChanged; + AddressToolbarViewModel.ToolbarPathItemInvoked -= ShellPage_NavigationRequested; + AddressToolbarViewModel.ToolbarFlyoutOpened -= ShellPage_ToolbarFlyoutOpened; + AddressToolbarViewModel.ToolbarPathItemLoaded -= ShellPage_ToolbarPathItemLoaded; + AddressToolbarViewModel.AddressBarTextEntered -= ShellPage_AddressBarTextEntered; + AddressToolbarViewModel.PathBoxItemDropped -= ShellPage_PathBoxItemDropped; + AddressToolbarViewModel.RefreshRequested -= ShellPage_RefreshRequested; + AddressToolbarViewModel.EditModeEnabled -= NavigationToolbar_EditModeEnabled; + AddressToolbarViewModel.ItemDraggedOverPathItem -= ShellPage_NavigationRequested; + AddressToolbarViewModel.PathBoxQuerySubmitted -= NavigationToolbar_QuerySubmitted; + AddressToolbarViewModel.SearchBox.TextChanged -= ShellPage_TextChanged; InstanceViewModel.FolderSettings.LayoutPreferencesUpdateRequired -= FolderSettings_LayoutPreferencesUpdateRequired; InstanceViewModel.FolderSettings.SortDirectionPreferenceUpdated -= AppSettings_SortDirectionPreferenceUpdated; @@ -829,15 +830,15 @@ public virtual void Dispose() InstanceViewModel.FolderSettings.SortFilesFirstPreferenceUpdated -= AppSettings_SortFilesFirstPreferenceUpdated; // Prevent weird case of this being null when many tabs are opened/closed quickly - if (FilesystemViewModel is not null) + if (ShellViewModel is not null) { - FilesystemViewModel.WorkingDirectoryModified -= ViewModel_WorkingDirectoryModified; - FilesystemViewModel.ItemLoadStatusChanged -= FilesystemViewModel_ItemLoadStatusChanged; - FilesystemViewModel.DirectoryInfoUpdated -= FilesystemViewModel_DirectoryInfoUpdated; - FilesystemViewModel.PageTypeUpdated -= FilesystemViewModel_PageTypeUpdated; - FilesystemViewModel.OnSelectionRequestedEvent -= FilesystemViewModel_OnSelectionRequestedEvent; - FilesystemViewModel.GitDirectoryUpdated -= FilesystemViewModel_GitDirectoryUpdated; - FilesystemViewModel.Dispose(); + ShellViewModel.WorkingDirectoryModified -= ViewModel_WorkingDirectoryModified; + ShellViewModel.ItemLoadStatusChanged -= FilesystemViewModel_ItemLoadStatusChanged; + ShellViewModel.DirectoryInfoUpdated -= FilesystemViewModel_DirectoryInfoUpdated; + ShellViewModel.PageTypeUpdated -= FilesystemViewModel_PageTypeUpdated; + ShellViewModel.OnSelectionRequestedEvent -= FilesystemViewModel_OnSelectionRequestedEvent; + ShellViewModel.GitDirectoryUpdated -= FilesystemViewModel_GitDirectoryUpdated; + ShellViewModel.Dispose(); } if (ItemDisplay.Content is IDisposable disposableContent) diff --git a/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs b/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs index e6b0f57a1485..2b951248419f 100644 --- a/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs +++ b/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs @@ -76,19 +76,19 @@ protected override void OnNavigationParamsChanged() protected override void Page_Loaded(object sender, RoutedEventArgs e) { - FilesystemViewModel = new ItemViewModel(InstanceViewModel?.FolderSettings); - FilesystemViewModel.WorkingDirectoryModified += ViewModel_WorkingDirectoryModified; - FilesystemViewModel.ItemLoadStatusChanged += FilesystemViewModel_ItemLoadStatusChanged; - FilesystemViewModel.DirectoryInfoUpdated += FilesystemViewModel_DirectoryInfoUpdated; - FilesystemViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated; - FilesystemViewModel.OnSelectionRequestedEvent += FilesystemViewModel_OnSelectionRequestedEvent; - FilesystemViewModel.GitDirectoryUpdated += FilesystemViewModel_GitDirectoryUpdated; + ShellViewModel = new ShellViewModel(InstanceViewModel?.FolderSettings); + ShellViewModel.WorkingDirectoryModified += ViewModel_WorkingDirectoryModified; + ShellViewModel.ItemLoadStatusChanged += FilesystemViewModel_ItemLoadStatusChanged; + ShellViewModel.DirectoryInfoUpdated += FilesystemViewModel_DirectoryInfoUpdated; + ShellViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated; + ShellViewModel.OnSelectionRequestedEvent += FilesystemViewModel_OnSelectionRequestedEvent; + ShellViewModel.GitDirectoryUpdated += FilesystemViewModel_GitDirectoryUpdated; PaneHolder = this.FindAscendant()?.ParentShellPageInstance?.PaneHolder; base.Page_Loaded(sender, e); - NotifyPropertyChanged(nameof(FilesystemViewModel)); + NotifyPropertyChanged(nameof(ShellViewModel)); } protected override async void ViewModel_WorkingDirectoryModified(object sender, WorkingDirectoryModifiedEventArgs e) @@ -102,10 +102,10 @@ private async void ItemDisplayFrame_Navigated(object sender, NavigationEventArgs { ContentPage = await GetContentOrNullAsync(); - if (!ToolbarViewModel.SearchBox.WasQuerySubmitted) + if (!AddressToolbarViewModel.SearchBox.WasQuerySubmitted) { - ToolbarViewModel.SearchBox.Query = string.Empty; - ToolbarViewModel.IsSearchBoxVisible = false; + AddressToolbarViewModel.SearchBox.Query = string.Empty; + AddressToolbarViewModel.IsSearchBoxVisible = false; } if (ItemDisplayFrame.CurrentSourcePageType == typeof(ColumnLayoutPage)) @@ -139,15 +139,15 @@ private async void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, Keybo { // Ctrl + V, Paste case (true, false, false, true, VirtualKey.V): - if (!ToolbarViewModel.IsEditModeEnabled && !ContentPage.IsRenamingItem && !InstanceViewModel.IsPageTypeSearchResults && !ToolbarViewModel.SearchHasFocus) - await UIFilesystemHelpers.PasteItemAsync(FilesystemViewModel.WorkingDirectory, this); + if (!AddressToolbarViewModel.IsEditModeEnabled && !ContentPage.IsRenamingItem && !InstanceViewModel.IsPageTypeSearchResults && !AddressToolbarViewModel.SearchHasFocus) + await UIFilesystemHelpers.PasteItemAsync(ShellViewModel.WorkingDirectory, this); break; } } public override void Back_Click() { - ToolbarViewModel.CanGoBack = false; + AddressToolbarViewModel.CanGoBack = false; if (ItemDisplayFrame.CanGoBack) base.Back_Click(); else @@ -156,7 +156,7 @@ public override void Back_Click() public override void Forward_Click() { - ToolbarViewModel.CanGoForward = false; + AddressToolbarViewModel.CanGoForward = false; if (ItemDisplayFrame.CanGoForward) base.Forward_Click(); else @@ -165,7 +165,7 @@ public override void Forward_Click() public override void Up_Click() { - if (!ToolbarViewModel.CanNavigateToParent) + if (!AddressToolbarViewModel.CanNavigateToParent) return; this.FindAscendant()?.NavigateUp(); @@ -191,13 +191,13 @@ public void RemoveLastPageFromBackStack() public void SubmitSearch(string query) { - FilesystemViewModel.CancelSearch(); + ShellViewModel.CancelSearch(); InstanceViewModel.CurrentSearchQuery = query; ItemDisplayFrame.Navigate(typeof(ColumnLayoutPage), new NavigationArguments() { AssociatedTabInstance = this, IsSearchResultPage = true, - SearchPathParam = FilesystemViewModel.WorkingDirectory, + SearchPathParam = ShellViewModel.WorkingDirectory, SearchQuery = query, }); diff --git a/src/Files.App/Views/Shells/ModernShellPage.xaml.cs b/src/Files.App/Views/Shells/ModernShellPage.xaml.cs index 86e7d99f52a5..fca0755462a5 100644 --- a/src/Files.App/Views/Shells/ModernShellPage.xaml.cs +++ b/src/Files.App/Views/Shells/ModernShellPage.xaml.cs @@ -44,16 +44,16 @@ public ModernShellPage() : base(new CurrentInstanceViewModel()) { InitializeComponent(); - FilesystemViewModel = new ItemViewModel(InstanceViewModel.FolderSettings); - FilesystemViewModel.WorkingDirectoryModified += ViewModel_WorkingDirectoryModified; - FilesystemViewModel.ItemLoadStatusChanged += FilesystemViewModel_ItemLoadStatusChanged; - FilesystemViewModel.DirectoryInfoUpdated += FilesystemViewModel_DirectoryInfoUpdated; - FilesystemViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated; - FilesystemViewModel.OnSelectionRequestedEvent += FilesystemViewModel_OnSelectionRequestedEvent; - FilesystemViewModel.GitDirectoryUpdated += FilesystemViewModel_GitDirectoryUpdated; + ShellViewModel = new ShellViewModel(InstanceViewModel.FolderSettings); + ShellViewModel.WorkingDirectoryModified += ViewModel_WorkingDirectoryModified; + ShellViewModel.ItemLoadStatusChanged += FilesystemViewModel_ItemLoadStatusChanged; + ShellViewModel.DirectoryInfoUpdated += FilesystemViewModel_DirectoryInfoUpdated; + ShellViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated; + ShellViewModel.OnSelectionRequestedEvent += FilesystemViewModel_OnSelectionRequestedEvent; + ShellViewModel.GitDirectoryUpdated += FilesystemViewModel_GitDirectoryUpdated; - ToolbarViewModel.PathControlDisplayText = "Home".GetLocalizedResource(); - ToolbarViewModel.RefreshWidgetsRequested += ModernShellPage_RefreshWidgetsRequested; + AddressToolbarViewModel.PathControlDisplayText = "Home".GetLocalizedResource(); + AddressToolbarViewModel.RefreshWidgetsRequested += ModernShellPage_RefreshWidgetsRequested; _navigationInteractionTracker = new NavigationInteractionTracker(this, BackIcon, ForwardIcon); _navigationInteractionTracker.NavigationRequested += OverscrollNavigationRequested; @@ -67,12 +67,12 @@ private void ModernShellPage_RefreshWidgetsRequested(object sender, EventArgs e) protected override void FolderSettings_LayoutPreferencesUpdateRequired(object sender, LayoutPreferenceEventArgs e) { - if (FilesystemViewModel is null) + if (ShellViewModel is null) return; - LayoutPreferencesManager.SetLayoutPreferencesForPath(FilesystemViewModel.WorkingDirectory, e.LayoutPreference); + LayoutPreferencesManager.SetLayoutPreferencesForPath(ShellViewModel.WorkingDirectory, e.LayoutPreference); if (e.IsAdaptiveLayoutUpdateRequired) - AdaptiveLayoutHelpers.ApplyAdaptativeLayout(InstanceViewModel.FolderSettings, FilesystemViewModel.WorkingDirectory, FilesystemViewModel.FilesAndFolders.ToList()); + AdaptiveLayoutHelpers.ApplyAdaptativeLayout(InstanceViewModel.FolderSettings, ShellViewModel.WorkingDirectory, ShellViewModel.FilesAndFolders.ToList()); } protected override void OnNavigatedTo(NavigationEventArgs eventArgs) @@ -138,13 +138,13 @@ protected override async void ViewModel_WorkingDirectoryModified(object sender, private async void ItemDisplayFrame_Navigated(object sender, NavigationEventArgs e) { ContentPage = await GetContentOrNullAsync(); - if (!ToolbarViewModel.SearchBox.WasQuerySubmitted) + if (!AddressToolbarViewModel.SearchBox.WasQuerySubmitted) { - ToolbarViewModel.SearchBox.Query = string.Empty; - ToolbarViewModel.IsSearchBoxVisible = false; + AddressToolbarViewModel.SearchBox.Query = string.Empty; + AddressToolbarViewModel.IsSearchBoxVisible = false; } - ToolbarViewModel.UpdateAdditionalActions(); + AddressToolbarViewModel.UpdateAdditionalActions(); if (ItemDisplayFrame.CurrentSourcePageType == (typeof(DetailsLayoutPage)) || ItemDisplayFrame.CurrentSourcePageType == typeof(GridLayoutPage)) { @@ -181,8 +181,8 @@ private async void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, Keybo { // Ctrl + V, Paste case (true, false, false, true, VirtualKey.V): - if (!ToolbarViewModel.IsEditModeEnabled && !ContentPage.IsRenamingItem && !InstanceViewModel.IsPageTypeSearchResults && !ToolbarViewModel.SearchHasFocus) - await UIFilesystemHelpers.PasteItemAsync(FilesystemViewModel.WorkingDirectory, this); + if (!AddressToolbarViewModel.IsEditModeEnabled && !ContentPage.IsRenamingItem && !InstanceViewModel.IsPageTypeSearchResults && !AddressToolbarViewModel.SearchHasFocus) + await UIFilesystemHelpers.PasteItemAsync(ShellViewModel.WorkingDirectory, this); break; } } @@ -203,7 +203,7 @@ private void OverscrollNavigationRequested(object? sender, OverscrollNavigationE public override void Back_Click() { - ToolbarViewModel.CanGoBack = false; + AddressToolbarViewModel.CanGoBack = false; if (!ItemDisplayFrame.CanGoBack) return; @@ -212,7 +212,7 @@ public override void Back_Click() public override void Forward_Click() { - ToolbarViewModel.CanGoForward = false; + AddressToolbarViewModel.CanGoForward = false; if (!ItemDisplayFrame.CanGoForward) return; @@ -221,14 +221,14 @@ public override void Forward_Click() public override void Up_Click() { - if (!ToolbarViewModel.CanNavigateToParent) + if (!AddressToolbarViewModel.CanNavigateToParent) return; - ToolbarViewModel.CanNavigateToParent = false; - if (string.IsNullOrEmpty(FilesystemViewModel?.WorkingDirectory)) + AddressToolbarViewModel.CanNavigateToParent = false; + if (string.IsNullOrEmpty(ShellViewModel?.WorkingDirectory)) return; - bool isPathRooted = string.Equals(FilesystemViewModel.WorkingDirectory, PathNormalization.GetPathRoot(FilesystemViewModel.WorkingDirectory), StringComparison.OrdinalIgnoreCase); + bool isPathRooted = string.Equals(ShellViewModel.WorkingDirectory, PathNormalization.GetPathRoot(ShellViewModel.WorkingDirectory), StringComparison.OrdinalIgnoreCase); if (isPathRooted) { ItemDisplayFrame.Navigate( @@ -242,13 +242,13 @@ public override void Up_Click() } else { - string parentDirectoryOfPath = FilesystemViewModel.WorkingDirectory.TrimEnd('\\', '/'); + string parentDirectoryOfPath = ShellViewModel.WorkingDirectory.TrimEnd('\\', '/'); var lastSlashIndex = parentDirectoryOfPath.LastIndexOf("\\", StringComparison.Ordinal); if (lastSlashIndex == -1) lastSlashIndex = parentDirectoryOfPath.LastIndexOf("/", StringComparison.Ordinal); if (lastSlashIndex != -1) - parentDirectoryOfPath = FilesystemViewModel.WorkingDirectory.Remove(lastSlashIndex); + parentDirectoryOfPath = ShellViewModel.WorkingDirectory.Remove(lastSlashIndex); if (parentDirectoryOfPath.EndsWith(':')) parentDirectoryOfPath += '\\'; @@ -266,7 +266,7 @@ public override void Up_Click() public override void Dispose() { - ToolbarViewModel.RefreshWidgetsRequested -= ModernShellPage_RefreshWidgetsRequested; + AddressToolbarViewModel.RefreshWidgetsRequested -= ModernShellPage_RefreshWidgetsRequested; _navigationInteractionTracker.NavigationRequested -= OverscrollNavigationRequested; _navigationInteractionTracker.Dispose(); @@ -287,7 +287,7 @@ public override void NavigateHome() public override void NavigateToPath(string? navigationPath, Type? sourcePageType, NavigationArguments? navArgs = null) { - FilesystemViewModel.FilesAndFoldersFilter = null; + ShellViewModel.FilesAndFoldersFilter = null; if (sourcePageType is null && !string.IsNullOrEmpty(navigationPath)) sourcePageType = InstanceViewModel.FolderSettings.GetLayoutType(navigationPath); @@ -302,9 +302,9 @@ public override void NavigateToPath(string? navigationPath, Type? sourcePageType else { if ((string.IsNullOrEmpty(navigationPath) || - string.IsNullOrEmpty(FilesystemViewModel?.WorkingDirectory) || + string.IsNullOrEmpty(ShellViewModel?.WorkingDirectory) || navigationPath.TrimEnd(Path.DirectorySeparatorChar).Equals( - FilesystemViewModel.WorkingDirectory.TrimEnd(Path.DirectorySeparatorChar), + ShellViewModel.WorkingDirectory.TrimEnd(Path.DirectorySeparatorChar), StringComparison.OrdinalIgnoreCase)) && (TabBarItemParameter?.NavigationParameter is not string navArg || string.IsNullOrEmpty(navArg) || @@ -338,7 +338,7 @@ public override void NavigateToPath(string? navigationPath, Type? sourcePageType transition); } - ToolbarViewModel.PathControlDisplayText = FilesystemViewModel.WorkingDirectory; + AddressToolbarViewModel.PathControlDisplayText = ShellViewModel.WorkingDirectory; } } } From c9cfc56080fa7de9424b404be0ad9d43002e60d9 Mon Sep 17 00:00:00 2001 From: 0x5bfa <62196528+0x5bfa@users.noreply.github.com> Date: Wed, 12 Jun 2024 18:48:33 +0900 Subject: [PATCH 4/4] Revert "Init" This reverts commit 03a3c1a22dc0ade6ee3a5a2c0dc38a0744762589. --- .../Compress/BaseCompressArchiveAction.cs | 2 +- .../Decompress/BaseDecompressArchiveAction.cs | 2 +- .../DecompressArchiveToChildFolderAction.cs | 2 +- .../Content/Background/BaseSetAsAction.cs | 6 +- .../ImageManipulation/BaseRotateAction.cs | 8 +- .../PreviewPopup/LaunchPreviewPopupAction.cs | 4 +- .../Content/Run/RunWithPowershellAction.cs | 2 +- .../Content/Selection/ClearSelectionAction.cs | 8 +- .../Selection/InvertSelectionAction.cs | 8 +- .../Content/Selection/SelectAllAction.cs | 10 +- .../Actions/FileSystem/BaseDeleteAction.cs | 4 +- .../Actions/FileSystem/CopyPathAction.cs | 8 +- .../FileSystem/CopyPathWithQuotesAction.cs | 6 +- .../FileSystem/OpenFileLocationAction.cs | 4 +- .../Actions/FileSystem/PasteItemAction.cs | 2 +- .../FileSystem/PasteItemToSelectionAction.cs | 2 +- .../Actions/FileSystem/RenameAction.cs | 4 +- .../Actions/Global/EditPathAction.cs | 2 +- src/Files.App/Actions/Global/SearchAction.cs | 2 +- .../OpenInNewPane/BaseOpenInNewPaneAction.cs | 2 +- .../OpenInNewTab/BaseOpenInNewTabAction.cs | 2 +- .../BaseOpenInNewWindowAction.cs | 6 +- .../Actions/Open/OpenCommandPaletteAction.cs | 2 +- .../Actions/Open/OpenInVSCodeAction.cs | 2 +- .../Actions/Open/OpenPropertiesAction.cs | 6 +- .../Actions/Start/PinToStartAction.cs | 8 +- .../Actions/Start/UnpinFromStartAction.cs | 4 +- src/Files.App/App.xaml.cs | 2 +- .../ContentPage/ContentPageContext.cs | 30 +-- src/Files.App/Data/Contracts/IShellPage.cs | 6 +- .../ContentPageContextFlyoutFactory.cs | 4 +- .../Models/ItemViewModel.cs} | 6 +- .../Extensions/ShellNewEntryExtensions.cs | 2 +- .../Helpers/Dialog/DynamicDialogFactory.cs | 2 +- .../Helpers/Navigation/NavigationHelpers.cs | 26 +-- .../Helpers/UI/UIFilesystemHelpers.cs | 44 ++-- .../Helpers/Win32/Win32Helper.Process.cs | 4 +- .../Utils/RecycleBin/RecycleBinHelpers.cs | 6 +- .../Storage/Helpers/FilePropertiesHelpers.cs | 4 +- .../Storage/Helpers/StorageFileExtensions.cs | 2 +- .../Storage/Operations/FilesystemHelpers.cs | 2 +- .../Operations/FilesystemOperations.cs | 36 +-- .../Operations/ShellFilesystemOperations.cs | 2 +- .../ViewModels/Layouts/BaseLayoutViewModel.cs | 12 +- .../Properties/CustomizationViewModel.cs | 2 +- .../Properties/Items/FileProperties.cs | 2 +- .../Properties/Items/FolderProperties.cs | 2 +- .../Properties/Items/LibraryProperties.cs | 4 +- .../UserControls/AddressToolbarViewModel.cs | 20 +- .../UserControls/SidebarViewModel.cs | 4 +- .../Widgets/QuickAccessWidgetViewModel.cs | 4 +- src/Files.App/Views/HomePage.xaml.cs | 26 +-- .../Views/Layouts/BaseGroupableLayoutPage.cs | 28 +-- src/Files.App/Views/Layouts/BaseLayoutPage.cs | 76 +++---- .../Views/Layouts/ColumnLayoutPage.xaml.cs | 8 +- .../Views/Layouts/ColumnsLayoutPage.xaml.cs | 28 +-- .../Views/Layouts/DetailsLayoutPage.xaml.cs | 24 +- .../Views/Layouts/GridLayoutPage.xaml.cs | 18 +- src/Files.App/Views/MainPage.xaml.cs | 12 +- .../Views/Properties/GeneralPage.xaml.cs | 12 +- src/Files.App/Views/ShellPanesPage.xaml.cs | 20 +- src/Files.App/Views/Shells/BaseShellPage.cs | 211 +++++++++--------- .../Views/Shells/ColumnShellPage.xaml.cs | 36 +-- .../Views/Shells/ModernShellPage.xaml.cs | 62 ++--- 64 files changed, 453 insertions(+), 454 deletions(-) rename src/Files.App/{ViewModels/ShellViewModel.cs => Data/Models/ItemViewModel.cs} (99%) diff --git a/src/Files.App/Actions/Content/Archives/Compress/BaseCompressArchiveAction.cs b/src/Files.App/Actions/Content/Archives/Compress/BaseCompressArchiveAction.cs index 7e1cb31c825e..3831bca97af6 100644 --- a/src/Files.App/Actions/Content/Archives/Compress/BaseCompressArchiveAction.cs +++ b/src/Files.App/Actions/Content/Archives/Compress/BaseCompressArchiveAction.cs @@ -35,7 +35,7 @@ protected void GetDestination(out string[] sources, out string directory, out st if (sources.Length is not 0) { // Get the current directory path - directory = context.ShellPage.ShellViewModel.WorkingDirectory.Normalize(); + directory = context.ShellPage.FilesystemViewModel.WorkingDirectory.Normalize(); // Get the library save folder if the folder is library item if (App.LibraryManager.TryGetLibrary(directory, out var library) && !library.IsEmpty) diff --git a/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs b/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs index cfe8039995fb..2f7dfa0cdad9 100644 --- a/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs +++ b/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs @@ -55,7 +55,7 @@ protected async Task DecompressArchiveHereAsync(bool smart = false) { var password = string.Empty; BaseStorageFile archive = await StorageHelpers.ToStorageItem(selectedItem.ItemPath); - BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem(context.ShellPage?.ShellViewModel.CurrentFolder?.ItemPath ?? string.Empty); + BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem(context.ShellPage?.FilesystemViewModel.CurrentFolder?.ItemPath ?? string.Empty); if (archive?.Path is null) return; diff --git a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveToChildFolderAction.cs b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveToChildFolderAction.cs index 361bc3bf2fb1..c7cd966391a3 100644 --- a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveToChildFolderAction.cs +++ b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveToChildFolderAction.cs @@ -31,7 +31,7 @@ public override async Task ExecuteAsync(object? parameter = null) var password = string.Empty; BaseStorageFile archive = await StorageHelpers.ToStorageItem(selectedItem.ItemPath); - BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem(context.ShellPage?.ShellViewModel.CurrentFolder.ItemPath); + BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem(context.ShellPage?.FilesystemViewModel.CurrentFolder.ItemPath); BaseStorageFolder destinationFolder = null; if (archive?.Path is null) diff --git a/src/Files.App/Actions/Content/Background/BaseSetAsAction.cs b/src/Files.App/Actions/Content/Background/BaseSetAsAction.cs index 3af2b64f1ff9..d4239457c320 100644 --- a/src/Files.App/Actions/Content/Background/BaseSetAsAction.cs +++ b/src/Files.App/Actions/Content/Background/BaseSetAsAction.cs @@ -17,7 +17,7 @@ internal abstract class BaseSetAsAction : ObservableObject, IAction context.ShellPage is not null && context.PageType != ContentPageTypes.RecycleBin && context.PageType != ContentPageTypes.ZipFolder && - (context.ShellPage?.LayoutPage?.SelectedItemsPropertiesViewModel?.IsCompatibleToSetAsWindowsWallpaper ?? false); + (context.ShellPage?.SlimContentPage?.SelectedItemsPropertiesViewModel?.IsCompatibleToSetAsWindowsWallpaper ?? false); public BaseSetAsAction() { @@ -38,9 +38,9 @@ private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) case nameof(IContentPageContext.SelectedItem): case nameof(IContentPageContext.SelectedItems): { - if (context.ShellPage is not null && context.ShellPage.LayoutPage is not null) + if (context.ShellPage is not null && context.ShellPage.SlimContentPage is not null) { - var viewModel = context.ShellPage.LayoutPage.SelectedItemsPropertiesViewModel; + var viewModel = context.ShellPage.SlimContentPage.SelectedItemsPropertiesViewModel; var extensions = context.SelectedItems.Select(selectedItem => selectedItem.FileExtension).Distinct().ToList(); viewModel.CheckAllFileExtensions(extensions); diff --git a/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs b/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs index 6c2e5cea5660..eead57e36a66 100644 --- a/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs +++ b/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs @@ -21,7 +21,7 @@ internal abstract class BaseRotateAction : ObservableObject, IAction public bool IsExecutable => IsContextPageTypeAdaptedToCommand() && - (context.ShellPage?.LayoutPage?.SelectedItemsPropertiesViewModel?.IsCompatibleToSetAsWindowsWallpaper ?? false); + (context.ShellPage?.SlimContentPage?.SelectedItemsPropertiesViewModel?.IsCompatibleToSetAsWindowsWallpaper ?? false); public BaseRotateAction() { @@ -35,7 +35,7 @@ public async Task ExecuteAsync(object? parameter = null) { await Task.WhenAll(context.SelectedItems.Select(image => BitmapHelper.RotateAsync(PathNormalization.NormalizePath(image.ItemPath), Rotation))); - context.ShellPage?.LayoutPage?.ItemManipulationModel?.RefreshItemsThumbnail(); + context.ShellPage?.SlimContentPage?.ItemManipulationModel?.RefreshItemsThumbnail(); await _infoPaneViewModel.UpdateSelectedItemPreviewAsync(); } @@ -52,9 +52,9 @@ private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName is nameof(IContentPageContext.SelectedItem)) { - if (context.ShellPage is not null && context.ShellPage.LayoutPage is not null) + if (context.ShellPage is not null && context.ShellPage.SlimContentPage is not null) { - var viewModel = context.ShellPage.LayoutPage.SelectedItemsPropertiesViewModel; + var viewModel = context.ShellPage.SlimContentPage.SelectedItemsPropertiesViewModel; var extensions = context.SelectedItems.Select(selectedItem => selectedItem.FileExtension).Distinct().ToList(); viewModel.CheckAllFileExtensions(extensions); diff --git a/src/Files.App/Actions/Content/PreviewPopup/LaunchPreviewPopupAction.cs b/src/Files.App/Actions/Content/PreviewPopup/LaunchPreviewPopupAction.cs index 7ef70fa0298e..e78e93474ddc 100644 --- a/src/Files.App/Actions/Content/PreviewPopup/LaunchPreviewPopupAction.cs +++ b/src/Files.App/Actions/Content/PreviewPopup/LaunchPreviewPopupAction.cs @@ -20,8 +20,8 @@ public HotKey HotKey public bool IsExecutable => context.SelectedItems.Count == 1 && - (!context.ShellPage?.AddressToolbarViewModel?.IsEditModeEnabled ?? false) && - (!context.ShellPage?.LayoutPage?.IsRenamingItem ?? false); + (!context.ShellPage?.ToolbarViewModel?.IsEditModeEnabled ?? false) && + (!context.ShellPage?.SlimContentPage?.IsRenamingItem ?? false); public LaunchPreviewPopupAction() { diff --git a/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs b/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs index 2dac1b004f4a..bd4029c31c5c 100644 --- a/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs +++ b/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs @@ -31,7 +31,7 @@ public RunWithPowershellAction() public Task ExecuteAsync(object? parameter = null) { - return Win32Helper.RunPowershellCommandAsync($"{context.ShellPage?.LayoutPage?.SelectedItem?.ItemPath}", false); + return Win32Helper.RunPowershellCommandAsync($"{context.ShellPage?.SlimContentPage?.SelectedItem?.ItemPath}", false); } private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) diff --git a/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs b/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs index 8fc9bfe365b3..e0eb0e783bd3 100644 --- a/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs +++ b/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs @@ -30,9 +30,9 @@ public bool IsExecutable if (page is null) return false; - bool isCommandPaletteOpen = page.AddressToolbarViewModel.IsCommandPaletteOpen; - bool isEditing = page.AddressToolbarViewModel.IsEditModeEnabled; - bool isRenaming = page.LayoutPage.IsRenamingItem; + bool isCommandPaletteOpen = page.ToolbarViewModel.IsCommandPaletteOpen; + bool isEditing = page.ToolbarViewModel.IsEditModeEnabled; + bool isRenaming = page.SlimContentPage.IsRenamingItem; return isCommandPaletteOpen || (!isEditing && !isRenaming); } @@ -45,7 +45,7 @@ public ClearSelectionAction() public Task ExecuteAsync(object? parameter = null) { - context.ShellPage?.LayoutPage?.ItemManipulationModel?.ClearSelection(); + context.ShellPage?.SlimContentPage?.ItemManipulationModel?.ClearSelection(); return Task.CompletedTask; } diff --git a/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs b/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs index 9509f057824d..4558204c0476 100644 --- a/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs +++ b/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs @@ -30,9 +30,9 @@ public bool IsExecutable if (page is null) return false; - bool isCommandPaletteOpen = page.AddressToolbarViewModel.IsCommandPaletteOpen; - bool isEditing = page.AddressToolbarViewModel.IsEditModeEnabled; - bool isRenaming = page.LayoutPage.IsRenamingItem; + bool isCommandPaletteOpen = page.ToolbarViewModel.IsCommandPaletteOpen; + bool isEditing = page.ToolbarViewModel.IsEditModeEnabled; + bool isRenaming = page.SlimContentPage.IsRenamingItem; return isCommandPaletteOpen || (!isEditing && !isRenaming); } @@ -45,7 +45,7 @@ public InvertSelectionAction() public Task ExecuteAsync(object? parameter = null) { - context?.ShellPage?.LayoutPage?.ItemManipulationModel?.InvertSelection(); + context?.ShellPage?.SlimContentPage?.ItemManipulationModel?.InvertSelection(); return Task.CompletedTask; } diff --git a/src/Files.App/Actions/Content/Selection/SelectAllAction.cs b/src/Files.App/Actions/Content/Selection/SelectAllAction.cs index 359802ef8dab..dc10151fd933 100644 --- a/src/Files.App/Actions/Content/Selection/SelectAllAction.cs +++ b/src/Files.App/Actions/Content/Selection/SelectAllAction.cs @@ -30,14 +30,14 @@ public bool IsExecutable if (page is null) return false; - int itemCount = page.ShellViewModel.FilesAndFolders.Count; + int itemCount = page.FilesystemViewModel.FilesAndFolders.Count; int selectedItemCount = context.SelectedItems.Count; if (itemCount == selectedItemCount) return false; - bool isCommandPaletteOpen = page.AddressToolbarViewModel.IsCommandPaletteOpen; - bool isEditing = page.AddressToolbarViewModel.IsEditModeEnabled; - bool isRenaming = page.LayoutPage?.IsRenamingItem ?? false; + bool isCommandPaletteOpen = page.ToolbarViewModel.IsCommandPaletteOpen; + bool isEditing = page.ToolbarViewModel.IsEditModeEnabled; + bool isRenaming = page.SlimContentPage?.IsRenamingItem ?? false; return isCommandPaletteOpen || (!isEditing && !isRenaming); } @@ -50,7 +50,7 @@ public SelectAllAction() public Task ExecuteAsync(object? parameter = null) { - context.ShellPage?.LayoutPage?.ItemManipulationModel?.SelectAllItems(); + context.ShellPage?.SlimContentPage?.ItemManipulationModel?.SelectAllItems(); return Task.CompletedTask; } diff --git a/src/Files.App/Actions/FileSystem/BaseDeleteAction.cs b/src/Files.App/Actions/FileSystem/BaseDeleteAction.cs index a564bc705c11..bbb385287a92 100644 --- a/src/Files.App/Actions/FileSystem/BaseDeleteAction.cs +++ b/src/Files.App/Actions/FileSystem/BaseDeleteAction.cs @@ -13,7 +13,7 @@ internal abstract class BaseDeleteAction : BaseUIAction public override bool IsExecutable => context.HasSelection && - (!context.ShellPage?.LayoutPage?.IsRenamingItem ?? false) && + (!context.ShellPage?.SlimContentPage?.IsRenamingItem ?? false) && UIHelpers.CanShowDialog; public BaseDeleteAction() @@ -37,7 +37,7 @@ item.PrimaryItemAttribute is StorageItemTypes.File if (context.ShellPage is IShellPage shellPage) { await shellPage.FilesystemHelpers.DeleteItemsAsync(items, settings.DeleteConfirmationPolicy, permanently, true); - await shellPage.ShellViewModel.ApplyFilesAndFoldersChangesAsync(); + await shellPage.FilesystemViewModel.ApplyFilesAndFoldersChangesAsync(); } } diff --git a/src/Files.App/Actions/FileSystem/CopyPathAction.cs b/src/Files.App/Actions/FileSystem/CopyPathAction.cs index 9b291da33dd2..19a7fa955566 100644 --- a/src/Files.App/Actions/FileSystem/CopyPathAction.cs +++ b/src/Files.App/Actions/FileSystem/CopyPathAction.cs @@ -31,11 +31,11 @@ public CopyPathAction() public Task ExecuteAsync(object? parameter = null) { - if (context.ShellPage?.LayoutPage is not null) + if (context.ShellPage?.SlimContentPage is not null) { - var path = context.ShellPage.LayoutPage.SelectedItems is not null - ? context.ShellPage.LayoutPage.SelectedItems.Select(x => x.ItemPath).Aggregate((accum, current) => accum + "\n" + current) - : context.ShellPage.ShellViewModel.WorkingDirectory; + var path = context.ShellPage.SlimContentPage.SelectedItems is not null + ? context.ShellPage.SlimContentPage.SelectedItems.Select(x => x.ItemPath).Aggregate((accum, current) => accum + "\n" + current) + : context.ShellPage.FilesystemViewModel.WorkingDirectory; if (FtpHelpers.IsFtpPath(path)) path = path.Replace("\\", "/", StringComparison.Ordinal); diff --git a/src/Files.App/Actions/FileSystem/CopyPathWithQuotesAction.cs b/src/Files.App/Actions/FileSystem/CopyPathWithQuotesAction.cs index 1bd15138c1c7..957ec14765c0 100644 --- a/src/Files.App/Actions/FileSystem/CopyPathWithQuotesAction.cs +++ b/src/Files.App/Actions/FileSystem/CopyPathWithQuotesAction.cs @@ -31,12 +31,12 @@ public CopyPathWithQuotesAction() public Task ExecuteAsync(object? parameter = null) { - if (context.ShellPage?.LayoutPage is not null) + if (context.ShellPage?.SlimContentPage is not null) { - var selectedItems = context.ShellPage.LayoutPage.SelectedItems; + var selectedItems = context.ShellPage.SlimContentPage.SelectedItems; var path = selectedItems is not null ? string.Join("\n", selectedItems.Select(item => $"\"{item.ItemPath}\"")) - : context.ShellPage.ShellViewModel.WorkingDirectory; + : context.ShellPage.FilesystemViewModel.WorkingDirectory; if (FtpHelpers.IsFtpPath(path)) path = path.Replace("\\", "/", StringComparison.Ordinal); diff --git a/src/Files.App/Actions/FileSystem/OpenFileLocationAction.cs b/src/Files.App/Actions/FileSystem/OpenFileLocationAction.cs index 8e37acd1be0d..28090f560b95 100644 --- a/src/Files.App/Actions/FileSystem/OpenFileLocationAction.cs +++ b/src/Files.App/Actions/FileSystem/OpenFileLocationAction.cs @@ -32,7 +32,7 @@ public OpenFileLocationAction() public async Task ExecuteAsync(object? parameter = null) { - if (context.ShellPage?.ShellViewModel is null) + if (context.ShellPage?.FilesystemViewModel is null) return; var item = context.SelectedItem as ShortcutItem; @@ -42,7 +42,7 @@ public async Task ExecuteAsync(object? parameter = null) // Check if destination path exists var folderPath = Path.GetDirectoryName(item.TargetPath); - var destFolder = await context.ShellPage.ShellViewModel.GetFolderWithPathFromPathAsync(folderPath); + var destFolder = await context.ShellPage.FilesystemViewModel.GetFolderWithPathFromPathAsync(folderPath); if (destFolder) { diff --git a/src/Files.App/Actions/FileSystem/PasteItemAction.cs b/src/Files.App/Actions/FileSystem/PasteItemAction.cs index a89c0d5a59f1..4f9afe5bd2ea 100644 --- a/src/Files.App/Actions/FileSystem/PasteItemAction.cs +++ b/src/Files.App/Actions/FileSystem/PasteItemAction.cs @@ -43,7 +43,7 @@ public async Task ExecuteAsync(object? parameter = null) if (context.ShellPage is null) return; - string path = context.ShellPage.ShellViewModel.WorkingDirectory; + string path = context.ShellPage.FilesystemViewModel.WorkingDirectory; await UIFilesystemHelpers.PasteItemAsync(path, context.ShellPage); } diff --git a/src/Files.App/Actions/FileSystem/PasteItemToSelectionAction.cs b/src/Files.App/Actions/FileSystem/PasteItemToSelectionAction.cs index 337918038fb6..1c9611c3c053 100644 --- a/src/Files.App/Actions/FileSystem/PasteItemToSelectionAction.cs +++ b/src/Files.App/Actions/FileSystem/PasteItemToSelectionAction.cs @@ -37,7 +37,7 @@ public async Task ExecuteAsync(object? parameter = null) string path = context.SelectedItem is StandardStorageItem selectedItem ? selectedItem.ItemPath - : context.ShellPage.ShellViewModel.WorkingDirectory; + : context.ShellPage.FilesystemViewModel.WorkingDirectory; await UIFilesystemHelpers.PasteItemAsync(path, context.ShellPage); } diff --git a/src/Files.App/Actions/FileSystem/RenameAction.cs b/src/Files.App/Actions/FileSystem/RenameAction.cs index 2a317704d8cc..621b1266668b 100644 --- a/src/Files.App/Actions/FileSystem/RenameAction.cs +++ b/src/Files.App/Actions/FileSystem/RenameAction.cs @@ -22,7 +22,7 @@ public RichGlyph Glyph public bool IsExecutable => context.ShellPage is not null && IsPageTypeValid() && - context.ShellPage.LayoutPage is not null && + context.ShellPage.SlimContentPage is not null && IsSelectionValid(); public RenameAction() @@ -34,7 +34,7 @@ public RenameAction() public Task ExecuteAsync(object? parameter = null) { - context.ShellPage?.LayoutPage?.ItemManipulationModel.StartRenameItem(); + context.ShellPage?.SlimContentPage?.ItemManipulationModel.StartRenameItem(); return Task.CompletedTask; } diff --git a/src/Files.App/Actions/Global/EditPathAction.cs b/src/Files.App/Actions/Global/EditPathAction.cs index 469998f0f72c..cd02dfa97a90 100644 --- a/src/Files.App/Actions/Global/EditPathAction.cs +++ b/src/Files.App/Actions/Global/EditPathAction.cs @@ -27,7 +27,7 @@ public EditPathAction() public Task ExecuteAsync(object? parameter = null) { if (context.ShellPage is not null) - context.ShellPage.AddressToolbarViewModel.IsEditModeEnabled = true; + context.ShellPage.ToolbarViewModel.IsEditModeEnabled = true; return Task.CompletedTask; } diff --git a/src/Files.App/Actions/Global/SearchAction.cs b/src/Files.App/Actions/Global/SearchAction.cs index 2ef9a6749f6a..cf2bac0ee9a4 100644 --- a/src/Files.App/Actions/Global/SearchAction.cs +++ b/src/Files.App/Actions/Global/SearchAction.cs @@ -34,7 +34,7 @@ public SearchAction() public Task ExecuteAsync(object? parameter = null) { - context.ShellPage!.AddressToolbarViewModel.SwitchSearchBoxVisibility(); + context.ShellPage!.ToolbarViewModel.SwitchSearchBoxVisibility(); return Task.CompletedTask; } diff --git a/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs b/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs index 523e431e2095..e6f73a419648 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs @@ -33,7 +33,7 @@ public virtual Task ExecuteAsync(object? parameter = null) { NavigationHelpers.OpenInSecondaryPane( ContentPageContext.ShellPage, - ContentPageContext.ShellPage.LayoutPage.SelectedItems.FirstOrDefault()); + ContentPageContext.ShellPage.SlimContentPage.SelectedItems.FirstOrDefault()); return Task.CompletedTask; } diff --git a/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs b/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs index 9a9558a9e4bf..91d616e051e0 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs @@ -24,7 +24,7 @@ public virtual bool IsAccessibleGlobally public virtual bool IsExecutable => ContentPageContext.ShellPage is not null && - ContentPageContext.ShellPage.LayoutPage is not null && + ContentPageContext.ShellPage.SlimContentPage is not null && ContentPageContext.SelectedItems.Count is not 0 && ContentPageContext.SelectedItems.Count <= 5 && ContentPageContext.SelectedItems.Count(x => x.IsFolder) == ContentPageContext.SelectedItems.Count && diff --git a/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs b/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs index 00ab5d6a808b..ca76483c2270 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs @@ -29,7 +29,7 @@ public virtual bool IsAccessibleGlobally public virtual bool IsExecutable => ContentPageContext.ShellPage is not null && - ContentPageContext.ShellPage.LayoutPage is not null && + ContentPageContext.ShellPage.SlimContentPage is not null && ContentPageContext.SelectedItems.Count is not 0 && ContentPageContext.SelectedItems.Count <= 5 && ContentPageContext.SelectedItems.Count(x => x.IsFolder) == ContentPageContext.SelectedItems.Count && @@ -42,10 +42,10 @@ public BaseOpenInNewWindowAction() public virtual async Task ExecuteAsync(object? parameter = null) { - if (ContentPageContext.ShellPage?.LayoutPage?.SelectedItems is null) + if (ContentPageContext.ShellPage?.SlimContentPage?.SelectedItems is null) return; - List items = ContentPageContext.ShellPage.LayoutPage.SelectedItems; + List items = ContentPageContext.ShellPage.SlimContentPage.SelectedItems; foreach (StandardStorageItem listedItem in items) { diff --git a/src/Files.App/Actions/Open/OpenCommandPaletteAction.cs b/src/Files.App/Actions/Open/OpenCommandPaletteAction.cs index 5ece5b1179f1..4d61f1022bc9 100644 --- a/src/Files.App/Actions/Open/OpenCommandPaletteAction.cs +++ b/src/Files.App/Actions/Open/OpenCommandPaletteAction.cs @@ -23,7 +23,7 @@ public OpenCommandPaletteAction() public Task ExecuteAsync(object? parameter = null) { - _context.ShellPage?.AddressToolbarViewModel.OpenCommandPalette(); + _context.ShellPage?.ToolbarViewModel.OpenCommandPalette(); return Task.CompletedTask; } diff --git a/src/Files.App/Actions/Open/OpenInVSCodeAction.cs b/src/Files.App/Actions/Open/OpenInVSCodeAction.cs index a65e5b11eb00..5d6ede12f8e3 100644 --- a/src/Files.App/Actions/Open/OpenInVSCodeAction.cs +++ b/src/Files.App/Actions/Open/OpenInVSCodeAction.cs @@ -32,7 +32,7 @@ public OpenInVSCodeAction() public Task ExecuteAsync(object? parameter = null) { - return Win32Helper.RunPowershellCommandAsync($"code \'{_context.ShellPage?.ShellViewModel.WorkingDirectory}\'", false); + return Win32Helper.RunPowershellCommandAsync($"code \'{_context.ShellPage?.FilesystemViewModel.WorkingDirectory}\'", false); } private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) diff --git a/src/Files.App/Actions/Open/OpenPropertiesAction.cs b/src/Files.App/Actions/Open/OpenPropertiesAction.cs index 062c34e4fa2d..5628eafec65e 100644 --- a/src/Files.App/Actions/Open/OpenPropertiesAction.cs +++ b/src/Files.App/Actions/Open/OpenPropertiesAction.cs @@ -33,7 +33,7 @@ public OpenPropertiesAction() public Task ExecuteAsync(object? parameter = null) { - var page = context.ShellPage?.LayoutPage; + var page = context.ShellPage?.SlimContentPage; if (page?.ItemContextMenuFlyout.IsOpen ?? false) page.ItemContextMenuFlyout.Closed += OpenPropertiesFromItemContextMenuFlyout; @@ -47,7 +47,7 @@ public Task ExecuteAsync(object? parameter = null) private void OpenPropertiesFromItemContextMenuFlyout(object? _, object e) { - var page = context.ShellPage?.LayoutPage; + var page = context.ShellPage?.SlimContentPage; if (page is not null) page.ItemContextMenuFlyout.Closed -= OpenPropertiesFromItemContextMenuFlyout; @@ -56,7 +56,7 @@ private void OpenPropertiesFromItemContextMenuFlyout(object? _, object e) private void OpenPropertiesFromBaseContextMenuFlyout(object? _, object e) { - var page = context.ShellPage?.LayoutPage; + var page = context.ShellPage?.SlimContentPage; if (page is not null) page.BaseContextMenuFlyout.Closed -= OpenPropertiesFromBaseContextMenuFlyout; diff --git a/src/Files.App/Actions/Start/PinToStartAction.cs b/src/Files.App/Actions/Start/PinToStartAction.cs index cc98ec95c653..7d07e3c152b9 100644 --- a/src/Files.App/Actions/Start/PinToStartAction.cs +++ b/src/Files.App/Actions/Start/PinToStartAction.cs @@ -33,9 +33,9 @@ public PinToStartAction() public async Task ExecuteAsync(object? parameter = null) { - if (context.SelectedItems.Count > 0 && context.ShellPage?.LayoutPage?.SelectedItems is not null) + if (context.SelectedItems.Count > 0 && context.ShellPage?.SlimContentPage?.SelectedItems is not null) { - foreach (StandardStorageItem listedItem in context.ShellPage.LayoutPage.SelectedItems) + foreach (StandardStorageItem listedItem in context.ShellPage.SlimContentPage.SelectedItems) { IStorable storable = listedItem.IsFolder switch { @@ -45,9 +45,9 @@ public async Task ExecuteAsync(object? parameter = null) await StartMenuService.PinAsync(storable, listedItem.Name); } } - else if (context.ShellPage?.ShellViewModel?.CurrentFolder is not null) + else if (context.ShellPage?.FilesystemViewModel?.CurrentFolder is not null) { - var currentFolder = context.ShellPage.ShellViewModel.CurrentFolder; + var currentFolder = context.ShellPage.FilesystemViewModel.CurrentFolder; var folder = await StorageService.GetFolderAsync(currentFolder.ItemPath); await StartMenuService.PinAsync(folder, currentFolder.Name); diff --git a/src/Files.App/Actions/Start/UnpinFromStartAction.cs b/src/Files.App/Actions/Start/UnpinFromStartAction.cs index 5f152de3d781..dc757be96000 100644 --- a/src/Files.App/Actions/Start/UnpinFromStartAction.cs +++ b/src/Files.App/Actions/Start/UnpinFromStartAction.cs @@ -31,7 +31,7 @@ public async Task ExecuteAsync(object? parameter = null) { if (context.SelectedItems.Count > 0) { - foreach (StandardStorageItem listedItem in context.ShellPage?.LayoutPage.SelectedItems) + foreach (StandardStorageItem listedItem in context.ShellPage?.SlimContentPage.SelectedItems) { IStorable storable = listedItem.IsFolder switch { @@ -43,7 +43,7 @@ public async Task ExecuteAsync(object? parameter = null) } else { - var currentFolder = context.ShellPage.ShellViewModel.CurrentFolder; + var currentFolder = context.ShellPage.FilesystemViewModel.CurrentFolder; var folder = await StorageService.GetFolderAsync(currentFolder.ItemPath); await StartMenuService.UnpinAsync(folder); diff --git a/src/Files.App/App.xaml.cs b/src/Files.App/App.xaml.cs index ad4fa6fd9049..3e9cf91b98a1 100644 --- a/src/Files.App/App.xaml.cs +++ b/src/Files.App/App.xaml.cs @@ -216,7 +216,7 @@ private async void Window_Closed(object sender, WindowEventArgs args) if (instance is null) return; - var items = (instance.TabItemContent as ShellPanesPage)?.ActivePane?.LayoutPage?.SelectedItems; + var items = (instance.TabItemContent as ShellPanesPage)?.ActivePane?.SlimContentPage?.SelectedItems; if (items is null) return; diff --git a/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs b/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs index 32fa86f31746..c5da3c256a08 100644 --- a/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs +++ b/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs @@ -12,7 +12,7 @@ internal sealed class ContentPageContext : ObservableObject, IContentPageContext private readonly IMultiPanesContext context = Ioc.Default.GetRequiredService(); - private ShellViewModel? filesystemViewModel; + private ItemViewModel? filesystemViewModel; public IShellPage? ShellPage => context?.ActivePaneOrColumn; @@ -21,9 +21,9 @@ internal sealed class ContentPageContext : ObservableObject, IContentPageContext private ContentPageTypes pageType = ContentPageTypes.None; public ContentPageTypes PageType => pageType; - public StandardStorageItem? Folder => ShellPage?.ShellViewModel?.CurrentFolder; + public StandardStorageItem? Folder => ShellPage?.FilesystemViewModel?.CurrentFolder; - public bool HasItem => ShellPage?.AddressToolbarViewModel?.HasItem ?? false; + public bool HasItem => ShellPage?.ToolbarViewModel?.HasItem ?? false; public bool HasSelection => SelectedItems.Count is not 0; public StandardStorageItem? SelectedItem => SelectedItems.Count is 1 ? SelectedItems[0] : null; @@ -31,15 +31,15 @@ internal sealed class ContentPageContext : ObservableObject, IContentPageContext private IReadOnlyList selectedItems = emptyItems; public IReadOnlyList SelectedItems => selectedItems; - public bool CanRefresh => ShellPage is not null && ShellPage.AddressToolbarViewModel.CanRefresh; + public bool CanRefresh => ShellPage is not null && ShellPage.ToolbarViewModel.CanRefresh; - public bool CanGoBack => ShellPage is not null && ShellPage.AddressToolbarViewModel.CanGoBack; + public bool CanGoBack => ShellPage is not null && ShellPage.ToolbarViewModel.CanGoBack; - public bool CanGoForward => ShellPage is not null && ShellPage.AddressToolbarViewModel.CanGoForward; + public bool CanGoForward => ShellPage is not null && ShellPage.ToolbarViewModel.CanGoForward; - public bool CanNavigateToParent => ShellPage is not null && ShellPage.AddressToolbarViewModel.CanNavigateToParent; + public bool CanNavigateToParent => ShellPage is not null && ShellPage.ToolbarViewModel.CanNavigateToParent; - public bool IsSearchBoxVisible => ShellPage is not null && ShellPage.AddressToolbarViewModel.IsSearchBoxVisible; + public bool IsSearchBoxVisible => ShellPage is not null && ShellPage.ToolbarViewModel.IsSearchBoxVisible; public bool CanCreateItem => GetCanCreateItem(); @@ -51,7 +51,7 @@ internal sealed class ContentPageContext : ObservableObject, IContentPageContext public bool CanExecuteGitAction => IsGitRepository && !GitHelpers.IsExecutingGitAction; - public string? SolutionFilePath => ShellPage?.ShellViewModel?.SolutionFilePath; + public string? SolutionFilePath => ShellPage?.FilesystemViewModel?.SolutionFilePath; public ContentPageContext() { @@ -74,7 +74,7 @@ private void Context_Changing(object? sender, EventArgs e) page.PropertyChanged -= Page_PropertyChanged; page.ContentChanged -= Page_ContentChanged; page.InstanceViewModel.PropertyChanged -= InstanceViewModel_PropertyChanged; - page.AddressToolbarViewModel.PropertyChanged -= ToolbarViewModel_PropertyChanged; + page.ToolbarViewModel.PropertyChanged -= ToolbarViewModel_PropertyChanged; if (page.PaneHolder is not null) page.PaneHolder.PropertyChanged -= PaneHolder_PropertyChanged; @@ -93,13 +93,13 @@ private void Context_Changed(object? sender, EventArgs e) page.PropertyChanged += Page_PropertyChanged; page.ContentChanged += Page_ContentChanged; page.InstanceViewModel.PropertyChanged += InstanceViewModel_PropertyChanged; - page.AddressToolbarViewModel.PropertyChanged += ToolbarViewModel_PropertyChanged; + page.ToolbarViewModel.PropertyChanged += ToolbarViewModel_PropertyChanged; if (page.PaneHolder is not null) page.PaneHolder.PropertyChanged += PaneHolder_PropertyChanged; } - filesystemViewModel = ShellPage?.ShellViewModel; + filesystemViewModel = ShellPage?.FilesystemViewModel; if (filesystemViewModel is not null) filesystemViewModel.PropertyChanged += FilesystemViewModel_PropertyChanged; @@ -178,10 +178,10 @@ private void FilesystemViewModel_PropertyChanged(object? sender, PropertyChanged { switch (e.PropertyName) { - case nameof(ShellViewModel.CurrentFolder): + case nameof(ItemViewModel.CurrentFolder): OnPropertyChanged(nameof(Folder)); break; - case nameof(ShellViewModel.SolutionFilePath): + case nameof(ItemViewModel.SolutionFilePath): OnPropertyChanged(nameof(SolutionFilePath)); break; } @@ -228,7 +228,7 @@ private void UpdateSelectedItems() bool oldHasSelection = HasSelection; StandardStorageItem? oldSelectedItem = SelectedItem; - IReadOnlyList items = ShellPage?.AddressToolbarViewModel?.SelectedItems?.AsReadOnly() ?? emptyItems; + IReadOnlyList items = ShellPage?.ToolbarViewModel?.SelectedItems?.AsReadOnly() ?? emptyItems; if (SetProperty(ref selectedItems, items, nameof(SelectedItems))) { if (HasSelection != oldHasSelection) diff --git a/src/Files.App/Data/Contracts/IShellPage.cs b/src/Files.App/Data/Contracts/IShellPage.cs index f6faa3986b36..57256fef21a5 100644 --- a/src/Files.App/Data/Contracts/IShellPage.cs +++ b/src/Files.App/Data/Contracts/IShellPage.cs @@ -5,19 +5,19 @@ namespace Files.App.Data.Contracts { public interface IShellPage : ITabBarItemContent, IMultiPaneInfo, IDisposable, INotifyPropertyChanged { - ShellViewModel ShellViewModel { get; } + ItemViewModel FilesystemViewModel { get; } CurrentInstanceViewModel InstanceViewModel { get; } StorageHistoryHelpers StorageHistoryHelpers { get; } - IBaseLayoutPage LayoutPage { get; } + IBaseLayoutPage SlimContentPage { get; } Type CurrentPageType { get; } IFilesystemHelpers FilesystemHelpers { get; } - AddressToolbarViewModel AddressToolbarViewModel { get; } + AddressToolbarViewModel ToolbarViewModel { get; } bool CanNavigateBackward { get; } diff --git a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs index 137e0d9c071f..37559f4ab67c 100644 --- a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs +++ b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs @@ -24,7 +24,7 @@ public static class ContentPageContextFlyoutFactory private static readonly ICommandManager Commands = Ioc.Default.GetRequiredService(); private static IStorageArchiveService StorageArchiveService { get; } = Ioc.Default.GetRequiredService(); - public static List GetItemContextCommandsWithoutShellItems(CurrentInstanceViewModel currentInstanceViewModel, List selectedItems, BaseLayoutViewModel commandsViewModel, bool shiftPressed, SelectedItemsPropertiesViewModel? selectedItemsPropertiesViewModel, ShellViewModel? itemViewModel = null) + public static List GetItemContextCommandsWithoutShellItems(CurrentInstanceViewModel currentInstanceViewModel, List selectedItems, BaseLayoutViewModel commandsViewModel, bool shiftPressed, SelectedItemsPropertiesViewModel? selectedItemsPropertiesViewModel, ItemViewModel? itemViewModel = null) { var menuItemsList = GetBaseItemMenuItems(commandsViewModel: commandsViewModel, selectedItems: selectedItems, selectedItemsPropertiesViewModel: selectedItemsPropertiesViewModel, currentInstanceViewModel: currentInstanceViewModel, itemViewModel: itemViewModel); menuItemsList = Filter(items: menuItemsList, shiftPressed: shiftPressed, currentInstanceViewModel: currentInstanceViewModel, selectedItems: selectedItems, removeOverflowMenu: false); @@ -80,7 +80,7 @@ public static List GetBaseItemMenuItems( SelectedItemsPropertiesViewModel? selectedItemsPropertiesViewModel, List selectedItems, CurrentInstanceViewModel currentInstanceViewModel, - ShellViewModel? itemViewModel = null) + ItemViewModel? itemViewModel = null) { bool itemsSelected = itemViewModel is null; bool canDecompress = selectedItems.Any() && selectedItems.All(x => x.IsArchive) diff --git a/src/Files.App/ViewModels/ShellViewModel.cs b/src/Files.App/Data/Models/ItemViewModel.cs similarity index 99% rename from src/Files.App/ViewModels/ShellViewModel.cs rename to src/Files.App/Data/Models/ItemViewModel.cs index a5164a82ff67..ff6c31394413 100644 --- a/src/Files.App/ViewModels/ShellViewModel.cs +++ b/src/Files.App/Data/Models/ItemViewModel.cs @@ -23,9 +23,9 @@ using DispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue; using FileAttributes = System.IO.FileAttributes; -namespace Files.App.ViewModels +namespace Files.App.Data.Models { - public sealed class ShellViewModel : ObservableObject, IDisposable + public sealed class ItemViewModel : ObservableObject, IDisposable { private readonly SemaphoreSlim enumFolderSemaphore; private readonly SemaphoreSlim getFileOrFolderSemaphore; @@ -470,7 +470,7 @@ public bool AreFilesSortedFirst public bool HasNoWatcher { get; private set; } - public ShellViewModel(LayoutPreferencesManager folderSettingsViewModel) + public ItemViewModel(LayoutPreferencesManager folderSettingsViewModel) { folderSettings = folderSettingsViewModel; filesAndFolders = []; diff --git a/src/Files.App/Extensions/ShellNewEntryExtensions.cs b/src/Files.App/Extensions/ShellNewEntryExtensions.cs index 3688bac70833..ed697800a589 100644 --- a/src/Files.App/Extensions/ShellNewEntryExtensions.cs +++ b/src/Files.App/Extensions/ShellNewEntryExtensions.cs @@ -36,7 +36,7 @@ public static async Task> GetNewContextMenuEntries() public static async Task> Create(this ShellNewEntry shellEntry, string filePath, IShellPage associatedInstance) { - var parentFolder = await associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(filePath)); + var parentFolder = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(filePath)); if (parentFolder) { return await Create(shellEntry, parentFolder, filePath); diff --git a/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs b/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs index 4c3b6af8c7ec..12961015584c 100644 --- a/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs +++ b/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs @@ -324,7 +324,7 @@ public static DynamicDialog GetFor_RenameRequiresHigherPermissions(string path) SecondaryButtonAction = (vm, e) => { var context = Ioc.Default.GetRequiredService(); - var item = context.ShellPage?.ShellViewModel.FilesAndFolders.FirstOrDefault(li => li.ItemPath.Equals(path)); + var item = context.ShellPage?.FilesystemViewModel.FilesAndFolders.FirstOrDefault(li => li.ItemPath.Equals(path)); if (context.ShellPage is not null && item is not null) FilePropertiesHelpers.OpenPropertiesWindow(item, context.ShellPage, PropertiesNavigationViewItemType.Security); diff --git a/src/Files.App/Helpers/Navigation/NavigationHelpers.cs b/src/Files.App/Helpers/Navigation/NavigationHelpers.cs index d29dbcdf0b7a..21076cf1de37 100644 --- a/src/Files.App/Helpers/Navigation/NavigationHelpers.cs +++ b/src/Files.App/Helpers/Navigation/NavigationHelpers.cs @@ -277,14 +277,14 @@ public static Task LaunchNewWindowAsync() public static async Task OpenSelectedItemsAsync(IShellPage associatedInstance, bool openViaApplicationPicker = false) { // Don't open files and folders inside recycle bin - if (associatedInstance.ShellViewModel.WorkingDirectory.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal) || - associatedInstance.LayoutPage?.SelectedItems is null) + if (associatedInstance.FilesystemViewModel.WorkingDirectory.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal) || + associatedInstance.SlimContentPage?.SelectedItems is null) { return; } var forceOpenInNewTab = false; - var selectedItems = associatedInstance.LayoutPage.SelectedItems.ToList(); + var selectedItems = associatedInstance.SlimContentPage.SelectedItems.ToList(); var opened = false; // If multiple files are selected, open them together @@ -314,8 +314,8 @@ public static async Task OpenSelectedItemsAsync(IShellPage associatedInstance, b public static async Task OpenItemsWithExecutableAsync(IShellPage associatedInstance, IEnumerable items, string executablePath) { // Don't open files and folders inside recycle bin - if (associatedInstance.ShellViewModel.WorkingDirectory.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal) || - associatedInstance.LayoutPage is null) + if (associatedInstance.FilesystemViewModel.WorkingDirectory.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal) || + associatedInstance.SlimContentPage is null) return; var arguments = string.Join(" ", items.Select(item => $"\"{item.Path}\"")); @@ -334,7 +334,7 @@ public static async Task OpenItemsWithExecutableAsync(IShellPage associatedInsta /// Open folders in a new tab regardless of the "OpenFoldersInNewTab" option public static async Task OpenPath(string path, IShellPage associatedInstance, FilesystemItemType? itemType = null, bool openSilent = false, bool openViaApplicationPicker = false, IEnumerable? selectItems = null, string? args = default, bool forceOpenInNewTab = false) { - string previousDir = associatedInstance.ShellViewModel.WorkingDirectory; + string previousDir = associatedInstance.FilesystemViewModel.WorkingDirectory; bool isHiddenItem = Win32Helper.HasFileAttribute(path, System.IO.FileAttributes.Hidden); bool isDirectory = Win32Helper.HasFileAttribute(path, System.IO.FileAttributes.Directory); bool isReparsePoint = Win32Helper.HasFileAttribute(path, System.IO.FileAttributes.ReparsePoint); @@ -430,8 +430,8 @@ public static async Task OpenPath(string path, IShellPage associatedInstan if (opened.ErrorCode == FileSystemStatusCode.NotFound && !openSilent) { await DialogDisplayHelper.ShowDialogAsync("FileNotFoundDialog/Title".GetLocalizedResource(), "FileNotFoundDialog/Text".GetLocalizedResource()); - associatedInstance.AddressToolbarViewModel.CanRefresh = false; - associatedInstance.ShellViewModel?.RefreshItems(previousDir); + associatedInstance.ToolbarViewModel.CanRefresh = false; + associatedInstance.FilesystemViewModel?.RefreshItems(previousDir); } return opened; @@ -485,7 +485,7 @@ private static async Task OpenDirectory(string path, IShellPag } else { - opened = await associatedInstance.ShellViewModel.GetFolderWithPathFromPathAsync(path) + opened = await associatedInstance.FilesystemViewModel.GetFolderWithPathFromPathAsync(path) .OnSuccess((childFolder) => { // Add location to Recent Items List @@ -519,7 +519,7 @@ private static async Task OpenFile(string path, IShellPage ass { if (!FileExtensionHelpers.IsWebLinkFile(path)) { - StorageFileWithPath childFile = await associatedInstance.ShellViewModel.GetFileWithPathFromPathAsync(shortcutInfo.TargetPath); + StorageFileWithPath childFile = await associatedInstance.FilesystemViewModel.GetFileWithPathFromPathAsync(shortcutInfo.TargetPath); // Add location to Recent Items List if (childFile?.Item is SystemStorageFile) App.RecentItemsManager.AddToRecentItems(childFile.Path); @@ -534,7 +534,7 @@ private static async Task OpenFile(string path, IShellPage ass } else { - opened = await associatedInstance.ShellViewModel.GetFileWithPathFromPathAsync(path) + opened = await associatedInstance.FilesystemViewModel.GetFileWithPathFromPathAsync(path) .OnSuccess(async childFile => { // Add location to Recent Items List @@ -558,7 +558,7 @@ private static async Task OpenFile(string path, IShellPage ass BaseStorageFileQueryResult? fileQueryResult = null; //Get folder to create a file query (to pass to apps like Photos, Movies & TV..., needed to scroll through the folder like what Windows Explorer does) - BaseStorageFolder currentFolder = await associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(path)); + BaseStorageFolder currentFolder = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(path)); if (currentFolder is not null) { @@ -655,7 +655,7 @@ private static async Task OpenPathAsync(bool forceOpenInNewTab, bool openFolderI } else { - associatedInstance.AddressToolbarViewModel.PathControlDisplayText = text; + associatedInstance.ToolbarViewModel.PathControlDisplayText = text; associatedInstance.NavigateWithArguments(associatedInstance.InstanceViewModel.FolderSettings.GetLayoutType(path), new NavigationArguments() { NavPathParam = path, diff --git a/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs b/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs index 05a9abc02ae9..e45b930f92ff 100644 --- a/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs +++ b/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs @@ -27,12 +27,12 @@ public static async Task CutItemAsync(IShellPage associatedInstance) }; ConcurrentBag items = []; - if (associatedInstance.LayoutPage.IsItemSelected) + if (associatedInstance.SlimContentPage.IsItemSelected) { // First, reset DataGrid Rows that may be in "cut" command mode - associatedInstance.LayoutPage.ItemManipulationModel.RefreshItemsOpacity(); + associatedInstance.SlimContentPage.ItemManipulationModel.RefreshItemsOpacity(); - var itemsCount = associatedInstance.LayoutPage.SelectedItems!.Count; + var itemsCount = associatedInstance.SlimContentPage.SelectedItems!.Count; var banner = itemsCount > 50 ? StatusCenterHelper.AddCard_Prepare() : null; @@ -46,7 +46,7 @@ public static async Task CutItemAsync(IShellPage associatedInstance) banner.Progress.ReportStatus(FileSystemStatusCode.InProgress); } - await associatedInstance.LayoutPage.SelectedItems.ToList().ParallelForEachAsync(async listedItem => + await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachAsync(async listedItem => { if (banner is not null) { @@ -70,7 +70,7 @@ await associatedInstance.LayoutPage.SelectedItems.ToList().ParallelForEachAsync( } else if (listedItem.PrimaryItemAttribute == StorageItemTypes.File || listedItem is ZipItem) { - var result = await associatedInstance.ShellViewModel.GetFileFromPathAsync(listedItem.ItemPath) + var result = await associatedInstance.FilesystemViewModel.GetFileFromPathAsync(listedItem.ItemPath) .OnSuccess(t => items.Add(t)); if (!result) @@ -78,7 +78,7 @@ await associatedInstance.LayoutPage.SelectedItems.ToList().ParallelForEachAsync( } else { - var result = await associatedInstance.ShellViewModel.GetFolderFromPathAsync(listedItem.ItemPath) + var result = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(listedItem.ItemPath) .OnSuccess(t => items.Add(t)); if (!result) @@ -90,7 +90,7 @@ await associatedInstance.LayoutPage.SelectedItems.ToList().ParallelForEachAsync( { if (ex.HResult == (int)FileSystemStatusCode.Unauthorized) { - string[] filePaths = associatedInstance.LayoutPage.SelectedItems.Select(x => x.ItemPath).ToArray(); + string[] filePaths = associatedInstance.SlimContentPage.SelectedItems.Select(x => x.ItemPath).ToArray(); await FileOperationsHelpers.SetClipboard(filePaths, DataPackageOperation.Move); @@ -99,7 +99,7 @@ await associatedInstance.LayoutPage.SelectedItems.ToList().ParallelForEachAsync( return; } - associatedInstance.LayoutPage.ItemManipulationModel.RefreshItemsOpacity(); + associatedInstance.SlimContentPage.ItemManipulationModel.RefreshItemsOpacity(); _statusCenterViewModel.RemoveItem(banner); @@ -136,11 +136,11 @@ public static async Task CopyItemAsync(IShellPage associatedInstance) }; ConcurrentBag items = []; - if (associatedInstance.LayoutPage.IsItemSelected) + if (associatedInstance.SlimContentPage.IsItemSelected) { - associatedInstance.LayoutPage.ItemManipulationModel.RefreshItemsOpacity(); + associatedInstance.SlimContentPage.ItemManipulationModel.RefreshItemsOpacity(); - var itemsCount = associatedInstance.LayoutPage.SelectedItems!.Count; + var itemsCount = associatedInstance.SlimContentPage.SelectedItems!.Count; var banner = itemsCount > 50 ? StatusCenterHelper.AddCard_Prepare() : null; @@ -152,7 +152,7 @@ public static async Task CopyItemAsync(IShellPage associatedInstance) banner.Progress.ItemsCount = items.Count; banner.Progress.ReportStatus(FileSystemStatusCode.InProgress); } - await associatedInstance.LayoutPage.SelectedItems.ToList().ParallelForEachAsync(async listedItem => + await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachAsync(async listedItem => { if (banner is not null) { @@ -167,7 +167,7 @@ await associatedInstance.LayoutPage.SelectedItems.ToList().ParallelForEachAsync( } else if (listedItem.PrimaryItemAttribute == StorageItemTypes.File || listedItem is ZipItem) { - var result = await associatedInstance.ShellViewModel.GetFileFromPathAsync(listedItem.ItemPath) + var result = await associatedInstance.FilesystemViewModel.GetFileFromPathAsync(listedItem.ItemPath) .OnSuccess(t => items.Add(t)); if (!result) @@ -175,7 +175,7 @@ await associatedInstance.LayoutPage.SelectedItems.ToList().ParallelForEachAsync( } else { - var result = await associatedInstance.ShellViewModel.GetFolderFromPathAsync(listedItem.ItemPath) + var result = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(listedItem.ItemPath) .OnSuccess(t => items.Add(t)); if (!result) @@ -187,7 +187,7 @@ await associatedInstance.LayoutPage.SelectedItems.ToList().ParallelForEachAsync( { if (ex.HResult == (int)FileSystemStatusCode.Unauthorized) { - string[] filePaths = associatedInstance.LayoutPage.SelectedItems.Select(x => x.ItemPath).ToArray(); + string[] filePaths = associatedInstance.SlimContentPage.SelectedItems.Select(x => x.ItemPath).ToArray(); await FileOperationsHelpers.SetClipboard(filePaths, DataPackageOperation.Copy); @@ -230,7 +230,7 @@ public static async Task PasteItemAsync(string destinationPath, IShellPage assoc if (packageView && packageView.Result is not null) { await associatedInstance.FilesystemHelpers.PerformOperationTypeAsync(packageView.Result.RequestedOperation, packageView, destinationPath, false, true); - associatedInstance.LayoutPage?.ItemManipulationModel?.RefreshItemsOpacity(); + associatedInstance.SlimContentPage?.ItemManipulationModel?.RefreshItemsOpacity(); await associatedInstance.RefreshIfNoWatcherExistsAsync(); } } @@ -263,7 +263,7 @@ public static async Task RenameFileItemAsync(StandardStorageItem item, str if (renamed == ReturnResult.Success) { - associatedInstance.AddressToolbarViewModel.CanGoForward = false; + associatedInstance.ToolbarViewModel.CanGoForward = false; await associatedInstance.RefreshIfNoWatcherExistsAsync(); return true; } @@ -281,9 +281,9 @@ public static async Task CreateFileFromDialogResultTypeAsync(AddItemDialogItemTy { string? currentPath = null; - if (associatedInstance.LayoutPage is not null) + if (associatedInstance.SlimContentPage is not null) { - currentPath = associatedInstance.ShellViewModel.WorkingDirectory; + currentPath = associatedInstance.FilesystemViewModel.WorkingDirectory; if (App.LibraryManager.TryGetLibrary(currentPath, out var library) && !library.IsEmpty && library.Folders.Count == 1) // TODO: handle libraries with multiple folders @@ -343,7 +343,7 @@ public static async Task CreateFolderWithSelectionAsync(IShellPage associatedIns { try { - var items = associatedInstance.LayoutPage.SelectedItems.ToList().Select((item) => StorageHelpers.FromPathAndType( + var items = associatedInstance.SlimContentPage.SelectedItems.ToList().Select((item) => StorageHelpers.FromPathAndType( item.ItemPath, item.PrimaryItemAttribute == StorageItemTypes.File ? FilesystemItemType.File : FilesystemItemType.Directory)); var folder = await CreateFileFromDialogResultTypeForResult(AddItemDialogItemType.Folder, null, associatedInstance); @@ -373,7 +373,7 @@ public static void SetHiddenAttributeItem(StandardStorageItem item, bool isHidde public static async Task CreateShortcutAsync(IShellPage? associatedInstance, IReadOnlyList selectedItems) { - var currentPath = associatedInstance?.ShellViewModel.WorkingDirectory; + var currentPath = associatedInstance?.FilesystemViewModel.WorkingDirectory; if (App.LibraryManager.TryGetLibrary(currentPath ?? string.Empty, out var library) && !library.IsEmpty) currentPath = library.DefaultSaveFolder; @@ -393,7 +393,7 @@ public static async Task CreateShortcutAsync(IShellPage? associatedInstance, IRe public static async Task CreateShortcutFromDialogAsync(IShellPage associatedInstance) { - var currentPath = associatedInstance.ShellViewModel.WorkingDirectory; + var currentPath = associatedInstance.FilesystemViewModel.WorkingDirectory; if (App.LibraryManager.TryGetLibrary(currentPath, out var library) && !library.IsEmpty) { diff --git a/src/Files.App/Helpers/Win32/Win32Helper.Process.cs b/src/Files.App/Helpers/Win32/Win32Helper.Process.cs index f4e0feb9f228..46d3dc99e50c 100644 --- a/src/Files.App/Helpers/Win32/Win32Helper.Process.cs +++ b/src/Files.App/Helpers/Win32/Win32Helper.Process.cs @@ -50,13 +50,13 @@ public static async Task InvokeWin32ComponentsAsync(IEnumerable ap if (string.IsNullOrEmpty(workingDirectory)) { - workingDirectory = associatedInstance.ShellViewModel.WorkingDirectory; + workingDirectory = associatedInstance.FilesystemViewModel.WorkingDirectory; } var application = applicationPaths.FirstOrDefault(); if (string.IsNullOrEmpty(workingDirectory)) { - workingDirectory = associatedInstance?.ShellViewModel?.WorkingDirectory; + workingDirectory = associatedInstance?.FilesystemViewModel?.WorkingDirectory; } if (runAsAdmin) diff --git a/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs b/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs index 9fa96dbdf297..3ac7c76db6bc 100644 --- a/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs +++ b/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs @@ -114,7 +114,7 @@ public static async Task RestoreRecycleBinAsync() public static async Task RestoreSelectionRecycleBinAsync(IShellPage associatedInstance) { - var items = associatedInstance.LayoutPage.SelectedItems; + var items = associatedInstance.SlimContentPage.SelectedItems; if (items == null) return; var ConfirmEmptyBinDialog = new ContentDialog() @@ -153,7 +153,7 @@ public static bool RecycleBinHasItems() public static async Task RestoreItemAsync(IShellPage associatedInstance) { - var selected = associatedInstance.LayoutPage.SelectedItems; + var selected = associatedInstance.SlimContentPage.SelectedItems; if (selected == null) return; var items = selected.ToList().Where(x => x is StandardRecycleBinItem).Select((item) => new @@ -168,7 +168,7 @@ public static async Task RestoreItemAsync(IShellPage associatedInstance) public static async Task DeleteItemAsync(IShellPage associatedInstance) { - var selected = associatedInstance.LayoutPage.SelectedItems; + var selected = associatedInstance.SlimContentPage.SelectedItems; if (selected == null) return; var items = selected.ToList().Select((item) => StorageHelpers.FromPathAndType( diff --git a/src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs b/src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs index 794aaa92b30a..b255a215616b 100644 --- a/src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs +++ b/src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs @@ -50,7 +50,7 @@ public static void OpenPropertiesWindow(IShellPage associatedInstance) object item; - var page = associatedInstance.LayoutPage; + var page = associatedInstance.SlimContentPage; // Item(s) selected if (page is not null && page.IsItemSelected) @@ -64,7 +64,7 @@ public static void OpenPropertiesWindow(IShellPage associatedInstance) else { // Instance's current folder - var folder = associatedInstance.ShellViewModel?.CurrentFolder; + var folder = associatedInstance.FilesystemViewModel?.CurrentFolder; if (folder is null) return; diff --git a/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs b/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs index 654221507cff..cddcfa616ea8 100644 --- a/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs +++ b/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs @@ -416,7 +416,7 @@ private static void SetCurrentWorkingDirectory(StringBuilder path, char separato var subPath = path.ToString().Substring(substringIndex); path.Clear(); - path.Append(context.ShellPage?.ShellViewModel.WorkingDirectory); + path.Append(context.ShellPage?.FilesystemViewModel.WorkingDirectory); path.Append(separator); path.Append(subPath); i = -1; diff --git a/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs b/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs index 93e604495b20..fc60fa8c05d8 100644 --- a/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs +++ b/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs @@ -26,7 +26,7 @@ public sealed class FilesystemHelpers : IFilesystemHelpers private readonly IWindowsJumpListService jumpListService; private ShellFilesystemOperations filesystemOperations; - private ItemManipulationModel? itemManipulationModel => associatedInstance.LayoutPage?.ItemManipulationModel; + private ItemManipulationModel? itemManipulationModel => associatedInstance.SlimContentPage?.ItemManipulationModel; private readonly CancellationToken cancellationToken; private static char[] RestrictedCharacters diff --git a/src/Files.App/Utils/Storage/Operations/FilesystemOperations.cs b/src/Files.App/Utils/Storage/Operations/FilesystemOperations.cs index 1d5f420e8372..4729b7810309 100644 --- a/src/Files.App/Utils/Storage/Operations/FilesystemOperations.cs +++ b/src/Files.App/Utils/Storage/Operations/FilesystemOperations.cs @@ -39,7 +39,7 @@ public FilesystemOperations(IShellPage associatedInstance) var newEntryInfo = await ShellNewEntryExtensions.GetNewContextMenuEntryForType(Path.GetExtension(source.Path)); if (newEntryInfo is null) { - var fsFolderResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(source.Path)); + var fsFolderResult = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(source.Path)); fsResult = fsFolderResult; if (fsResult) { @@ -71,7 +71,7 @@ public FilesystemOperations(IShellPage associatedInstance) case FilesystemItemType.Directory: { - var fsFolderResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(source.Path)); + var fsFolderResult = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(source.Path)); fsResult = fsFolderResult; if (fsResult) { @@ -164,7 +164,7 @@ await DialogDisplayHelper.ShowDialogAsync( { // CopyFileFromApp only works on file not directories var fsSourceFolder = await source.ToStorageItemResult(); - var fsDestinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); + var fsDestinationFolder = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); var fsResult = (FilesystemResult)(fsSourceFolder.ErrorCode | fsDestinationFolder.ErrorCode); if (fsResult) @@ -217,7 +217,7 @@ await DialogDisplayHelper.ShowDialogAsync( { Debug.WriteLine(System.Runtime.InteropServices.Marshal.GetLastWin32Error()); - FilesystemResult destinationResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); + FilesystemResult destinationResult = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); var sourceResult = await source.ToStorageItemResult(); fsResult = sourceResult.ErrorCode | destinationResult.ErrorCode; @@ -371,7 +371,7 @@ await DialogDisplayHelper.ShowDialogAsync( Debug.WriteLine(System.Runtime.InteropServices.Marshal.GetLastWin32Error()); var fsSourceFolder = await source.ToStorageItemResult(); - var fsDestinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); + var fsDestinationFolder = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); fsResult = fsSourceFolder.ErrorCode | fsDestinationFolder.ErrorCode; if (fsResult) @@ -430,7 +430,7 @@ await DialogDisplayHelper.ShowDialogAsync( { Debug.WriteLine(System.Runtime.InteropServices.Marshal.GetLastWin32Error()); - FilesystemResult destinationResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); + FilesystemResult destinationResult = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); var sourceResult = await source.ToStorageItemResult(); fsResult = sourceResult.ErrorCode | destinationResult.ErrorCode; @@ -471,12 +471,12 @@ await DialogDisplayHelper.ShowDialogAsync( return null; } - bool sourceInCurrentFolder = PathNormalization.TrimPath(_associatedInstance.ShellViewModel.CurrentFolder.ItemPath) == + bool sourceInCurrentFolder = PathNormalization.TrimPath(_associatedInstance.FilesystemViewModel.CurrentFolder.ItemPath) == PathNormalization.GetParentDir(source.Path); if (fsProgress.Status == FileSystemStatusCode.Success && sourceInCurrentFolder) { - await _associatedInstance.ShellViewModel.RemoveFileOrFolderAsync(source.Path); - await _associatedInstance.ShellViewModel.ApplyFilesAndFoldersChangesAsync(); + await _associatedInstance.FilesystemViewModel.RemoveFileOrFolderAsync(source.Path); + await _associatedInstance.FilesystemViewModel.ApplyFilesAndFoldersChangesAsync(); } var pathWithType = movedItem.FromStorageItem(destination, source.ItemType); @@ -510,12 +510,12 @@ public async Task DeleteAsync(IStorageItemWithPath source, IPro { if (source.ItemType == FilesystemItemType.File) { - fsResult = await _associatedInstance.ShellViewModel.GetFileFromPathAsync(source.Path) + fsResult = await _associatedInstance.FilesystemViewModel.GetFileFromPathAsync(source.Path) .OnSuccess((t) => t.DeleteAsync(permanently ? StorageDeleteOption.PermanentDelete : StorageDeleteOption.Default).AsTask()); } else if (source.ItemType == FilesystemItemType.Directory) { - fsResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(source.Path) + fsResult = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(source.Path) .OnSuccess((t) => t.DeleteAsync(permanently ? StorageDeleteOption.PermanentDelete : StorageDeleteOption.Default).AsTask()); } } @@ -537,14 +537,14 @@ public async Task DeleteAsync(IStorageItemWithPath source, IPro // Recycle bin also stores a file starting with $I for each item string iFilePath = Path.Combine(Path.GetDirectoryName(source.Path), Path.GetFileName(source.Path).Replace("$R", "$I", StringComparison.Ordinal)); - await _associatedInstance.ShellViewModel.GetFileFromPathAsync(iFilePath) + await _associatedInstance.FilesystemViewModel.GetFileFromPathAsync(iFilePath) .OnSuccess(iFile => iFile.DeleteAsync(StorageDeleteOption.PermanentDelete).AsTask()); } fsProgress.ReportStatus(fsResult); if (fsResult) { - await _associatedInstance.ShellViewModel.RemoveFileOrFolderAsync(source.Path); + await _associatedInstance.FilesystemViewModel.RemoveFileOrFolderAsync(source.Path); if (!permanently) { @@ -736,8 +736,8 @@ public async Task RestoreFromTrashAsync(IStorageItemWithPath so { if (source.ItemType == FilesystemItemType.Directory) { - FilesystemResult sourceFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(source.Path); - FilesystemResult destinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); + FilesystemResult sourceFolder = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(source.Path); + FilesystemResult destinationFolder = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); fsResult = sourceFolder.ErrorCode | destinationFolder.ErrorCode; fsProgress.ReportStatus(fsResult); @@ -757,8 +757,8 @@ public async Task RestoreFromTrashAsync(IStorageItemWithPath so } else { - FilesystemResult sourceFile = await _associatedInstance.ShellViewModel.GetFileFromPathAsync(source.Path); - FilesystemResult destinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); + FilesystemResult sourceFile = await _associatedInstance.FilesystemViewModel.GetFileFromPathAsync(source.Path); + FilesystemResult destinationFolder = await _associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination)); fsResult = sourceFile.ErrorCode | destinationFolder.ErrorCode; fsProgress.ReportStatus(fsResult); @@ -780,7 +780,7 @@ public async Task RestoreFromTrashAsync(IStorageItemWithPath so // Recycle bin also stores a file starting with $I for each item string iFilePath = Path.Combine(Path.GetDirectoryName(source.Path), Path.GetFileName(source.Path).Replace("$R", "$I", StringComparison.Ordinal)); - await _associatedInstance.ShellViewModel.GetFileFromPathAsync(iFilePath) + await _associatedInstance.FilesystemViewModel.GetFileFromPathAsync(iFilePath) .OnSuccess(iFile => iFile.DeleteAsync(StorageDeleteOption.PermanentDelete).AsTask()); } diff --git a/src/Files.App/Utils/Storage/Operations/ShellFilesystemOperations.cs b/src/Files.App/Utils/Storage/Operations/ShellFilesystemOperations.cs index bcab988dc692..aab8616c71eb 100644 --- a/src/Files.App/Utils/Storage/Operations/ShellFilesystemOperations.cs +++ b/src/Files.App/Utils/Storage/Operations/ShellFilesystemOperations.cs @@ -385,7 +385,7 @@ public async Task DeleteItemsAsync(IList foreach (var item in deleteResult.Items) { - await _associatedInstance.ShellViewModel.RemoveFileOrFolderAsync(item.Source); + await _associatedInstance.FilesystemViewModel.RemoveFileOrFolderAsync(item.Source); } var recycledSources = deleteResult.Items.Where(x => x.Succeeded && x.Destination is not null && x.Source != x.Destination); diff --git a/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs b/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs index 550fcdbc1394..edc913be4891 100644 --- a/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs +++ b/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs @@ -57,8 +57,8 @@ private async Task ItemPointerPressedAsync(PointerRoutedEventArgs e) e.OriginalSource is FrameworkElement { DataContext: StandardStorageItem Item } && Item.PrimaryItemAttribute == StorageItemTypes.Folder) { - _associatedInstance.LayoutPage.IsMiddleClickToScrollEnabled = false; - _associatedInstance.LayoutPage.IsMiddleClickToScrollEnabled = true; + _associatedInstance.SlimContentPage.IsMiddleClickToScrollEnabled = false; + _associatedInstance.SlimContentPage.IsMiddleClickToScrollEnabled = true; if (Item.IsShortcut) await NavigationHelpers.OpenPathInNewTab(((e.OriginalSource as FrameworkElement)?.DataContext as ShortcutItem)?.TargetPath ?? Item.ItemPath, false); @@ -105,11 +105,11 @@ public async Task DragOverAsync(DragEventArgs e) var draggedItems = await FilesystemHelpers.GetDraggedStorageItems(e.DataView); - var pwd = _associatedInstance.ShellViewModel.WorkingDirectory.TrimPath(); + var pwd = _associatedInstance.FilesystemViewModel.WorkingDirectory.TrimPath(); var folderName = Path.IsPathRooted(pwd) && Path.GetPathRoot(pwd) == pwd ? Path.GetPathRoot(pwd) : Path.GetFileName(pwd); // As long as one file doesn't already belong to this folder - if (_associatedInstance.InstanceViewModel.IsPageTypeSearchResults || draggedItems.Any() && draggedItems.AreItemsAlreadyInFolder(_associatedInstance.ShellViewModel.WorkingDirectory)) + if (_associatedInstance.InstanceViewModel.IsPageTypeSearchResults || draggedItems.Any() && draggedItems.AreItemsAlreadyInFolder(_associatedInstance.FilesystemViewModel.WorkingDirectory)) { e.AcceptedOperation = DataPackageOperation.None; } @@ -150,7 +150,7 @@ x.Item is ZipStorageFile || e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), folderName); e.AcceptedOperation = DataPackageOperation.Copy; } - else if (draggedItems.AreItemsInSameDrive(_associatedInstance.ShellViewModel.WorkingDirectory)) + else if (draggedItems.AreItemsInSameDrive(_associatedInstance.FilesystemViewModel.WorkingDirectory)) { e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), folderName); // Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well. @@ -177,7 +177,7 @@ public async Task DropAsync(DragEventArgs e) try { - await _associatedInstance.FilesystemHelpers.PerformOperationTypeAsync(e.AcceptedOperation, e.DataView, _associatedInstance.ShellViewModel.WorkingDirectory, false, true); + await _associatedInstance.FilesystemHelpers.PerformOperationTypeAsync(e.AcceptedOperation, e.DataView, _associatedInstance.FilesystemViewModel.WorkingDirectory, false, true); await _associatedInstance.RefreshIfNoWatcherExistsAsync(); } finally diff --git a/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs b/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs index f86f9665b84d..e0c7fb1c8e9a 100644 --- a/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs +++ b/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs @@ -121,7 +121,7 @@ public async Task UpdateIcon() await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => { - _appInstance?.ShellViewModel?.RefreshItems(null); + _appInstance?.FilesystemViewModel?.RefreshItems(null); }); return true; diff --git a/src/Files.App/ViewModels/Properties/Items/FileProperties.cs b/src/Files.App/ViewModels/Properties/Items/FileProperties.cs index aa57316bc550..1f200fadfb1b 100644 --- a/src/Files.App/ViewModels/Properties/Items/FileProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/FileProperties.cs @@ -131,7 +131,7 @@ public override async Task GetSpecialPropertiesAsync() } string filePath = (Item as ShortcutItem)?.TargetPath ?? Item.ItemPath; - BaseStorageFile file = await AppInstance.ShellViewModel.GetFileFromPathAsync(filePath); + BaseStorageFile file = await AppInstance.FilesystemViewModel.GetFileFromPathAsync(filePath); // Couldn't access the file and can't load any other properties if (file is null) diff --git a/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs b/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs index 904be0883dda..388410a4d3fd 100644 --- a/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs @@ -107,7 +107,7 @@ public async override Task GetSpecialPropertiesAsync() } string folderPath = (Item as ShortcutItem)?.TargetPath ?? Item.ItemPath; - BaseStorageFolder storageFolder = await AppInstance.ShellViewModel.GetFolderFromPathAsync(folderPath); + BaseStorageFolder storageFolder = await AppInstance.FilesystemViewModel.GetFolderFromPathAsync(folderPath); if (storageFolder is not null) { diff --git a/src/Files.App/ViewModels/Properties/Items/LibraryProperties.cs b/src/Files.App/ViewModels/Properties/Items/LibraryProperties.cs index ad087f23c621..0ae2cb2e26de 100644 --- a/src/Files.App/ViewModels/Properties/Items/LibraryProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/LibraryProperties.cs @@ -62,7 +62,7 @@ public async override Task GetSpecialPropertiesAsync() ViewModel.LoadFileIcon = true; } - BaseStorageFile libraryFile = await AppInstance.ShellViewModel.GetFileFromPathAsync(Library.ItemPath); + BaseStorageFile libraryFile = await AppInstance.FilesystemViewModel.GetFileFromPathAsync(Library.ItemPath); if (libraryFile is not null) { ViewModel.ItemCreatedTimestampReal = libraryFile.DateCreated; @@ -79,7 +79,7 @@ public async override Task GetSpecialPropertiesAsync() { foreach (var path in Library.Folders) { - BaseStorageFolder folder = await AppInstance.ShellViewModel.GetFolderFromPathAsync(path); + BaseStorageFolder folder = await AppInstance.FilesystemViewModel.GetFolderFromPathAsync(path); if (!string.IsNullOrEmpty(folder.Path)) { storageFolders.Add(folder); diff --git a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs index a25adc33c686..a652d8b893cc 100644 --- a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs @@ -587,7 +587,7 @@ private void CloseSearchBox(bool doFocus = false) { SearchBox.Query = string.Empty; - var page = Ioc.Default.GetRequiredService().ShellPage?.LayoutPage; + var page = Ioc.Default.GetRequiredService().ShellPage?.SlimContentPage; if (page is BaseGroupableLayoutPage svb && svb.IsLoaded) page.ItemManipulationModel.FocusFileList(); @@ -630,7 +630,7 @@ public async Task SetPathBoxDropDownFlyoutAsync(MenuFlyout flyout, PathBoxItem p var nextPathItemTitle = PathComponents[PathComponents.IndexOf(pathItem) + 1].Title; IList? childFolders = null; - StorageFolderWithPath folder = await shellPage.ShellViewModel.GetFolderWithPathFromPathAsync(pathItem.Path); + StorageFolderWithPath folder = await shellPage.FilesystemViewModel.GetFolderWithPathFromPathAsync(pathItem.Path); if (folder is not null) childFolders = (await FilesystemTasks.Wrap(() => folder.GetFoldersWithPathAsync(string.Empty))).Result; @@ -725,7 +725,7 @@ await DialogDisplayHelper.ShowDialogAsync("CommandNotExecutable".GetLocalizedRes if (currentSelectedPath == normalizedInput || string.IsNullOrWhiteSpace(normalizedInput)) return; - if (normalizedInput != shellPage.ShellViewModel.WorkingDirectory || shellPage.CurrentPageType == typeof(HomePage)) + if (normalizedInput != shellPage.FilesystemViewModel.WorkingDirectory || shellPage.CurrentPageType == typeof(HomePage)) { if (normalizedInput.Equals("Home", StringComparison.OrdinalIgnoreCase) || normalizedInput.Equals("Home".GetLocalizedResource(), StringComparison.OrdinalIgnoreCase)) { @@ -774,10 +774,10 @@ await DialogDisplayHelper.ShowDialogAsync("CommandNotExecutable".GetLocalizedRes else // Not a file or not accessible { var workingDir = - string.IsNullOrEmpty(shellPage.ShellViewModel.WorkingDirectory) || + string.IsNullOrEmpty(shellPage.FilesystemViewModel.WorkingDirectory) || shellPage.CurrentPageType == typeof(HomePage) ? Constants.UserEnvironmentPaths.HomePath : - shellPage.ShellViewModel.WorkingDirectory; + shellPage.FilesystemViewModel.WorkingDirectory; if (await LaunchApplicationFromPath(currentInput, workingDir)) return; @@ -797,7 +797,7 @@ await DialogDisplayHelper.ShowDialogAsync("InvalidItemDialogTitle".GetLocalizedR } } - PathControlDisplayText = shellPage.ShellViewModel.WorkingDirectory; + PathControlDisplayText = shellPage.FilesystemViewModel.WorkingDirectory; } } @@ -823,7 +823,7 @@ private static async Task LaunchApplicationFromPath(string currentInput, s public async Task SetAddressBarSuggestionsAsync(AutoSuggestBox sender, IShellPage shellpage) { - if (sender.Text is not null && shellpage.ShellViewModel is not null) + if (sender.Text is not null && shellpage.FilesystemViewModel is not null) { if (!await SafetyExtensions.IgnoreExceptions(async () => { @@ -870,7 +870,7 @@ public async Task SetAddressBarSuggestionsAsync(AutoSuggestBox sender, IShellPag currentInput = NormalizePathInput(currentInput, isFtp); var expandedPath = StorageFileExtensions.GetResolvedPath(currentInput, isFtp); var folderPath = PathNormalization.GetParentDir(expandedPath) ?? expandedPath; - StorageFolderWithPath folder = await shellpage.ShellViewModel.GetFolderWithPathFromPathAsync(folderPath); + StorageFolderWithPath folder = await shellpage.FilesystemViewModel.GetFolderWithPathFromPathAsync(folderPath); if (folder is null) return false; @@ -904,7 +904,7 @@ public async Task SetAddressBarSuggestionsAsync(AutoSuggestBox sender, IShellPag if (suggestions is null || suggestions.Count == 0) { suggestions = new List() { new NavigationBarSuggestionItem() { - Text = shellpage.ShellViewModel.WorkingDirectory, + Text = shellpage.FilesystemViewModel.WorkingDirectory, PrimaryDisplay = "NavigationToolbarVisiblePathNoResults".GetLocalizedResource() } }; } @@ -956,7 +956,7 @@ public async Task SetAddressBarSuggestionsAsync(AutoSuggestBox sender, IShellPag NavigationBarSuggestions.Clear(); NavigationBarSuggestions.Add(new NavigationBarSuggestionItem() { - Text = shellpage.ShellViewModel.WorkingDirectory, + Text = shellpage.FilesystemViewModel.WorkingDirectory, PrimaryDisplay = "NavigationToolbarVisiblePathNoResults".GetLocalizedResource() }); }); diff --git a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs index 085467f7637b..3ae452ee053c 100644 --- a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs @@ -906,10 +906,10 @@ private void OpenProperties(CommandBarFlyout menu) if (!string.Equals(locationItem.Path, Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.OrdinalIgnoreCase)) { - BaseStorageFolder matchingStorageFolder = await PaneHolder.ActivePane.ShellViewModel.GetFolderFromPathAsync(locationItem.Path); + BaseStorageFolder matchingStorageFolder = await PaneHolder.ActivePane.FilesystemViewModel.GetFolderFromPathAsync(locationItem.Path); if (matchingStorageFolder is not null) { - var syncStatus = await PaneHolder.ActivePane.ShellViewModel.CheckCloudDriveSyncStatusAsync(matchingStorageFolder); + var syncStatus = await PaneHolder.ActivePane.FilesystemViewModel.CheckCloudDriveSyncStatusAsync(matchingStorageFolder); listedItem.SyncStatusUI = CloudDriveSyncStatusUI.FromCloudDriveSyncStatus(syncStatus); } } diff --git a/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs b/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs index a40b73666fa2..ffa459202e75 100644 --- a/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs @@ -282,10 +282,10 @@ private void ExecuteOpenPropertiesCommand(WidgetFolderCardItem? item) if (!string.Equals(item.Item.Path, Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.OrdinalIgnoreCase)) { - BaseStorageFolder matchingStorageFolder = await ContentPageContext.ShellPage!.ShellViewModel.GetFolderFromPathAsync(item.Item.Path); + BaseStorageFolder matchingStorageFolder = await ContentPageContext.ShellPage!.FilesystemViewModel.GetFolderFromPathAsync(item.Item.Path); if (matchingStorageFolder is not null) { - var syncStatus = await ContentPageContext.ShellPage!.ShellViewModel.CheckCloudDriveSyncStatusAsync(matchingStorageFolder); + var syncStatus = await ContentPageContext.ShellPage!.FilesystemViewModel.CheckCloudDriveSyncStatusAsync(matchingStorageFolder); listedItem.SyncStatusUI = CloudDriveSyncStatusUI.FromCloudDriveSyncStatus(syncStatus); } } diff --git a/src/Files.App/Views/HomePage.xaml.cs b/src/Files.App/Views/HomePage.xaml.cs index 38bd4547064d..1e29c086924f 100644 --- a/src/Files.App/Views/HomePage.xaml.cs +++ b/src/Files.App/Views/HomePage.xaml.cs @@ -42,20 +42,20 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) AppInstance.InstanceViewModel.IsPageTypeLibrary = false; AppInstance.InstanceViewModel.GitRepositoryPath = null; AppInstance.InstanceViewModel.IsGitRepository = false; - AppInstance.AddressToolbarViewModel.CanRefresh = true; - AppInstance.AddressToolbarViewModel.CanGoBack = AppInstance.CanNavigateBackward; - AppInstance.AddressToolbarViewModel.CanGoForward = AppInstance.CanNavigateForward; - AppInstance.AddressToolbarViewModel.CanNavigateToParent = false; + AppInstance.ToolbarViewModel.CanRefresh = true; + AppInstance.ToolbarViewModel.CanGoBack = AppInstance.CanNavigateBackward; + AppInstance.ToolbarViewModel.CanGoForward = AppInstance.CanNavigateForward; + AppInstance.ToolbarViewModel.CanNavigateToParent = false; - AppInstance.AddressToolbarViewModel.RefreshRequested -= ToolbarViewModel_RefreshRequested; - AppInstance.AddressToolbarViewModel.RefreshRequested += ToolbarViewModel_RefreshRequested; + AppInstance.ToolbarViewModel.RefreshRequested -= ToolbarViewModel_RefreshRequested; + AppInstance.ToolbarViewModel.RefreshRequested += ToolbarViewModel_RefreshRequested; // Set path of working directory empty - await AppInstance.ShellViewModel.SetWorkingDirectoryAsync("Home"); + await AppInstance.FilesystemViewModel.SetWorkingDirectoryAsync("Home"); - AppInstance.LayoutPage?.StatusBarViewModel.UpdateGitInfo(false, string.Empty, null); + AppInstance.SlimContentPage?.StatusBarViewModel.UpdateGitInfo(false, string.Empty, null); - AppInstance.AddressToolbarViewModel.PathComponents.Clear(); + AppInstance.ToolbarViewModel.PathComponents.Clear(); string componentLabel = parameters?.NavPathParam == "Home" @@ -71,7 +71,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) Path = tag, }; - AppInstance.AddressToolbarViewModel.PathComponents.Add(item); + AppInstance.ToolbarViewModel.PathComponents.Add(item); base.OnNavigatedTo(e); } @@ -83,18 +83,18 @@ protected override void OnNavigatedFrom(NavigationEventArgs e) private async void ToolbarViewModel_RefreshRequested(object? sender, EventArgs e) { - AppInstance.AddressToolbarViewModel.CanRefresh = false; + AppInstance.ToolbarViewModel.CanRefresh = false; await Task.WhenAll(ViewModel.WidgetItems.Select(w => w.WidgetItemModel.RefreshWidgetAsync())); - AppInstance.AddressToolbarViewModel.CanRefresh = true; + AppInstance.ToolbarViewModel.CanRefresh = true; } // Disposer public void Dispose() { - AppInstance.AddressToolbarViewModel.RefreshRequested -= ToolbarViewModel_RefreshRequested; + AppInstance.ToolbarViewModel.RefreshRequested -= ToolbarViewModel_RefreshRequested; ViewModel?.Dispose(); } } diff --git a/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs b/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs index 4253317fa8fb..5453ca9ed82e 100644 --- a/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs +++ b/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs @@ -128,40 +128,40 @@ protected virtual async void ItemManipulationModel_RefreshItemThumbnail(object? protected virtual async Task ReloadSelectedItemIconAsync() { - if (ParentShellPageInstance?.LayoutPage?.SelectedItem is null) + if (ParentShellPageInstance?.SlimContentPage?.SelectedItem is null) return; - ParentShellPageInstance.ShellViewModel.CancelExtendedPropertiesLoading(); - ParentShellPageInstance.LayoutPage.SelectedItem.ItemPropertiesInitialized = false; + ParentShellPageInstance.FilesystemViewModel.CancelExtendedPropertiesLoading(); + ParentShellPageInstance.SlimContentPage.SelectedItem.ItemPropertiesInitialized = false; - await ParentShellPageInstance.ShellViewModel.LoadExtendedItemPropertiesAsync(ParentShellPageInstance.LayoutPage.SelectedItem); + await ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemPropertiesAsync(ParentShellPageInstance.SlimContentPage.SelectedItem); - if (ParentShellPageInstance.ShellViewModel.EnabledGitProperties is not GitProperties.None && - ParentShellPageInstance.LayoutPage.SelectedItem is GitItem gitItem) + if (ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties is not GitProperties.None && + ParentShellPageInstance.SlimContentPage.SelectedItem is GitItem gitItem) { - await ParentShellPageInstance.ShellViewModel.LoadGitPropertiesAsync(gitItem); + await ParentShellPageInstance.FilesystemViewModel.LoadGitPropertiesAsync(gitItem); } } protected virtual async Task ReloadSelectedItemsIconAsync() { - if (ParentShellPageInstance?.LayoutPage?.SelectedItems is null) + if (ParentShellPageInstance?.SlimContentPage?.SelectedItems is null) return; - ParentShellPageInstance.ShellViewModel.CancelExtendedPropertiesLoading(); + ParentShellPageInstance.FilesystemViewModel.CancelExtendedPropertiesLoading(); - foreach (var selectedItem in ParentShellPageInstance.LayoutPage.SelectedItems) + foreach (var selectedItem in ParentShellPageInstance.SlimContentPage.SelectedItems) { selectedItem.ItemPropertiesInitialized = false; - await ParentShellPageInstance.ShellViewModel.LoadExtendedItemPropertiesAsync(selectedItem); + await ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemPropertiesAsync(selectedItem); } - if (ParentShellPageInstance.ShellViewModel.EnabledGitProperties is not GitProperties.None) + if (ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties is not GitProperties.None) { - await Task.WhenAll(ParentShellPageInstance.LayoutPage.SelectedItems.Select(item => + await Task.WhenAll(ParentShellPageInstance.SlimContentPage.SelectedItems.Select(item => { if (item is GitItem gitItem) - return ParentShellPageInstance.ShellViewModel.LoadGitPropertiesAsync(gitItem); + return ParentShellPageInstance.FilesystemViewModel.LoadGitPropertiesAsync(gitItem); return Task.CompletedTask; })); diff --git a/src/Files.App/Views/Layouts/BaseLayoutPage.cs b/src/Files.App/Views/Layouts/BaseLayoutPage.cs index a92c8acd7790..362a0a946150 100644 --- a/src/Files.App/Views/Layouts/BaseLayoutPage.cs +++ b/src/Files.App/Views/Layouts/BaseLayoutPage.cs @@ -186,7 +186,7 @@ public string JumpString if (previouslySelectedItem is not null) { // Use FilesAndFolders because only displayed entries should be jumped to - IEnumerable candidateItems = ParentShellPageInstance!.ShellViewModel.FilesAndFolders.ToList() + IEnumerable candidateItems = ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders.ToList() .SkipWhile(x => x != previouslySelectedItem) .Skip(value.Length == 1 ? 1 : 0) // User is trying to cycle through items starting with the same letter .Where(f => f.Name.Length >= value.Length && string.Equals(f.Name.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase)); @@ -196,7 +196,7 @@ public string JumpString if (jumpedToItem is null) { // Use FilesAndFolders because only displayed entries should be jumped to - IEnumerable candidateItems = ParentShellPageInstance!.ShellViewModel.FilesAndFolders.ToList() + IEnumerable candidateItems = ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders.ToList() .Where(f => f.Name.Length >= value.Length && string.Equals(f.Name.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase)); jumpedToItem = candidateItems.FirstOrDefault(); } @@ -262,7 +262,7 @@ internal set NotifyPropertyChanged(nameof(SelectedItems)); } - ParentShellPageInstance!.AddressToolbarViewModel.SelectedItems = value; + ParentShellPageInstance!.ToolbarViewModel.SelectedItems = value; } } @@ -346,9 +346,9 @@ public virtual void ResetItemOpacity() protected virtual void BaseFolderSettings_LayoutModeChangeRequested(object? sender, LayoutModeEventArgs e) { - if (ParentShellPageInstance?.LayoutPage is not null) + if (ParentShellPageInstance?.SlimContentPage is not null) { - var layoutType = FolderSettings!.GetLayoutType(ParentShellPageInstance.ShellViewModel.WorkingDirectory); + var layoutType = FolderSettings!.GetLayoutType(ParentShellPageInstance.FilesystemViewModel.WorkingDirectory); if (layoutType != ParentShellPageInstance.CurrentPageType) { @@ -367,7 +367,7 @@ protected virtual void BaseFolderSettings_LayoutModeChangeRequested(object? send ParentShellPageInstance.ResetNavigationStackLayoutMode(); } - ParentShellPageInstance.ShellViewModel.UpdateEmptyTextType(); + ParentShellPageInstance.FilesystemViewModel.UpdateEmptyTextType(); } } @@ -387,7 +387,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) ParentShellPageInstance = navigationArguments.AssociatedTabInstance; // Git properties are not loaded by default - ParentShellPageInstance.ShellViewModel.EnabledGitProperties = GitProperties.None; + ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties = GitProperties.None; InitializeCommandsViewModel(); @@ -398,30 +398,30 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) FolderSettings.GroupDirectionPreferenceUpdated += FolderSettings_GroupDirectionPreferenceUpdated; FolderSettings.GroupByDateUnitPreferenceUpdated += FolderSettings_GroupByDateUnitPreferenceUpdated; - ParentShellPageInstance.ShellViewModel.EmptyTextType = EmptyTextType.None; - ParentShellPageInstance.AddressToolbarViewModel.CanRefresh = true; + ParentShellPageInstance.FilesystemViewModel.EmptyTextType = EmptyTextType.None; + ParentShellPageInstance.ToolbarViewModel.CanRefresh = true; if (!navigationArguments.IsSearchResultPage) { - var previousDir = ParentShellPageInstance.ShellViewModel.WorkingDirectory; - await ParentShellPageInstance.ShellViewModel.SetWorkingDirectoryAsync(navigationArguments.NavPathParam); + var previousDir = ParentShellPageInstance.FilesystemViewModel.WorkingDirectory; + await ParentShellPageInstance.FilesystemViewModel.SetWorkingDirectoryAsync(navigationArguments.NavPathParam); // pathRoot will be empty on recycle bin path - var workingDir = ParentShellPageInstance.ShellViewModel.WorkingDirectory ?? string.Empty; + var workingDir = ParentShellPageInstance.FilesystemViewModel.WorkingDirectory ?? string.Empty; var pathRoot = GetPathRoot(workingDir); var isRecycleBin = workingDir.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal); ParentShellPageInstance.InstanceViewModel.IsPageTypeRecycleBin = isRecycleBin; // Can't go up from recycle bin - ParentShellPageInstance.AddressToolbarViewModel.CanNavigateToParent = !(string.IsNullOrEmpty(pathRoot) || isRecycleBin); + ParentShellPageInstance.ToolbarViewModel.CanNavigateToParent = !(string.IsNullOrEmpty(pathRoot) || isRecycleBin); ParentShellPageInstance.InstanceViewModel.IsPageTypeMtpDevice = workingDir.StartsWith("\\\\?\\", StringComparison.Ordinal); ParentShellPageInstance.InstanceViewModel.IsPageTypeFtp = FtpHelpers.IsFtpPath(workingDir); ParentShellPageInstance.InstanceViewModel.IsPageTypeZipFolder = ZipStorageFolder.IsZipPath(workingDir); ParentShellPageInstance.InstanceViewModel.IsPageTypeLibrary = LibraryManager.IsLibraryPath(workingDir); ParentShellPageInstance.InstanceViewModel.IsPageTypeSearchResults = false; - ParentShellPageInstance.AddressToolbarViewModel.PathControlDisplayText = navigationArguments.NavPathParam; + ParentShellPageInstance.ToolbarViewModel.PathControlDisplayText = navigationArguments.NavPathParam; if (ParentShellPageInstance.InstanceViewModel.FolderSettings.DirectorySortOption == SortOption.Path) ParentShellPageInstance.InstanceViewModel.FolderSettings.DirectorySortOption = SortOption.Name; @@ -431,22 +431,22 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) ParentShellPageInstance.InstanceViewModel.FolderSettings.DirectoryGroupOption = GroupOption.None; if (!navigationArguments.IsLayoutSwitch || previousDir != workingDir) - ParentShellPageInstance.ShellViewModel.RefreshItems(previousDir, SetSelectedItemsOnNavigation); + ParentShellPageInstance.FilesystemViewModel.RefreshItems(previousDir, SetSelectedItemsOnNavigation); else - ParentShellPageInstance.AddressToolbarViewModel.CanGoForward = false; + ParentShellPageInstance.ToolbarViewModel.CanGoForward = false; } else { - await ParentShellPageInstance.ShellViewModel.SetWorkingDirectoryAsync(navigationArguments.SearchPathParam); + await ParentShellPageInstance.FilesystemViewModel.SetWorkingDirectoryAsync(navigationArguments.SearchPathParam); - ParentShellPageInstance.AddressToolbarViewModel.CanGoForward = false; + ParentShellPageInstance.ToolbarViewModel.CanGoForward = false; // Impose no artificial restrictions on back navigation. Even in a search results page. - ParentShellPageInstance.AddressToolbarViewModel.CanGoBack = true; + ParentShellPageInstance.ToolbarViewModel.CanGoBack = true; - ParentShellPageInstance.AddressToolbarViewModel.CanNavigateToParent = false; + ParentShellPageInstance.ToolbarViewModel.CanNavigateToParent = false; - var workingDir = ParentShellPageInstance.ShellViewModel.WorkingDirectory ?? string.Empty; + var workingDir = ParentShellPageInstance.FilesystemViewModel.WorkingDirectory ?? string.Empty; ParentShellPageInstance.InstanceViewModel.IsPageTypeRecycleBin = workingDir.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal); ParentShellPageInstance.InstanceViewModel.IsPageTypeMtpDevice = workingDir.StartsWith("\\\\?\\", StringComparison.Ordinal); @@ -466,13 +466,13 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) ThumbnailSize = InstanceViewModel!.FolderSettings.GetRoundedIconSize(), }; - _ = ParentShellPageInstance.ShellViewModel.SearchAsync(searchInstance); + _ = ParentShellPageInstance.FilesystemViewModel.SearchAsync(searchInstance); } } // Show controls that were hidden on the home page ParentShellPageInstance.InstanceViewModel.IsPageTypeNotHome = true; - ParentShellPageInstance.ShellViewModel.UpdateGroupOptions(); + ParentShellPageInstance.FilesystemViewModel.UpdateGroupOptions(); UpdateCollectionViewSource(); FolderSettings.IsLayoutModeChanging = false; @@ -493,7 +493,7 @@ navigationArguments.SelectItems is not null && { List listedItemsToSelect = [ - .. ParentShellPageInstance!.ShellViewModel.FilesAndFolders.ToList().Where((li) => navigationArguments.SelectItems.Contains(li.ItemNameRaw)), + .. ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders.ToList().Where((li) => navigationArguments.SelectItems.Contains(li.ItemNameRaw)), ]; ItemManipulationModel.SetSelectedItems(listedItemsToSelect); @@ -530,11 +530,11 @@ private async Task GroupPreferenceUpdatedAsync() groupingCancellationToken = new CancellationTokenSource(); var token = groupingCancellationToken.Token; - await ParentShellPageInstance!.ShellViewModel.GroupOptionsUpdatedAsync(token); + await ParentShellPageInstance!.FilesystemViewModel.GroupOptionsUpdatedAsync(token); UpdateCollectionViewSource(); - await ParentShellPageInstance.ShellViewModel.ReloadItemGroupHeaderImagesAsync(); + await ParentShellPageInstance.FilesystemViewModel.ReloadItemGroupHeaderImagesAsync(); } protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) @@ -552,7 +552,7 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) var parameter = e.Parameter as NavigationArguments; if (parameter is not null && !parameter.IsLayoutSwitch) - ParentShellPageInstance!.ShellViewModel.CancelLoadAndClearFiles(); + ParentShellPageInstance!.FilesystemViewModel.CancelLoadAndClearFiles(); } private async void ItemContextFlyout_Opening(object? sender, object e) @@ -600,7 +600,7 @@ private async void ItemContextFlyout_Opening(object? sender, object e) if (!InstanceViewModel.IsPageTypeZipFolder && !InstanceViewModel.IsPageTypeFtp) { - var shellMenuItems = await ContentPageContextFlyoutFactory.GetItemContextShellCommandsAsync(workingDir: ParentShellPageInstance.ShellViewModel.WorkingDirectory, selectedItems: SelectedItems!, shiftPressed: shiftPressed, showOpenMenu: false, shellContextMenuItemCancellationToken.Token); + var shellMenuItems = await ContentPageContextFlyoutFactory.GetItemContextShellCommandsAsync(workingDir: ParentShellPageInstance.FilesystemViewModel.WorkingDirectory, selectedItems: SelectedItems!, shiftPressed: shiftPressed, showOpenMenu: false, shellContextMenuItemCancellationToken.Token); if (shellMenuItems.Any()) await AddShellMenuItemsAsync(shellMenuItems, ItemContextMenuFlyout, shiftPressed); else @@ -642,7 +642,7 @@ private async void BaseContextFlyout_Opening(object? sender, object e) shellContextMenuItemCancellationToken = new CancellationTokenSource(); shiftPressed = Microsoft.UI.Input.InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Shift).HasFlag(Windows.UI.Core.CoreVirtualKeyStates.Down); - var items = ContentPageContextFlyoutFactory.GetItemContextCommandsWithoutShellItems(currentInstanceViewModel: InstanceViewModel!, selectedItems: [ParentShellPageInstance!.ShellViewModel.CurrentFolder], commandsViewModel: CommandsViewModel!, shiftPressed: shiftPressed, itemViewModel: ParentShellPageInstance!.ShellViewModel, selectedItemsPropertiesViewModel: null); + var items = ContentPageContextFlyoutFactory.GetItemContextCommandsWithoutShellItems(currentInstanceViewModel: InstanceViewModel!, selectedItems: [ParentShellPageInstance!.FilesystemViewModel.CurrentFolder], commandsViewModel: CommandsViewModel!, shiftPressed: shiftPressed, itemViewModel: ParentShellPageInstance!.FilesystemViewModel, selectedItemsPropertiesViewModel: null); BaseContextMenuFlyout.PrimaryCommands.Clear(); BaseContextMenuFlyout.SecondaryCommands.Clear(); @@ -659,7 +659,7 @@ private async void BaseContextFlyout_Opening(object? sender, object e) if (!InstanceViewModel!.IsPageTypeSearchResults && !InstanceViewModel.IsPageTypeZipFolder && !InstanceViewModel.IsPageTypeFtp) { - var shellMenuItems = await ContentPageContextFlyoutFactory.GetItemContextShellCommandsAsync(workingDir: ParentShellPageInstance.ShellViewModel.WorkingDirectory, selectedItems: [], shiftPressed: shiftPressed, showOpenMenu: false, shellContextMenuItemCancellationToken.Token); + var shellMenuItems = await ContentPageContextFlyoutFactory.GetItemContextShellCommandsAsync(workingDir: ParentShellPageInstance.FilesystemViewModel.WorkingDirectory, selectedItems: [], shiftPressed: shiftPressed, showOpenMenu: false, shellContextMenuItemCancellationToken.Token); if (shellMenuItems.Any()) await AddShellMenuItemsAsync(shellMenuItems, BaseContextMenuFlyout, shiftPressed); else @@ -1157,7 +1157,7 @@ private void RefreshItem(SelectorItem container, object item, bool inRecycleQueu if (inRecycleQueue) { - ParentShellPageInstance!.ShellViewModel.CancelExtendedPropertiesLoadingForItem(listedItem); + ParentShellPageInstance!.FilesystemViewModel.CancelExtendedPropertiesLoadingForItem(listedItem); } else { @@ -1168,9 +1168,9 @@ private void RefreshItem(SelectorItem container, object item, bool inRecycleQueu uint callbackPhase = 3; args.RegisterUpdateCallback(callbackPhase, async (s, c) => { - await ParentShellPageInstance!.ShellViewModel.LoadExtendedItemPropertiesAsync(listedItem); - if (ParentShellPageInstance.ShellViewModel.EnabledGitProperties is not GitProperties.None && listedItem is GitItem gitItem) - await ParentShellPageInstance.ShellViewModel.LoadGitPropertiesAsync(gitItem); + await ParentShellPageInstance!.FilesystemViewModel.LoadExtendedItemPropertiesAsync(listedItem); + if (ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties is not GitProperties.None && listedItem is GitItem gitItem) + await ParentShellPageInstance.FilesystemViewModel.LoadGitPropertiesAsync(gitItem); }); } } @@ -1303,12 +1303,12 @@ private void UpdateCollectionViewSource() if (ParentShellPageInstance is null) return; - if (ParentShellPageInstance.ShellViewModel.FilesAndFolders.IsGrouped) + if (ParentShellPageInstance.FilesystemViewModel.FilesAndFolders.IsGrouped) { var newSource = new CollectionViewSource() { IsSourceGrouped = true, - Source = ParentShellPageInstance.ShellViewModel.FilesAndFolders.GroupedCollection + Source = ParentShellPageInstance.FilesystemViewModel.FilesAndFolders.GroupedCollection }; CollectionViewSource = newSource; } @@ -1317,7 +1317,7 @@ private void UpdateCollectionViewSource() var newSource = new CollectionViewSource() { IsSourceGrouped = false, - Source = ParentShellPageInstance.ShellViewModel.FilesAndFolders + Source = ParentShellPageInstance.FilesystemViewModel.FilesAndFolders }; CollectionViewSource = newSource; } @@ -1373,7 +1373,7 @@ private void ItemManipulationModel_RefreshItemsOpacityInvoked(object? sender, Ev private void View_VectorChanged(IObservableVector sender, IVectorChangedEventArgs @event) { if (ParentShellPageInstance is not null) - ParentShellPageInstance.AddressToolbarViewModel.HasItem = CollectionViewSource.View.Any(); + ParentShellPageInstance.ToolbarViewModel.HasItem = CollectionViewSource.View.Any(); } virtual public void StartRenameItem() diff --git a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs index 74d577ffc202..6020a6785600 100644 --- a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs @@ -307,7 +307,7 @@ protected override void FileList_SelectionChanged(object sender, SelectionChange else if (SelectedItems?.Count > 1 || SelectedItem?.PrimaryItemAttribute is StorageItemTypes.File || openedFolderPresenter != null && ParentShellPageInstance != null - && !ParentShellPageInstance.ShellViewModel.FilesAndFolders.ToList().Contains(FileList.ItemFromContainer(openedFolderPresenter)) + && !ParentShellPageInstance.FilesystemViewModel.FilesAndFolders.ToList().Contains(FileList.ItemFromContainer(openedFolderPresenter)) && !isDraggingSelectionRectangle) // Skip closing if dragging since nothing should be open { CloseFolder(); @@ -363,7 +363,7 @@ ParentShellPageInstance is null || } else if (e.Key == VirtualKey.Space) { - if (!ParentShellPageInstance.AddressToolbarViewModel.IsEditModeEnabled) + if (!ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) e.Handled = true; } else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up)) @@ -389,7 +389,7 @@ ParentShellPageInstance is null || } else if (e.Key == VirtualKey.Left) // Left arrow: select parent folder (previous column) { - if (ParentShellPageInstance is not null && ParentShellPageInstance.AddressToolbarViewModel.IsEditModeEnabled) + if (ParentShellPageInstance is not null && ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) return; var currentBladeIndex = (ParentShellPageInstance is ColumnShellPage associatedColumnShellPage) ? associatedColumnShellPage.ColumnParams.Column : 0; @@ -400,7 +400,7 @@ ParentShellPageInstance is null || } else if (e.Key == VirtualKey.Right) // Right arrow: switch focus to next column { - if (ParentShellPageInstance is not null && ParentShellPageInstance.AddressToolbarViewModel.IsEditModeEnabled) + if (ParentShellPageInstance is not null && ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) return; var currentBladeIndex = (ParentShellPageInstance is ColumnShellPage associatedColumnShellPage) ? associatedColumnShellPage.ColumnParams.Column : 0; diff --git a/src/Files.App/Views/Layouts/ColumnsLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/ColumnsLayoutPage.xaml.cs index 9d5c9d902c67..2ec35c81c91c 100644 --- a/src/Files.App/Views/Layouts/ColumnsLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/ColumnsLayoutPage.xaml.cs @@ -63,7 +63,7 @@ private void ColumnViewBase_ItemInvoked(object? sender, EventArgs e) var nextBladeIndex = ColumnHost.ActiveBlades.IndexOf(column.ListView.FindAscendant()) + 1; var nextBlade = ColumnHost.ActiveBlades.ToList().ElementAtOrDefault(nextBladeIndex); - var arePathsDifferent = ((nextBlade?.Content as Frame)?.Content as IShellPage)?.ShellViewModel?.WorkingDirectory != column.NavPathParam; + var arePathsDifferent = ((nextBlade?.Content as Frame)?.Content as IShellPage)?.FilesystemViewModel?.WorkingDirectory != column.NavPathParam; if (nextBlade is null || arePathsDifferent) { @@ -158,7 +158,7 @@ public override void Dispose() if (frame?.Content is ColumnShellPage shPage) { shPage.ContentChanged -= ColumnViewBrowser_ContentChanged; - if (shPage.LayoutPage is ColumnLayoutPage viewBase) + if (shPage.SlimContentPage is ColumnLayoutPage viewBase) { viewBase.ItemInvoked -= ColumnViewBase_ItemInvoked; viewBase.ItemTapped -= ColumnViewBase_ItemTapped; @@ -200,7 +200,7 @@ public void DismissOtherBlades(int index) if (frame?.Content is IDisposable disposableContent) disposableContent.Dispose(); - if ((frame?.Content as ColumnShellPage)?.LayoutPage is ColumnLayoutPage columnLayout) + if ((frame?.Content as ColumnShellPage)?.SlimContentPage is ColumnLayoutPage columnLayout) { columnLayout.ItemInvoked -= ColumnViewBase_ItemInvoked; columnLayout.ItemTapped -= ColumnViewBase_ItemTapped; @@ -216,8 +216,8 @@ public void DismissOtherBlades(int index) if ((ColumnHost.ActiveBlades[index].Content as Frame)?.Content is ColumnShellPage s) { - navigationArguments.NavPathParam = s.ShellViewModel.WorkingDirectory; - ParentShellPageInstance.TabBarItemParameter.NavigationParameter = s.ShellViewModel.WorkingDirectory; + navigationArguments.NavPathParam = s.FilesystemViewModel.WorkingDirectory; + ParentShellPageInstance.TabBarItemParameter.NavigationParameter = s.FilesystemViewModel.WorkingDirectory; } }); } @@ -256,7 +256,7 @@ private void ColumnViewBrowser_GotFocus(object sender, RoutedEventArgs e) private void ColumnViewBrowser_ContentChanged(object sender, TabBarItemParameter e) { var c = sender as IShellPage; - var columnView = c?.LayoutPage as ColumnLayoutPage; + var columnView = c?.SlimContentPage as ColumnLayoutPage; if (columnView is not null) { columnView.ItemInvoked -= ColumnViewBase_ItemInvoked; @@ -273,7 +273,7 @@ private void ColumnViewBrowser_ContentChanged(object sender, TabBarItemParameter private void ColumnViewBase_KeyUp(object sender, Microsoft.UI.Xaml.Input.KeyRoutedEventArgs e) { var shPage = ActiveColumnShellPage as ColumnShellPage; - if (shPage?.LayoutPage?.SelectedItem?.PrimaryItemAttribute is not StorageItemTypes.Folder) + if (shPage?.SlimContentPage?.SelectedItem?.PrimaryItemAttribute is not StorageItemTypes.Folder) CloseUnnecessaryColumns(shPage?.ColumnParams); } @@ -293,7 +293,7 @@ public void NavigateUp() DismissOtherBlades(ColumnHost.ActiveBlades[ColumnHost.ActiveBlades.Count - 2]); else { - var workingDirectory = ((ColumnHost.ActiveBlades?.ToList().FirstOrDefault()?.Content as Frame)?.Content as ColumnShellPage)?.ShellViewModel.WorkingDirectory; + var workingDirectory = ((ColumnHost.ActiveBlades?.ToList().FirstOrDefault()?.Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel.WorkingDirectory; if (workingDirectory is null || string.Equals(workingDirectory, GetPathRoot(workingDirectory), StringComparison.OrdinalIgnoreCase)) ParentShellPageInstance?.NavigateHome(); else @@ -344,7 +344,7 @@ public void MoveFocusToNextBlade(int currentBladeIndex) activeBladeFrame.Content is not ColumnShellPage activeBladePage) return null; - return activeBladePage.LayoutPage as ColumnLayoutPage; + return activeBladePage.SlimContentPage as ColumnLayoutPage; } public void SetSelectedPathOrNavigate(string navigationPath, Type sourcePageType, NavigationArguments navArgs = null) @@ -356,8 +356,8 @@ public void SetSelectedPathOrNavigate(string navigationPath, Type sourcePageType } var destPath = navArgs is not null ? navArgs.NavPathParam : navigationPath; - var columnPath = ((ColumnHost.ActiveBlades.ToList().LastOrDefault()?.Content as Frame)?.Content as ColumnShellPage)?.ShellViewModel.WorkingDirectory; - var columnFirstPath = ((ColumnHost.ActiveBlades.ToList().FirstOrDefault()?.Content as Frame)?.Content as ColumnShellPage)?.ShellViewModel.WorkingDirectory; + var columnPath = ((ColumnHost.ActiveBlades.ToList().LastOrDefault()?.Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel.WorkingDirectory; + var columnFirstPath = ((ColumnHost.ActiveBlades.ToList().FirstOrDefault()?.Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel.WorkingDirectory; if (string.IsNullOrEmpty(destPath) || string.IsNullOrEmpty(columnPath) || string.IsNullOrEmpty(columnFirstPath)) { @@ -404,7 +404,7 @@ public void SetSelectedPathOrNavigate(PathNavigationEventArgs e) foreach (var item in ColumnHost.ActiveBlades.ToList()) { if ((item.Content as Frame)?.Content is ColumnShellPage s && - NormalizePath(s.ShellViewModel?.WorkingDirectory) == NormalizePath(e.ItemPath)) + NormalizePath(s.FilesystemViewModel?.WorkingDirectory) == NormalizePath(e.ItemPath)) { DismissOtherBlades(item); return; @@ -415,7 +415,7 @@ public void SetSelectedPathOrNavigate(PathNavigationEventArgs e) if (ParentShellPageInstance is null) return; - if (NormalizePath(ParentShellPageInstance.ShellViewModel?.WorkingDirectory) != NormalizePath(e.ItemPath)) + if (NormalizePath(ParentShellPageInstance.FilesystemViewModel?.WorkingDirectory) != NormalizePath(e.ItemPath)) ParentShellPageInstance.NavigateToPath(e.ItemPath); else DismissOtherBlades(0); @@ -466,7 +466,7 @@ private void CloseUnnecessaryColumns(ColumnParam column) { // Get the index of the blade with the same path as the requested var blade = ColumnHost.ActiveBlades.ToList().FirstOrDefault(b => - column.NavPathParam.Equals(((b.Content as Frame)?.Content as ColumnShellPage)?.ShellViewModel?.WorkingDirectory)); + column.NavPathParam.Equals(((b.Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel?.WorkingDirectory)); if (blade is not null) relativeIndex = ColumnHost.ActiveBlades.IndexOf(blade); diff --git a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs index 15491f85199e..b5a7da48beb1 100644 --- a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs @@ -156,13 +156,13 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs) ColumnsViewModel.GitLastCommitShaColumn = FolderSettings.ColumnsViewModel.GitLastCommitShaColumn; } - ParentShellPageInstance.ShellViewModel.EnabledGitProperties = GetEnabledGitProperties(ColumnsViewModel); + ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties = GetEnabledGitProperties(ColumnsViewModel); FolderSettings.LayoutModeChangeRequested += FolderSettings_LayoutModeChangeRequested; FolderSettings.GroupOptionPreferenceUpdated += ZoomIn; FolderSettings.SortDirectionPreferenceUpdated += FolderSettings_SortDirectionPreferenceUpdated; FolderSettings.SortOptionPreferenceUpdated += FolderSettings_SortOptionPreferenceUpdated; - ParentShellPageInstance.ShellViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated; + ParentShellPageInstance.FilesystemViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated; UserSettingsService.LayoutSettingsService.PropertyChanged += LayoutSettingsService_PropertyChanged; var parameters = (NavigationArguments)eventArgs.Parameter; @@ -189,7 +189,7 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) FolderSettings.GroupOptionPreferenceUpdated -= ZoomIn; FolderSettings.SortDirectionPreferenceUpdated -= FolderSettings_SortDirectionPreferenceUpdated; FolderSettings.SortOptionPreferenceUpdated -= FolderSettings_SortOptionPreferenceUpdated; - ParentShellPageInstance.ShellViewModel.PageTypeUpdated -= FilesystemViewModel_PageTypeUpdated; + ParentShellPageInstance.FilesystemViewModel.PageTypeUpdated -= FilesystemViewModel_PageTypeUpdated; UserSettingsService.LayoutSettingsService.PropertyChanged -= LayoutSettingsService_PropertyChanged; } @@ -410,7 +410,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv if (ctrlPressed && !shiftPressed) { - var folders = ParentShellPageInstance?.LayoutPage.SelectedItems?.Where(file => file.PrimaryItemAttribute == StorageItemTypes.Folder); + var folders = ParentShellPageInstance?.SlimContentPage.SelectedItems?.Where(file => file.PrimaryItemAttribute == StorageItemTypes.Folder); if (folders is not null) { foreach (StandardStorageItem folder in folders) @@ -431,7 +431,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv } else if (e.Key == VirtualKey.Space) { - if (!ParentShellPageInstance.AddressToolbarViewModel.IsEditModeEnabled) + if (!ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) e.Handled = true; } else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up)) @@ -446,7 +446,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv } else if (e.Key == VirtualKey.Down) { - if (isHeaderFocused && !ParentShellPageInstance.AddressToolbarViewModel.IsEditModeEnabled) + if (isHeaderFocused && !ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) { var selectIndex = FileList.SelectedIndex < 0 ? 0 : FileList.SelectedIndex; if (FileList.ContainerFromIndex(selectIndex) is ListViewItem item) @@ -469,24 +469,24 @@ private async Task ReloadItemIconsAsync() if (ParentShellPageInstance is null) return; - ParentShellPageInstance.ShellViewModel.CancelExtendedPropertiesLoading(); - var filesAndFolders = ParentShellPageInstance.ShellViewModel.FilesAndFolders.ToList(); + ParentShellPageInstance.FilesystemViewModel.CancelExtendedPropertiesLoading(); + var filesAndFolders = ParentShellPageInstance.FilesystemViewModel.FilesAndFolders.ToList(); await Task.WhenAll(filesAndFolders.Select(listedItem => { listedItem.ItemPropertiesInitialized = false; if (FileList.ContainerFromItem(listedItem) is not null) - return ParentShellPageInstance.ShellViewModel.LoadExtendedItemPropertiesAsync(listedItem); + return ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemPropertiesAsync(listedItem); else return Task.CompletedTask; })); - if (ParentShellPageInstance.ShellViewModel.EnabledGitProperties is not GitProperties.None) + if (ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties is not GitProperties.None) { await Task.WhenAll(filesAndFolders.Select(item => { if (item is GitItem gitItem) - return ParentShellPageInstance.ShellViewModel.LoadGitPropertiesAsync(gitItem); + return ParentShellPageInstance.FilesystemViewModel.LoadGitPropertiesAsync(gitItem); return Task.CompletedTask; })); @@ -644,7 +644,7 @@ private void GridSplitter_Loaded(object sender, RoutedEventArgs e) private void ToggleMenuFlyoutItem_Click(object sender, RoutedEventArgs e) { FolderSettings.ColumnsViewModel = ColumnsViewModel; - ParentShellPageInstance.ShellViewModel.EnabledGitProperties = GetEnabledGitProperties(ColumnsViewModel); + ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties = GetEnabledGitProperties(ColumnsViewModel); } private void GridSplitter_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs index 936dc34b4b4b..e2a704a81535 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs @@ -138,7 +138,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs) // Set ItemTemplate SetItemTemplate(); SetItemContainerStyle(); - FileList.ItemsSource ??= ParentShellPageInstance.ShellViewModel.FilesAndFolders; + FileList.ItemsSource ??= ParentShellPageInstance.FilesystemViewModel.FilesAndFolders; var parameters = (NavigationArguments)eventArgs.Parameter; if (parameters.IsLayoutSwitch) @@ -443,7 +443,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv if (ctrlPressed && !shiftPressed) { - var folders = ParentShellPageInstance?.LayoutPage.SelectedItems?.Where(file => file.PrimaryItemAttribute == StorageItemTypes.Folder); + var folders = ParentShellPageInstance?.SlimContentPage.SelectedItems?.Where(file => file.PrimaryItemAttribute == StorageItemTypes.Folder); foreach (StandardStorageItem? folder in folders) { if (folder is not null) @@ -462,7 +462,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv } else if (e.Key == VirtualKey.Space) { - if (!ParentShellPageInstance.AddressToolbarViewModel.IsEditModeEnabled) + if (!ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) e.Handled = true; } else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up)) @@ -508,21 +508,21 @@ private async Task ReloadItemIconsAsync() if (ParentShellPageInstance is null) return; - ParentShellPageInstance.ShellViewModel.CancelExtendedPropertiesLoading(); - var filesAndFolders = ParentShellPageInstance.ShellViewModel.FilesAndFolders.ToList(); + ParentShellPageInstance.FilesystemViewModel.CancelExtendedPropertiesLoading(); + var filesAndFolders = ParentShellPageInstance.FilesystemViewModel.FilesAndFolders.ToList(); foreach (StandardStorageItem listedItem in filesAndFolders) { listedItem.ItemPropertiesInitialized = false; if (FileList.ContainerFromItem(listedItem) is not null) - await ParentShellPageInstance.ShellViewModel.LoadExtendedItemPropertiesAsync(listedItem); + await ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemPropertiesAsync(listedItem); } - if (ParentShellPageInstance.ShellViewModel.EnabledGitProperties is not GitProperties.None) + if (ParentShellPageInstance.FilesystemViewModel.EnabledGitProperties is not GitProperties.None) { await Task.WhenAll(filesAndFolders.Select(item => { if (item is GitItem gitItem) - return ParentShellPageInstance.ShellViewModel.LoadGitPropertiesAsync(gitItem); + return ParentShellPageInstance.FilesystemViewModel.LoadGitPropertiesAsync(gitItem); return Task.CompletedTask; })); @@ -699,7 +699,7 @@ private void SelectionCheckbox_PointerCanceled(object sender, PointerRoutedEvent // To avoid crashes, disable scrolling when drag-and-drop if grouped. (#14484) private bool ShouldDisableScrollingWhenDragAndDrop => FolderSettings?.LayoutMode is FolderLayoutModes.GridView or FolderLayoutModes.TilesView && - (ParentShellPageInstance?.ShellViewModel.FilesAndFolders.IsGrouped ?? false); + (ParentShellPageInstance?.FilesystemViewModel.FilesAndFolders.IsGrouped ?? false); protected override void FileList_DragItemsStarting(object sender, DragItemsStartingEventArgs e) { diff --git a/src/Files.App/Views/MainPage.xaml.cs b/src/Files.App/Views/MainPage.xaml.cs index 2828f2f26b06..e6dc0621e687 100644 --- a/src/Files.App/Views/MainPage.xaml.cs +++ b/src/Files.App/Views/MainPage.xaml.cs @@ -185,8 +185,8 @@ public async void MultitaskingControl_CurrentInstanceChanged(object? sender, Cur } SidebarAdaptiveViewModel.NotifyInstanceRelatedPropertiesChanged((navArgs as PaneNavigationArguments)?.LeftPaneNavPathParam); - if (SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.LayoutPage?.StatusBarViewModel is not null) - SidebarAdaptiveViewModel.PaneHolder.ActivePaneOrColumn.LayoutPage.StatusBarViewModel.ShowLocals = true; + if (SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.SlimContentPage?.StatusBarViewModel is not null) + SidebarAdaptiveViewModel.PaneHolder.ActivePaneOrColumn.SlimContentPage.StatusBarViewModel.ShowLocals = true; UpdateStatusBarProperties(); UpdateNavToolbarProperties(); @@ -210,18 +210,18 @@ private void UpdateStatusBarProperties() { if (StatusBar is not null) { - StatusBar.StatusBarViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.LayoutPage?.StatusBarViewModel; - StatusBar.SelectedItemsPropertiesViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.LayoutPage?.SelectedItemsPropertiesViewModel; + StatusBar.StatusBarViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.SlimContentPage?.StatusBarViewModel; + StatusBar.SelectedItemsPropertiesViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.SlimContentPage?.SelectedItemsPropertiesViewModel; } } private void UpdateNavToolbarProperties() { if (NavToolbar is not null) - NavToolbar.ViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.AddressToolbarViewModel; + NavToolbar.ViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.ToolbarViewModel; if (InnerNavigationToolbar is not null) - InnerNavigationToolbar.ViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.AddressToolbarViewModel; + InnerNavigationToolbar.ViewModel = SidebarAdaptiveViewModel.PaneHolder?.ActivePaneOrColumn.ToolbarViewModel; } protected override void OnNavigatedTo(NavigationEventArgs e) diff --git a/src/Files.App/Views/Properties/GeneralPage.xaml.cs b/src/Files.App/Views/Properties/GeneralPage.xaml.cs index 680a31f1a9b2..3f4cd3037aa2 100644 --- a/src/Files.App/Views/Properties/GeneralPage.xaml.cs +++ b/src/Files.App/Views/Properties/GeneralPage.xaml.cs @@ -80,7 +80,7 @@ bool GetNewName(out string newName) bool SaveDrive(DriveItem drive) { - var fsVM = AppInstance.ShellViewModel; + var fsVM = AppInstance.FilesystemViewModel; if (!GetNewName(out var newName) || fsVM is null) return false; @@ -101,7 +101,7 @@ bool SaveDrive(DriveItem drive) async Task SaveLibraryAsync(LibraryItem library) { - var fsVM = AppInstance.ShellViewModel; + var fsVM = AppInstance.FilesystemViewModel; if (!GetNewName(out var newName) || fsVM is null || !App.LibraryManager.CanCreateLibrary(newName).result) return false; @@ -125,7 +125,7 @@ async Task SaveLibraryAsync(LibraryItem library) async Task SaveCombinedAsync(IList fileOrFolders) { // Handle the visibility attribute for multiple files - var itemMM = AppInstance?.LayoutPage?.ItemManipulationModel; + var itemMM = AppInstance?.SlimContentPage?.ItemManipulationModel; if (itemMM is not null) // null on homepage { foreach (var fileOrFolder in fileOrFolders) @@ -147,7 +147,7 @@ await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => { - AppInstance?.ShellViewModel?.RefreshItems(null); + AppInstance?.FilesystemViewModel?.RefreshItems(null); }); } } @@ -158,7 +158,7 @@ await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => async Task SaveBaseAsync(StandardStorageItem item) { // Handle the visibility attribute for a single file - var itemMM = AppInstance?.LayoutPage?.ItemManipulationModel; + var itemMM = AppInstance?.SlimContentPage?.ItemManipulationModel; if (itemMM is not null && ViewModel.IsHiddenEditedValue is not null) // null on homepage { await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => @@ -175,7 +175,7 @@ await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => { - AppInstance?.ShellViewModel?.RefreshItems(null); + AppInstance?.FilesystemViewModel?.RefreshItems(null); }); } diff --git a/src/Files.App/Views/ShellPanesPage.xaml.cs b/src/Files.App/Views/ShellPanesPage.xaml.cs index 1275a5470e20..124d1994ff59 100644 --- a/src/Files.App/Views/ShellPanesPage.xaml.cs +++ b/src/Files.App/Views/ShellPanesPage.xaml.cs @@ -54,7 +54,7 @@ public IShellPage ActivePaneOrColumn get { // Active shell is column view - if (ActivePane is not null && ActivePane.IsColumnView && ActivePane.LayoutPage is ColumnsLayoutPage columnLayoutPage) + if (ActivePane is not null && ActivePane.IsColumnView && ActivePane.SlimContentPage is ColumnsLayoutPage columnLayoutPage) return columnLayoutPage.ActiveColumnShellPage; return ActivePane ?? GetPane(0)!; @@ -470,18 +470,18 @@ private void Pane_GotFocus(object sender, RoutedEventArgs e) var isLeftPane = sender == (GetPane(0) as IShellPage); // Clear selection in left pane - if (isLeftPane && GetPane(1) is ModernShellPage secondShellPage && (secondShellPage.LayoutPage?.IsItemSelected ?? false)) + if (isLeftPane && GetPane(1) is ModernShellPage secondShellPage && (secondShellPage.SlimContentPage?.IsItemSelected ?? false)) { - secondShellPage.LayoutPage.LockPreviewPaneContent = true; - secondShellPage.LayoutPage.ItemManipulationModel.ClearSelection(); - secondShellPage.LayoutPage.LockPreviewPaneContent = false; + secondShellPage.SlimContentPage.LockPreviewPaneContent = true; + secondShellPage.SlimContentPage.ItemManipulationModel.ClearSelection(); + secondShellPage.SlimContentPage.LockPreviewPaneContent = false; } // Clear selection in right pane - else if (!isLeftPane && GetPane(0) is ModernShellPage firstShellPage && (firstShellPage.LayoutPage?.IsItemSelected ?? false)) + else if (!isLeftPane && GetPane(0) is ModernShellPage firstShellPage && (firstShellPage.SlimContentPage?.IsItemSelected ?? false)) { - firstShellPage.LayoutPage.LockPreviewPaneContent = true; - firstShellPage.LayoutPage.ItemManipulationModel.ClearSelection(); - firstShellPage.LayoutPage.LockPreviewPaneContent = false; + firstShellPage.SlimContentPage.LockPreviewPaneContent = true; + firstShellPage.SlimContentPage.ItemManipulationModel.ClearSelection(); + firstShellPage.SlimContentPage.LockPreviewPaneContent = false; } var newActivePane = isLeftPane ? GetPane(0) : GetPane(1); @@ -491,7 +491,7 @@ private void Pane_GotFocus(object sender, RoutedEventArgs e) private void Pane_RightTapped(object sender, RoutedEventArgs e) { - if (sender != ActivePane && sender is IShellPage shellPage && shellPage.LayoutPage is not ColumnsLayoutPage) + if (sender != ActivePane && sender is IShellPage shellPage && shellPage.SlimContentPage is not ColumnsLayoutPage) ((UIElement)sender).Focus(FocusState.Programmatic); } diff --git a/src/Files.App/Views/Shells/BaseShellPage.cs b/src/Files.App/Views/Shells/BaseShellPage.cs index e9283834f2dd..67d7aeb6b3f4 100644 --- a/src/Files.App/Views/Shells/BaseShellPage.cs +++ b/src/Files.App/Views/Shells/BaseShellPage.cs @@ -18,24 +18,13 @@ namespace Files.App.Views.Shells { public abstract class BaseShellPage : Page, IShellPage, INotifyPropertyChanged { - // Dependency injections - - protected DrivesViewModel drivesViewModel { get; } = Ioc.Default.GetRequiredService(); - protected IDialogService dialogService { get; } = Ioc.Default.GetRequiredService(); - protected IUserSettingsService userSettingsService { get; } = Ioc.Default.GetRequiredService(); - protected IUpdateService updateSettingsService { get; } = Ioc.Default.GetRequiredService(); - protected ICommandManager commands { get; } = Ioc.Default.GetRequiredService(); - public AddressToolbarViewModel AddressToolbarViewModel { get; } = new AddressToolbarViewModel(); - private readonly DispatcherQueueTimer _updateDateDisplayTimer; private DateTimeFormats _lastDateTimeFormats; private Task _gitFetch = Task.CompletedTask; - private CancellationTokenSource _gitFetchToken = new(); - - protected readonly CancellationTokenSource cancellationTokenSource; + private CancellationTokenSource _gitFetchToken = new CancellationTokenSource(); public static readonly DependencyProperty NavParamsProperty = DependencyProperty.Register( @@ -46,7 +35,21 @@ public abstract class BaseShellPage : Page, IShellPage, INotifyPropertyChanged public StorageHistoryHelpers StorageHistoryHelpers { get; } - public IBaseLayoutPage LayoutPage => ContentPage; + protected readonly CancellationTokenSource cancellationTokenSource; + + protected readonly DrivesViewModel drivesViewModel = Ioc.Default.GetRequiredService(); + + protected readonly IDialogService dialogService = Ioc.Default.GetRequiredService(); + + protected readonly IUserSettingsService userSettingsService = Ioc.Default.GetRequiredService(); + + protected readonly IUpdateService updateSettingsService = Ioc.Default.GetRequiredService(); + + protected readonly ICommandManager commands = Ioc.Default.GetRequiredService(); + + public AddressToolbarViewModel ToolbarViewModel { get; } = new AddressToolbarViewModel(); + + public IBaseLayoutPage SlimContentPage => ContentPage; public IFilesystemHelpers FilesystemHelpers { get; protected set; } @@ -54,15 +57,17 @@ public abstract class BaseShellPage : Page, IShellPage, INotifyPropertyChanged public LayoutPreferencesManager FolderSettings => InstanceViewModel.FolderSettings; + public AppModel AppModel => App.AppModel; + protected abstract Frame ItemDisplay { get; } public abstract bool CanNavigateForward { get; } public abstract bool CanNavigateBackward { get; } - public bool IsColumnView => LayoutPage is ColumnsLayoutPage; + public bool IsColumnView => SlimContentPage is ColumnsLayoutPage; - public ShellViewModel ShellViewModel { get; protected set; } + public ItemViewModel FilesystemViewModel { get; protected set; } public CurrentInstanceViewModel InstanceViewModel { get; } @@ -80,7 +85,7 @@ public BaseLayoutPage ContentPage _ContentPage = value; NotifyPropertyChanged(nameof(ContentPage)); - NotifyPropertyChanged(nameof(LayoutPage)); + NotifyPropertyChanged(nameof(SlimContentPage)); if (value is not null) _ContentPage.StatusBarViewModel.CheckoutRequested += GitCheckout_Required; } @@ -118,7 +123,6 @@ public TabBarItemParameter TabBarItemParameter } protected TaskCompletionSource _IsCurrentInstanceTCS = new(); - protected bool _IsCurrentInstance = false; public bool IsCurrentInstance { @@ -129,8 +133,8 @@ public bool IsCurrentInstance { _IsCurrentInstance = value; - if (!value && LayoutPage is not ColumnsLayoutPage) - AddressToolbarViewModel.IsEditModeEnabled = false; + if (!value && SlimContentPage is not ColumnsLayoutPage) + ToolbarViewModel.IsEditModeEnabled = false; if (value) _IsCurrentInstanceTCS.TrySetResult(); @@ -150,12 +154,9 @@ public bool IsCurrentInstance public virtual Task WhenIsCurrent() => _IsCurrentInstanceTCS.Task; - // Events - public event PropertyChangedEventHandler PropertyChanged; - public event EventHandler ContentChanged; - // Constructor + public event EventHandler ContentChanged; public BaseShellPage(CurrentInstanceViewModel instanceViewModel) { @@ -165,7 +166,7 @@ public BaseShellPage(CurrentInstanceViewModel instanceViewModel) FilesystemHelpers = new FilesystemHelpers(this, cancellationTokenSource.Token); StorageHistoryHelpers = new StorageHistoryHelpers(new StorageHistoryOperations(this, cancellationTokenSource.Token)); - AddressToolbarViewModel.InstanceViewModel = InstanceViewModel; + ToolbarViewModel.InstanceViewModel = InstanceViewModel; InitToolbarCommands(); @@ -174,18 +175,18 @@ public BaseShellPage(CurrentInstanceViewModel instanceViewModel) if (FilePropertiesHelpers.FlowDirectionSettingIsRightToLeft) FlowDirection = FlowDirection.RightToLeft; - AddressToolbarViewModel.ToolbarPathItemInvoked += ShellPage_NavigationRequested; - AddressToolbarViewModel.ToolbarFlyoutOpened += ShellPage_ToolbarFlyoutOpened; - AddressToolbarViewModel.ToolbarPathItemLoaded += ShellPage_ToolbarPathItemLoaded; - AddressToolbarViewModel.AddressBarTextEntered += ShellPage_AddressBarTextEntered; - AddressToolbarViewModel.PathBoxItemDropped += ShellPage_PathBoxItemDropped; + ToolbarViewModel.ToolbarPathItemInvoked += ShellPage_NavigationRequested; + ToolbarViewModel.ToolbarFlyoutOpened += ShellPage_ToolbarFlyoutOpened; + ToolbarViewModel.ToolbarPathItemLoaded += ShellPage_ToolbarPathItemLoaded; + ToolbarViewModel.AddressBarTextEntered += ShellPage_AddressBarTextEntered; + ToolbarViewModel.PathBoxItemDropped += ShellPage_PathBoxItemDropped; - AddressToolbarViewModel.RefreshRequested += ShellPage_RefreshRequested; - AddressToolbarViewModel.EditModeEnabled += NavigationToolbar_EditModeEnabled; - AddressToolbarViewModel.ItemDraggedOverPathItem += ShellPage_NavigationRequested; - AddressToolbarViewModel.PathBoxQuerySubmitted += NavigationToolbar_QuerySubmitted; - AddressToolbarViewModel.SearchBox.TextChanged += ShellPage_TextChanged; - AddressToolbarViewModel.SearchBox.QuerySubmitted += ShellPage_QuerySubmitted; + ToolbarViewModel.RefreshRequested += ShellPage_RefreshRequested; + ToolbarViewModel.EditModeEnabled += NavigationToolbar_EditModeEnabled; + ToolbarViewModel.ItemDraggedOverPathItem += ShellPage_NavigationRequested; + ToolbarViewModel.PathBoxQuerySubmitted += NavigationToolbar_QuerySubmitted; + ToolbarViewModel.SearchBox.TextChanged += ShellPage_TextChanged; + ToolbarViewModel.SearchBox.QuerySubmitted += ShellPage_QuerySubmitted; InstanceViewModel.FolderSettings.SortDirectionPreferenceUpdated += AppSettings_SortDirectionPreferenceUpdated; InstanceViewModel.FolderSettings.SortOptionPreferenceUpdated += AppSettings_SortOptionPreferenceUpdated; @@ -207,8 +208,6 @@ public BaseShellPage(CurrentInstanceViewModel instanceViewModel) _updateDateDisplayTimer.Start(); } - // Methods - protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "") { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); @@ -231,16 +230,16 @@ protected async void FilesystemViewModel_DirectoryInfoUpdated(object sender, Eve if (ContentPage is null) return; - var directoryItemCountLocalization = "Items".GetLocalizedFormatResource(ShellViewModel.FilesAndFolders.Count); + var directoryItemCountLocalization = "Items".GetLocalizedFormatResource(FilesystemViewModel.FilesAndFolders.Count); BranchItem? headBranch = headBranch = InstanceViewModel.IsGitRepository ? await GitHelpers.GetRepositoryHead(InstanceViewModel.GitRepositoryPath) : null; - if (InstanceViewModel.GitRepositoryPath != ShellViewModel.GitDirectory) + if (InstanceViewModel.GitRepositoryPath != FilesystemViewModel.GitDirectory) { - InstanceViewModel.GitRepositoryPath = ShellViewModel.GitDirectory; - InstanceViewModel.IsGitRepository = ShellViewModel.IsValidGitDirectory; + InstanceViewModel.GitRepositoryPath = FilesystemViewModel.GitDirectory; + InstanceViewModel.IsGitRepository = FilesystemViewModel.IsValidGitDirectory; InstanceViewModel.GitBranchName = headBranch is not null ? headBranch.Name @@ -272,7 +271,7 @@ protected async void FilesystemViewModel_DirectoryInfoUpdated(object sender, Eve headBranch); } - contentPage.StatusBarViewModel.DirectoryItemCount = $"{ShellViewModel.FilesAndFolders.Count} {directoryItemCountLocalization}"; + contentPage.StatusBarViewModel.DirectoryItemCount = $"{FilesystemViewModel.FilesAndFolders.Count} {directoryItemCountLocalization}"; contentPage.UpdateSelectionSize(); } @@ -297,7 +296,7 @@ protected async void FilesystemViewModel_GitDirectoryUpdated(object sender, Even protected async void GitCheckout_Required(object? sender, string branchName) { - if (!await GitHelpers.Checkout(ShellViewModel.GitDirectory, branchName)) + if (!await GitHelpers.Checkout(FilesystemViewModel.GitDirectory, branchName)) { _ContentPage.StatusBarViewModel.ShowLocals = true; _ContentPage.StatusBarViewModel.SelectedBranchIndex = StatusBarViewModel.ACTIVE_BRANCH_INDEX; @@ -356,15 +355,15 @@ protected async void ShellPage_TextChanged(ISearchBoxViewModel sender, SearchBox if (e.Reason != SearchBoxTextChangeReason.UserInput) return; - ShellViewModel.FilesAndFoldersFilter = sender.Query; - await ShellViewModel.ApplyFilesAndFoldersChangesAsync(); + FilesystemViewModel.FilesAndFoldersFilter = sender.Query; + await FilesystemViewModel.ApplyFilesAndFoldersChangesAsync(); if (!string.IsNullOrWhiteSpace(sender.Query)) { var search = new FolderSearch { Query = sender.Query, - Folder = ShellViewModel.WorkingDirectory, + Folder = FilesystemViewModel.WorkingDirectory, MaxItemCount = 10, }; @@ -383,22 +382,22 @@ protected async void ShellPage_RefreshRequested(object sender, EventArgs e) protected void AppSettings_SortDirectionPreferenceUpdated(object sender, SortDirection e) { - ShellViewModel?.UpdateSortDirectionStatusAsync(); + FilesystemViewModel?.UpdateSortDirectionStatusAsync(); } protected void AppSettings_SortOptionPreferenceUpdated(object sender, SortOption e) { - ShellViewModel?.UpdateSortOptionStatusAsync(); + FilesystemViewModel?.UpdateSortOptionStatusAsync(); } protected void AppSettings_SortDirectoriesAlongsideFilesPreferenceUpdated(object sender, bool e) { - ShellViewModel?.UpdateSortDirectoriesAlongsideFilesAsync(); + FilesystemViewModel?.UpdateSortDirectoriesAlongsideFilesAsync(); } protected void AppSettings_SortFilesFirstPreferenceUpdated(object sender, bool e) { - ShellViewModel?.UpdateSortFilesFirstAsync(); + FilesystemViewModel?.UpdateSortFilesFirstAsync(); } protected void CoreWindow_PointerPressed(object sender, PointerRoutedEventArgs args) @@ -420,12 +419,12 @@ protected async void ShellPage_PathBoxItemDropped(object sender, PathBoxItemDrop protected async void ShellPage_AddressBarTextEntered(object sender, AddressBarTextEnteredEventArgs e) { - await AddressToolbarViewModel.SetAddressBarSuggestionsAsync(e.AddressBarTextField, this); + await ToolbarViewModel.SetAddressBarSuggestionsAsync(e.AddressBarTextField, this); } protected async void ShellPage_ToolbarPathItemLoaded(object sender, ToolbarPathItemLoadedEventArgs e) { - await AddressToolbarViewModel.SetPathBoxDropDownFlyoutAsync(e.OpenedFlyout, e.Item, this); + await ToolbarViewModel.SetPathBoxDropDownFlyoutAsync(e.OpenedFlyout, e.Item, this); } protected async void ShellPage_ToolbarFlyoutOpened(object sender, ToolbarFlyoutOpenedEventArgs e) @@ -433,21 +432,21 @@ protected async void ShellPage_ToolbarFlyoutOpened(object sender, ToolbarFlyoutO var pathBoxItem = ((Button)e.OpenedFlyout.Target).DataContext as PathBoxItem; if (pathBoxItem is not null) - await AddressToolbarViewModel.SetPathBoxDropDownFlyoutAsync(e.OpenedFlyout, pathBoxItem, this); + await ToolbarViewModel.SetPathBoxDropDownFlyoutAsync(e.OpenedFlyout, pathBoxItem, this); } protected async void NavigationToolbar_QuerySubmitted(object sender, ToolbarQuerySubmittedEventArgs e) { - await AddressToolbarViewModel.CheckPathInputAsync(e.QueryText, AddressToolbarViewModel.PathComponents.LastOrDefault()?.Path, this); + await ToolbarViewModel.CheckPathInputAsync(e.QueryText, ToolbarViewModel.PathComponents.LastOrDefault()?.Path, this); } protected void NavigationToolbar_EditModeEnabled(object sender, EventArgs e) { - AddressToolbarViewModel.ManualEntryBoxLoaded = true; - AddressToolbarViewModel.ClickablePathLoaded = false; - AddressToolbarViewModel.PathText = string.IsNullOrEmpty(ShellViewModel?.WorkingDirectory) + ToolbarViewModel.ManualEntryBoxLoaded = true; + ToolbarViewModel.ClickablePathLoaded = false; + ToolbarViewModel.PathText = string.IsNullOrEmpty(FilesystemViewModel?.WorkingDirectory) ? Constants.UserEnvironmentPaths.HomePath - : ShellViewModel.WorkingDirectory; + : FilesystemViewModel.WorkingDirectory; } protected async void DrivesManager_PropertyChanged(object sender, PropertyChangedEventArgs e) @@ -473,40 +472,40 @@ public async Task UpdatePathUIToWorkingDirectoryAsync(string newWorkingDir, stri if (cts.IsCancellationRequested) return; - AddressToolbarViewModel.PathComponents.Clear(); + ToolbarViewModel.PathComponents.Clear(); foreach (var component in components) - AddressToolbarViewModel.PathComponents.Add(component); + ToolbarViewModel.PathComponents.Add(component); } else { cts?.Cancel(); // Clear the path UI - AddressToolbarViewModel.PathComponents.Clear(); - AddressToolbarViewModel.IsSingleItemOverride = true; - AddressToolbarViewModel.PathComponents.Add(new PathBoxItem() { Path = null, Title = singleItemOverride }); + ToolbarViewModel.PathComponents.Clear(); + ToolbarViewModel.IsSingleItemOverride = true; + ToolbarViewModel.PathComponents.Add(new PathBoxItem() { Path = null, Title = singleItemOverride }); } } public void SubmitSearch(string query) { - ShellViewModel.CancelSearch(); + FilesystemViewModel.CancelSearch(); InstanceViewModel.CurrentSearchQuery = query; var args = new NavigationArguments() { AssociatedTabInstance = this, IsSearchResultPage = true, - SearchPathParam = ShellViewModel.WorkingDirectory, + SearchPathParam = FilesystemViewModel.WorkingDirectory, SearchQuery = query, }; - var layout = InstanceViewModel.FolderSettings.GetLayoutType(ShellViewModel.WorkingDirectory); + var layout = InstanceViewModel.FolderSettings.GetLayoutType(FilesystemViewModel.WorkingDirectory); if (layout == typeof(ColumnsLayoutPage)) - NavigateToPath(ShellViewModel.WorkingDirectory, typeof(DetailsLayoutPage), args); + NavigateToPath(FilesystemViewModel.WorkingDirectory, typeof(DetailsLayoutPage), args); else - NavigateToPath(ShellViewModel.WorkingDirectory, layout, args); + NavigateToPath(FilesystemViewModel.WorkingDirectory, layout, args); } public void NavigateWithArguments(Type sourcePageType, NavigationArguments navArgs) @@ -527,17 +526,17 @@ public void NavigateToPath(string navigationPath, NavigationArguments? navArgs = public Task TabItemDragOver(object sender, DragEventArgs e) { - return LayoutPage?.CommandsViewModel.DragOverAsync(e); + return SlimContentPage?.CommandsViewModel.DragOverAsync(e); } public Task TabItemDrop(object sender, DragEventArgs e) { - return LayoutPage?.CommandsViewModel.DropAsync(e); + return SlimContentPage?.CommandsViewModel.DropAsync(e); } public async Task RefreshIfNoWatcherExistsAsync() { - if (ShellViewModel.HasNoWatcher) + if (FilesystemViewModel.HasNoWatcher) await Refresh_Click(); } @@ -545,20 +544,20 @@ public async Task Refresh_Click() { if (InstanceViewModel.IsPageTypeSearchResults) { - AddressToolbarViewModel.CanRefresh = false; + ToolbarViewModel.CanRefresh = false; var searchInstance = new FolderSearch { Query = InstanceViewModel.CurrentSearchQuery ?? (string)TabBarItemParameter.NavigationParameter, - Folder = ShellViewModel.WorkingDirectory, + Folder = FilesystemViewModel.WorkingDirectory, ThumbnailSize = InstanceViewModel.FolderSettings.GetRoundedIconSize(), }; - await ShellViewModel.SearchAsync(searchInstance); + await FilesystemViewModel.SearchAsync(searchInstance); } else if (CurrentPageType != typeof(HomePage)) { - AddressToolbarViewModel.CanRefresh = false; - ShellViewModel?.RefreshItems(null); + ToolbarViewModel.CanRefresh = false; + FilesystemViewModel?.RefreshItems(null); } } @@ -631,19 +630,19 @@ protected void FilesystemViewModel_ItemLoadStatusChanged(object sender, ItemLoad switch (e.Status) { case ItemLoadStatusChangedEventArgs.ItemLoadStatus.Starting: - AddressToolbarViewModel.CanRefresh = false; + ToolbarViewModel.CanRefresh = false; SetLoadingIndicatorForTabs(true); break; case ItemLoadStatusChangedEventArgs.ItemLoadStatus.InProgress: var columnCanNavigateBackward = false; var columnCanNavigateForward = false; - if (LayoutPage is ColumnsLayoutPage browser) + if (SlimContentPage is ColumnsLayoutPage browser) { columnCanNavigateBackward = browser.ParentShellPageInstance?.CanNavigateBackward ?? false; columnCanNavigateForward = browser.ParentShellPageInstance?.CanNavigateForward ?? false; } - AddressToolbarViewModel.CanGoBack = ItemDisplay.CanGoBack || columnCanNavigateBackward; - AddressToolbarViewModel.CanGoForward = ItemDisplay.CanGoForward || columnCanNavigateForward; + ToolbarViewModel.CanGoBack = ItemDisplay.CanGoBack || columnCanNavigateBackward; + ToolbarViewModel.CanGoForward = ItemDisplay.CanGoForward || columnCanNavigateForward; SetLoadingIndicatorForTabs(true); break; case ItemLoadStatusChangedEventArgs.ItemLoadStatus.Complete: @@ -652,7 +651,7 @@ protected void FilesystemViewModel_ItemLoadStatusChanged(object sender, ItemLoad if (ContentPage is not null) ContentPage.ItemManipulationModel.ScrollToTop(); - AddressToolbarViewModel.CanRefresh = true; + ToolbarViewModel.CanRefresh = true; // Select previous directory if (!string.IsNullOrWhiteSpace(e.PreviousDirectory) && e.PreviousDirectory.Contains(e.Path, StringComparison.Ordinal) && @@ -685,7 +684,7 @@ protected void FilesystemViewModel_ItemLoadStatusChanged(object sender, ItemLoad if (folderToSelect.EndsWith(separator)) folderToSelect = folderToSelect.Remove(folderToSelect.Length - 1, 1); - var itemToSelect = ShellViewModel.FilesAndFolders.ToList().FirstOrDefault((item) => item.ItemPath == folderToSelect); + var itemToSelect = FilesystemViewModel.FilesAndFolders.ToList().FirstOrDefault((item) => item.ItemPath == folderToSelect); if (itemToSelect is not null && ContentPage is not null && userSettingsService.FoldersSettingsService.ScrollToPreviousFolderWhenNavigatingUp) { @@ -715,9 +714,9 @@ protected virtual void ShellPage_NavigationRequested(object sender, PathNavigati protected void InitToolbarCommands() { - AddressToolbarViewModel.OpenNewWindowCommand = new AsyncRelayCommand(NavigationHelpers.LaunchNewWindowAsync); - AddressToolbarViewModel.CreateNewFileCommand = new RelayCommand(x => UIFilesystemHelpers.CreateFileFromDialogResultTypeAsync(AddItemDialogItemType.File, x, this)); - AddressToolbarViewModel.UpdateCommand = new AsyncRelayCommand(async () => await updateSettingsService.DownloadUpdatesAsync()); + ToolbarViewModel.OpenNewWindowCommand = new AsyncRelayCommand(NavigationHelpers.LaunchNewWindowAsync); + ToolbarViewModel.CreateNewFileCommand = new RelayCommand(x => UIFilesystemHelpers.CreateFileFromDialogResultTypeAsync(AddItemDialogItemType.File, x, this)); + ToolbarViewModel.UpdateCommand = new AsyncRelayCommand(async () => await updateSettingsService.DownloadUpdatesAsync()); } protected async Task GetContentOrNullAsync() @@ -752,7 +751,7 @@ await DispatcherQueue.EnqueueOrInvokeAsync(async () => protected void SelectSidebarItemFromPath(Type incomingSourcePageType = null) { if (incomingSourcePageType == typeof(HomePage) && incomingSourcePageType is not null) - AddressToolbarViewModel.PathControlDisplayText = "Home".GetLocalizedResource(); + ToolbarViewModel.PathControlDisplayText = "Home".GetLocalizedResource(); } protected void SetLoadingIndicatorForTabs(bool isLoading) @@ -798,11 +797,11 @@ private void UpdateDateDisplayTimer_Tick(object sender, object e) if (userSettingsService.GeneralSettingsService.DateTimeFormat != _lastDateTimeFormats) { _lastDateTimeFormats = userSettingsService.GeneralSettingsService.DateTimeFormat; - ShellViewModel?.UpdateDateDisplay(true); + FilesystemViewModel?.UpdateDateDisplay(true); } else if (userSettingsService.GeneralSettingsService.DateTimeFormat == DateTimeFormats.Application) { - ShellViewModel?.UpdateDateDisplay(false); + FilesystemViewModel?.UpdateDateDisplay(false); } } @@ -812,16 +811,16 @@ public virtual void Dispose() PointerPressed -= CoreWindow_PointerPressed; drivesViewModel.PropertyChanged -= DrivesManager_PropertyChanged; - AddressToolbarViewModel.ToolbarPathItemInvoked -= ShellPage_NavigationRequested; - AddressToolbarViewModel.ToolbarFlyoutOpened -= ShellPage_ToolbarFlyoutOpened; - AddressToolbarViewModel.ToolbarPathItemLoaded -= ShellPage_ToolbarPathItemLoaded; - AddressToolbarViewModel.AddressBarTextEntered -= ShellPage_AddressBarTextEntered; - AddressToolbarViewModel.PathBoxItemDropped -= ShellPage_PathBoxItemDropped; - AddressToolbarViewModel.RefreshRequested -= ShellPage_RefreshRequested; - AddressToolbarViewModel.EditModeEnabled -= NavigationToolbar_EditModeEnabled; - AddressToolbarViewModel.ItemDraggedOverPathItem -= ShellPage_NavigationRequested; - AddressToolbarViewModel.PathBoxQuerySubmitted -= NavigationToolbar_QuerySubmitted; - AddressToolbarViewModel.SearchBox.TextChanged -= ShellPage_TextChanged; + ToolbarViewModel.ToolbarPathItemInvoked -= ShellPage_NavigationRequested; + ToolbarViewModel.ToolbarFlyoutOpened -= ShellPage_ToolbarFlyoutOpened; + ToolbarViewModel.ToolbarPathItemLoaded -= ShellPage_ToolbarPathItemLoaded; + ToolbarViewModel.AddressBarTextEntered -= ShellPage_AddressBarTextEntered; + ToolbarViewModel.PathBoxItemDropped -= ShellPage_PathBoxItemDropped; + ToolbarViewModel.RefreshRequested -= ShellPage_RefreshRequested; + ToolbarViewModel.EditModeEnabled -= NavigationToolbar_EditModeEnabled; + ToolbarViewModel.ItemDraggedOverPathItem -= ShellPage_NavigationRequested; + ToolbarViewModel.PathBoxQuerySubmitted -= NavigationToolbar_QuerySubmitted; + ToolbarViewModel.SearchBox.TextChanged -= ShellPage_TextChanged; InstanceViewModel.FolderSettings.LayoutPreferencesUpdateRequired -= FolderSettings_LayoutPreferencesUpdateRequired; InstanceViewModel.FolderSettings.SortDirectionPreferenceUpdated -= AppSettings_SortDirectionPreferenceUpdated; @@ -830,15 +829,15 @@ public virtual void Dispose() InstanceViewModel.FolderSettings.SortFilesFirstPreferenceUpdated -= AppSettings_SortFilesFirstPreferenceUpdated; // Prevent weird case of this being null when many tabs are opened/closed quickly - if (ShellViewModel is not null) + if (FilesystemViewModel is not null) { - ShellViewModel.WorkingDirectoryModified -= ViewModel_WorkingDirectoryModified; - ShellViewModel.ItemLoadStatusChanged -= FilesystemViewModel_ItemLoadStatusChanged; - ShellViewModel.DirectoryInfoUpdated -= FilesystemViewModel_DirectoryInfoUpdated; - ShellViewModel.PageTypeUpdated -= FilesystemViewModel_PageTypeUpdated; - ShellViewModel.OnSelectionRequestedEvent -= FilesystemViewModel_OnSelectionRequestedEvent; - ShellViewModel.GitDirectoryUpdated -= FilesystemViewModel_GitDirectoryUpdated; - ShellViewModel.Dispose(); + FilesystemViewModel.WorkingDirectoryModified -= ViewModel_WorkingDirectoryModified; + FilesystemViewModel.ItemLoadStatusChanged -= FilesystemViewModel_ItemLoadStatusChanged; + FilesystemViewModel.DirectoryInfoUpdated -= FilesystemViewModel_DirectoryInfoUpdated; + FilesystemViewModel.PageTypeUpdated -= FilesystemViewModel_PageTypeUpdated; + FilesystemViewModel.OnSelectionRequestedEvent -= FilesystemViewModel_OnSelectionRequestedEvent; + FilesystemViewModel.GitDirectoryUpdated -= FilesystemViewModel_GitDirectoryUpdated; + FilesystemViewModel.Dispose(); } if (ItemDisplay.Content is IDisposable disposableContent) diff --git a/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs b/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs index 2b951248419f..e6b0f57a1485 100644 --- a/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs +++ b/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs @@ -76,19 +76,19 @@ protected override void OnNavigationParamsChanged() protected override void Page_Loaded(object sender, RoutedEventArgs e) { - ShellViewModel = new ShellViewModel(InstanceViewModel?.FolderSettings); - ShellViewModel.WorkingDirectoryModified += ViewModel_WorkingDirectoryModified; - ShellViewModel.ItemLoadStatusChanged += FilesystemViewModel_ItemLoadStatusChanged; - ShellViewModel.DirectoryInfoUpdated += FilesystemViewModel_DirectoryInfoUpdated; - ShellViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated; - ShellViewModel.OnSelectionRequestedEvent += FilesystemViewModel_OnSelectionRequestedEvent; - ShellViewModel.GitDirectoryUpdated += FilesystemViewModel_GitDirectoryUpdated; + FilesystemViewModel = new ItemViewModel(InstanceViewModel?.FolderSettings); + FilesystemViewModel.WorkingDirectoryModified += ViewModel_WorkingDirectoryModified; + FilesystemViewModel.ItemLoadStatusChanged += FilesystemViewModel_ItemLoadStatusChanged; + FilesystemViewModel.DirectoryInfoUpdated += FilesystemViewModel_DirectoryInfoUpdated; + FilesystemViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated; + FilesystemViewModel.OnSelectionRequestedEvent += FilesystemViewModel_OnSelectionRequestedEvent; + FilesystemViewModel.GitDirectoryUpdated += FilesystemViewModel_GitDirectoryUpdated; PaneHolder = this.FindAscendant()?.ParentShellPageInstance?.PaneHolder; base.Page_Loaded(sender, e); - NotifyPropertyChanged(nameof(ShellViewModel)); + NotifyPropertyChanged(nameof(FilesystemViewModel)); } protected override async void ViewModel_WorkingDirectoryModified(object sender, WorkingDirectoryModifiedEventArgs e) @@ -102,10 +102,10 @@ private async void ItemDisplayFrame_Navigated(object sender, NavigationEventArgs { ContentPage = await GetContentOrNullAsync(); - if (!AddressToolbarViewModel.SearchBox.WasQuerySubmitted) + if (!ToolbarViewModel.SearchBox.WasQuerySubmitted) { - AddressToolbarViewModel.SearchBox.Query = string.Empty; - AddressToolbarViewModel.IsSearchBoxVisible = false; + ToolbarViewModel.SearchBox.Query = string.Empty; + ToolbarViewModel.IsSearchBoxVisible = false; } if (ItemDisplayFrame.CurrentSourcePageType == typeof(ColumnLayoutPage)) @@ -139,15 +139,15 @@ private async void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, Keybo { // Ctrl + V, Paste case (true, false, false, true, VirtualKey.V): - if (!AddressToolbarViewModel.IsEditModeEnabled && !ContentPage.IsRenamingItem && !InstanceViewModel.IsPageTypeSearchResults && !AddressToolbarViewModel.SearchHasFocus) - await UIFilesystemHelpers.PasteItemAsync(ShellViewModel.WorkingDirectory, this); + if (!ToolbarViewModel.IsEditModeEnabled && !ContentPage.IsRenamingItem && !InstanceViewModel.IsPageTypeSearchResults && !ToolbarViewModel.SearchHasFocus) + await UIFilesystemHelpers.PasteItemAsync(FilesystemViewModel.WorkingDirectory, this); break; } } public override void Back_Click() { - AddressToolbarViewModel.CanGoBack = false; + ToolbarViewModel.CanGoBack = false; if (ItemDisplayFrame.CanGoBack) base.Back_Click(); else @@ -156,7 +156,7 @@ public override void Back_Click() public override void Forward_Click() { - AddressToolbarViewModel.CanGoForward = false; + ToolbarViewModel.CanGoForward = false; if (ItemDisplayFrame.CanGoForward) base.Forward_Click(); else @@ -165,7 +165,7 @@ public override void Forward_Click() public override void Up_Click() { - if (!AddressToolbarViewModel.CanNavigateToParent) + if (!ToolbarViewModel.CanNavigateToParent) return; this.FindAscendant()?.NavigateUp(); @@ -191,13 +191,13 @@ public void RemoveLastPageFromBackStack() public void SubmitSearch(string query) { - ShellViewModel.CancelSearch(); + FilesystemViewModel.CancelSearch(); InstanceViewModel.CurrentSearchQuery = query; ItemDisplayFrame.Navigate(typeof(ColumnLayoutPage), new NavigationArguments() { AssociatedTabInstance = this, IsSearchResultPage = true, - SearchPathParam = ShellViewModel.WorkingDirectory, + SearchPathParam = FilesystemViewModel.WorkingDirectory, SearchQuery = query, }); diff --git a/src/Files.App/Views/Shells/ModernShellPage.xaml.cs b/src/Files.App/Views/Shells/ModernShellPage.xaml.cs index fca0755462a5..86e7d99f52a5 100644 --- a/src/Files.App/Views/Shells/ModernShellPage.xaml.cs +++ b/src/Files.App/Views/Shells/ModernShellPage.xaml.cs @@ -44,16 +44,16 @@ public ModernShellPage() : base(new CurrentInstanceViewModel()) { InitializeComponent(); - ShellViewModel = new ShellViewModel(InstanceViewModel.FolderSettings); - ShellViewModel.WorkingDirectoryModified += ViewModel_WorkingDirectoryModified; - ShellViewModel.ItemLoadStatusChanged += FilesystemViewModel_ItemLoadStatusChanged; - ShellViewModel.DirectoryInfoUpdated += FilesystemViewModel_DirectoryInfoUpdated; - ShellViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated; - ShellViewModel.OnSelectionRequestedEvent += FilesystemViewModel_OnSelectionRequestedEvent; - ShellViewModel.GitDirectoryUpdated += FilesystemViewModel_GitDirectoryUpdated; + FilesystemViewModel = new ItemViewModel(InstanceViewModel.FolderSettings); + FilesystemViewModel.WorkingDirectoryModified += ViewModel_WorkingDirectoryModified; + FilesystemViewModel.ItemLoadStatusChanged += FilesystemViewModel_ItemLoadStatusChanged; + FilesystemViewModel.DirectoryInfoUpdated += FilesystemViewModel_DirectoryInfoUpdated; + FilesystemViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated; + FilesystemViewModel.OnSelectionRequestedEvent += FilesystemViewModel_OnSelectionRequestedEvent; + FilesystemViewModel.GitDirectoryUpdated += FilesystemViewModel_GitDirectoryUpdated; - AddressToolbarViewModel.PathControlDisplayText = "Home".GetLocalizedResource(); - AddressToolbarViewModel.RefreshWidgetsRequested += ModernShellPage_RefreshWidgetsRequested; + ToolbarViewModel.PathControlDisplayText = "Home".GetLocalizedResource(); + ToolbarViewModel.RefreshWidgetsRequested += ModernShellPage_RefreshWidgetsRequested; _navigationInteractionTracker = new NavigationInteractionTracker(this, BackIcon, ForwardIcon); _navigationInteractionTracker.NavigationRequested += OverscrollNavigationRequested; @@ -67,12 +67,12 @@ private void ModernShellPage_RefreshWidgetsRequested(object sender, EventArgs e) protected override void FolderSettings_LayoutPreferencesUpdateRequired(object sender, LayoutPreferenceEventArgs e) { - if (ShellViewModel is null) + if (FilesystemViewModel is null) return; - LayoutPreferencesManager.SetLayoutPreferencesForPath(ShellViewModel.WorkingDirectory, e.LayoutPreference); + LayoutPreferencesManager.SetLayoutPreferencesForPath(FilesystemViewModel.WorkingDirectory, e.LayoutPreference); if (e.IsAdaptiveLayoutUpdateRequired) - AdaptiveLayoutHelpers.ApplyAdaptativeLayout(InstanceViewModel.FolderSettings, ShellViewModel.WorkingDirectory, ShellViewModel.FilesAndFolders.ToList()); + AdaptiveLayoutHelpers.ApplyAdaptativeLayout(InstanceViewModel.FolderSettings, FilesystemViewModel.WorkingDirectory, FilesystemViewModel.FilesAndFolders.ToList()); } protected override void OnNavigatedTo(NavigationEventArgs eventArgs) @@ -138,13 +138,13 @@ protected override async void ViewModel_WorkingDirectoryModified(object sender, private async void ItemDisplayFrame_Navigated(object sender, NavigationEventArgs e) { ContentPage = await GetContentOrNullAsync(); - if (!AddressToolbarViewModel.SearchBox.WasQuerySubmitted) + if (!ToolbarViewModel.SearchBox.WasQuerySubmitted) { - AddressToolbarViewModel.SearchBox.Query = string.Empty; - AddressToolbarViewModel.IsSearchBoxVisible = false; + ToolbarViewModel.SearchBox.Query = string.Empty; + ToolbarViewModel.IsSearchBoxVisible = false; } - AddressToolbarViewModel.UpdateAdditionalActions(); + ToolbarViewModel.UpdateAdditionalActions(); if (ItemDisplayFrame.CurrentSourcePageType == (typeof(DetailsLayoutPage)) || ItemDisplayFrame.CurrentSourcePageType == typeof(GridLayoutPage)) { @@ -181,8 +181,8 @@ private async void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, Keybo { // Ctrl + V, Paste case (true, false, false, true, VirtualKey.V): - if (!AddressToolbarViewModel.IsEditModeEnabled && !ContentPage.IsRenamingItem && !InstanceViewModel.IsPageTypeSearchResults && !AddressToolbarViewModel.SearchHasFocus) - await UIFilesystemHelpers.PasteItemAsync(ShellViewModel.WorkingDirectory, this); + if (!ToolbarViewModel.IsEditModeEnabled && !ContentPage.IsRenamingItem && !InstanceViewModel.IsPageTypeSearchResults && !ToolbarViewModel.SearchHasFocus) + await UIFilesystemHelpers.PasteItemAsync(FilesystemViewModel.WorkingDirectory, this); break; } } @@ -203,7 +203,7 @@ private void OverscrollNavigationRequested(object? sender, OverscrollNavigationE public override void Back_Click() { - AddressToolbarViewModel.CanGoBack = false; + ToolbarViewModel.CanGoBack = false; if (!ItemDisplayFrame.CanGoBack) return; @@ -212,7 +212,7 @@ public override void Back_Click() public override void Forward_Click() { - AddressToolbarViewModel.CanGoForward = false; + ToolbarViewModel.CanGoForward = false; if (!ItemDisplayFrame.CanGoForward) return; @@ -221,14 +221,14 @@ public override void Forward_Click() public override void Up_Click() { - if (!AddressToolbarViewModel.CanNavigateToParent) + if (!ToolbarViewModel.CanNavigateToParent) return; - AddressToolbarViewModel.CanNavigateToParent = false; - if (string.IsNullOrEmpty(ShellViewModel?.WorkingDirectory)) + ToolbarViewModel.CanNavigateToParent = false; + if (string.IsNullOrEmpty(FilesystemViewModel?.WorkingDirectory)) return; - bool isPathRooted = string.Equals(ShellViewModel.WorkingDirectory, PathNormalization.GetPathRoot(ShellViewModel.WorkingDirectory), StringComparison.OrdinalIgnoreCase); + bool isPathRooted = string.Equals(FilesystemViewModel.WorkingDirectory, PathNormalization.GetPathRoot(FilesystemViewModel.WorkingDirectory), StringComparison.OrdinalIgnoreCase); if (isPathRooted) { ItemDisplayFrame.Navigate( @@ -242,13 +242,13 @@ public override void Up_Click() } else { - string parentDirectoryOfPath = ShellViewModel.WorkingDirectory.TrimEnd('\\', '/'); + string parentDirectoryOfPath = FilesystemViewModel.WorkingDirectory.TrimEnd('\\', '/'); var lastSlashIndex = parentDirectoryOfPath.LastIndexOf("\\", StringComparison.Ordinal); if (lastSlashIndex == -1) lastSlashIndex = parentDirectoryOfPath.LastIndexOf("/", StringComparison.Ordinal); if (lastSlashIndex != -1) - parentDirectoryOfPath = ShellViewModel.WorkingDirectory.Remove(lastSlashIndex); + parentDirectoryOfPath = FilesystemViewModel.WorkingDirectory.Remove(lastSlashIndex); if (parentDirectoryOfPath.EndsWith(':')) parentDirectoryOfPath += '\\'; @@ -266,7 +266,7 @@ public override void Up_Click() public override void Dispose() { - AddressToolbarViewModel.RefreshWidgetsRequested -= ModernShellPage_RefreshWidgetsRequested; + ToolbarViewModel.RefreshWidgetsRequested -= ModernShellPage_RefreshWidgetsRequested; _navigationInteractionTracker.NavigationRequested -= OverscrollNavigationRequested; _navigationInteractionTracker.Dispose(); @@ -287,7 +287,7 @@ public override void NavigateHome() public override void NavigateToPath(string? navigationPath, Type? sourcePageType, NavigationArguments? navArgs = null) { - ShellViewModel.FilesAndFoldersFilter = null; + FilesystemViewModel.FilesAndFoldersFilter = null; if (sourcePageType is null && !string.IsNullOrEmpty(navigationPath)) sourcePageType = InstanceViewModel.FolderSettings.GetLayoutType(navigationPath); @@ -302,9 +302,9 @@ public override void NavigateToPath(string? navigationPath, Type? sourcePageType else { if ((string.IsNullOrEmpty(navigationPath) || - string.IsNullOrEmpty(ShellViewModel?.WorkingDirectory) || + string.IsNullOrEmpty(FilesystemViewModel?.WorkingDirectory) || navigationPath.TrimEnd(Path.DirectorySeparatorChar).Equals( - ShellViewModel.WorkingDirectory.TrimEnd(Path.DirectorySeparatorChar), + FilesystemViewModel.WorkingDirectory.TrimEnd(Path.DirectorySeparatorChar), StringComparison.OrdinalIgnoreCase)) && (TabBarItemParameter?.NavigationParameter is not string navArg || string.IsNullOrEmpty(navArg) || @@ -338,7 +338,7 @@ public override void NavigateToPath(string? navigationPath, Type? sourcePageType transition); } - AddressToolbarViewModel.PathControlDisplayText = ShellViewModel.WorkingDirectory; + ToolbarViewModel.PathControlDisplayText = FilesystemViewModel.WorkingDirectory; } } }