Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected async Task DecompressArchiveHereAsync(bool smart = false)
{
var password = string.Empty;
BaseStorageFile archive = await StorageHelpers.ToStorageItem<BaseStorageFile>(selectedItem.ItemPath);
BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem<BaseStorageFolder>(context.ShellPage?.FilesystemViewModel.CurrentFolder?.ItemPath ?? string.Empty);
BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem<BaseStorageFolder>(context.ShellPage?.ShellViewModel.CurrentFolder?.ItemPath ?? string.Empty);

if (archive?.Path is null)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override async Task ExecuteAsync(object? parameter = null)
var password = string.Empty;

BaseStorageFile archive = await StorageHelpers.ToStorageItem<BaseStorageFile>(selectedItem.ItemPath);
BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem<BaseStorageFolder>(context.ShellPage?.FilesystemViewModel.CurrentFolder.ItemPath);
BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem<BaseStorageFolder>(context.ShellPage?.ShellViewModel.CurrentFolder.ItemPath);
BaseStorageFolder destinationFolder = null;

if (archive?.Path is null)
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/Content/Selection/SelectAllAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ 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;
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/FileSystem/BaseDeleteAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/FileSystem/CopyPathAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Task ExecuteAsync(object? parameter = 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;
: context.ShellPage.ShellViewModel.WorkingDirectory;

if (FtpHelpers.IsFtpPath(path))
path = path.Replace("\\", "/", StringComparison.Ordinal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Task ExecuteAsync(object? parameter = null)
var selectedItems = context.ShellPage.SlimContentPage.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);
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Actions/FileSystem/OpenFileLocationAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/FileSystem/PasteItemAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task ExecuteAsync(object? parameter = null)

string path = context.SelectedItem is ListedItem selectedItem
? selectedItem.ItemPath
: context.ShellPage.FilesystemViewModel.WorkingDirectory;
: context.ShellPage.ShellViewModel.WorkingDirectory;

await UIFilesystemHelpers.PasteItemAsync(path, context.ShellPage);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/Open/OpenInVSCodeAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Actions/Start/PinToStartAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/Start/UnpinFromStartAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal sealed class ContentPageContext : ObservableObject, IContentPageContext

private readonly IMultiPanesContext context = Ioc.Default.GetRequiredService<IMultiPanesContext>();

private ItemViewModel? filesystemViewModel;
private ShellViewModel? filesystemViewModel;

public IShellPage? ShellPage => context?.ActivePaneOrColumn;

Expand All @@ -21,7 +21,7 @@ internal sealed class ContentPageContext : ObservableObject, IContentPageContext
private ContentPageTypes pageType = ContentPageTypes.None;
public ContentPageTypes PageType => pageType;

public ListedItem? Folder => ShellPage?.FilesystemViewModel?.CurrentFolder;
public ListedItem? Folder => ShellPage?.ShellViewModel?.CurrentFolder;

public bool HasItem => ShellPage?.ToolbarViewModel?.HasItem ?? false;

Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -99,7 +99,7 @@ private void Context_Changed(object? sender, EventArgs e)
page.PaneHolder.PropertyChanged += PaneHolder_PropertyChanged;
}

filesystemViewModel = ShellPage?.FilesystemViewModel;
filesystemViewModel = ShellPage?.ShellViewModel;
if (filesystemViewModel is not null)
filesystemViewModel.PropertyChanged += FilesystemViewModel_PropertyChanged;

Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Data/Contracts/IShellPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Files.App.Data.Contracts
{
public interface IShellPage : ITabBarItemContent, IMultiPaneInfo, IDisposable, INotifyPropertyChanged
{
ItemViewModel FilesystemViewModel { get; }
ShellViewModel ShellViewModel { get; }

CurrentInstanceViewModel InstanceViewModel { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static class ContentPageContextFlyoutFactory
private static readonly ICommandManager Commands = Ioc.Default.GetRequiredService<ICommandManager>();
private static IStorageArchiveService StorageArchiveService { get; } = Ioc.Default.GetRequiredService<IStorageArchiveService>();

public static List<ContextMenuFlyoutItemViewModel> GetItemContextCommandsWithoutShellItems(CurrentInstanceViewModel currentInstanceViewModel, List<ListedItem> selectedItems, BaseLayoutViewModel commandsViewModel, bool shiftPressed, SelectedItemsPropertiesViewModel? selectedItemsPropertiesViewModel, ItemViewModel? itemViewModel = null)
public static List<ContextMenuFlyoutItemViewModel> GetItemContextCommandsWithoutShellItems(CurrentInstanceViewModel currentInstanceViewModel, List<ListedItem> 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);
Expand Down Expand Up @@ -80,7 +80,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(
SelectedItemsPropertiesViewModel? selectedItemsPropertiesViewModel,
List<ListedItem> selectedItems,
CurrentInstanceViewModel currentInstanceViewModel,
ItemViewModel? itemViewModel = null)
ShellViewModel? itemViewModel = null)
{
bool itemsSelected = itemViewModel is null;
bool canDecompress = selectedItems.Any() && selectedItems.All(x => x.IsArchive)
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Extensions/ShellNewEntryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static async Task<List<ShellNewEntry>> GetNewContextMenuEntries()

public static async Task<FilesystemResult<BaseStorageFile>> 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);
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public static DynamicDialog GetFor_RenameRequiresHigherPermissions(string path)
SecondaryButtonAction = (vm, e) =>
{
var context = Ioc.Default.GetRequiredService<IContentPageContext>();
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);
Expand Down
16 changes: 8 additions & 8 deletions src/Files.App/Helpers/Navigation/NavigationHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ 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) ||
if (associatedInstance.ShellViewModel.WorkingDirectory.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal) ||
associatedInstance.SlimContentPage?.SelectedItems is null)
{
return;
Expand Down Expand Up @@ -314,7 +314,7 @@ public static async Task OpenSelectedItemsAsync(IShellPage associatedInstance, b
public static async Task OpenItemsWithExecutableAsync(IShellPage associatedInstance, IEnumerable<IStorageItemWithPath> items, string executablePath)
{
// Don't open files and folders inside recycle bin
if (associatedInstance.FilesystemViewModel.WorkingDirectory.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal) ||
if (associatedInstance.ShellViewModel.WorkingDirectory.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal) ||
associatedInstance.SlimContentPage is null)
return;

Expand All @@ -334,7 +334,7 @@ public static async Task OpenItemsWithExecutableAsync(IShellPage associatedInsta
/// <param name="forceOpenInNewTab">Open folders in a new tab regardless of the "OpenFoldersInNewTab" option</param>
public static async Task<bool> OpenPath(string path, IShellPage associatedInstance, FilesystemItemType? itemType = null, bool openSilent = false, bool openViaApplicationPicker = false, IEnumerable<string>? 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);
Expand Down Expand Up @@ -431,7 +431,7 @@ public static async Task<bool> OpenPath(string path, IShellPage associatedInstan
{
await DialogDisplayHelper.ShowDialogAsync("FileNotFoundDialog/Title".GetLocalizedResource(), "FileNotFoundDialog/Text".GetLocalizedResource());
associatedInstance.ToolbarViewModel.CanRefresh = false;
associatedInstance.FilesystemViewModel?.RefreshItems(previousDir);
associatedInstance.ShellViewModel?.RefreshItems(previousDir);
}

return opened;
Expand Down Expand Up @@ -485,7 +485,7 @@ private static async Task<FilesystemResult> 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
Expand Down Expand Up @@ -519,7 +519,7 @@ private static async Task<FilesystemResult> 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);
Expand All @@ -534,7 +534,7 @@ private static async Task<FilesystemResult> 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
Expand All @@ -558,7 +558,7 @@ private static async Task<FilesystemResult> 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)
{
Expand Down
14 changes: 7 additions & 7 deletions src/Files.App/Helpers/UI/UIFilesystemHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ 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)
throw new IOException($"Failed to process {listedItem.ItemPath}.", (int)result.ErrorCode);
}
else
{
var result = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(listedItem.ItemPath)
var result = await associatedInstance.ShellViewModel.GetFolderFromPathAsync(listedItem.ItemPath)
.OnSuccess(t => items.Add(t));

if (!result)
Expand Down Expand Up @@ -167,15 +167,15 @@ 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)
throw new IOException($"Failed to process {listedItem.ItemPath}.", (int)result.ErrorCode);
}
else
{
var result = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(listedItem.ItemPath)
var result = await associatedInstance.ShellViewModel.GetFolderFromPathAsync(listedItem.ItemPath)
.OnSuccess(t => items.Add(t));

if (!result)
Expand Down Expand Up @@ -283,7 +283,7 @@ public static async Task CreateFileFromDialogResultTypeAsync(AddItemDialogItemTy

if (associatedInstance.SlimContentPage 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
Expand Down Expand Up @@ -373,7 +373,7 @@ public static void SetHiddenAttributeItem(ListedItem item, bool isHidden, ItemMa

public static async Task CreateShortcutAsync(IShellPage? associatedInstance, IReadOnlyList<ListedItem> 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;
Expand All @@ -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)
{
Expand Down
Loading