diff --git a/src/Files.App/Actions/Content/RefreshItemsAction.cs b/src/Files.App/Actions/Content/RefreshItemsAction.cs new file mode 100644 index 000000000000..8e68cf3651d4 --- /dev/null +++ b/src/Files.App/Actions/Content/RefreshItemsAction.cs @@ -0,0 +1,47 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.DependencyInjection; +using Files.App.Commands; +using Files.App.Contexts; +using Files.App.Extensions; +using System.ComponentModel; +using System.Threading.Tasks; +using Windows.System; + +namespace Files.App.Actions +{ + internal class RefreshItemsAction : ObservableObject, IAction + { + private readonly IContentPageContext context = Ioc.Default.GetRequiredService(); + + public string Label { get; } = "Refresh".GetLocalizedResource(); + public string Description { get; } = "TODO"; + + public RichGlyph Glyph { get; } = new("\uE72C"); + + public HotKey HotKey { get; } = new(VirtualKey.R, VirtualKeyModifiers.Control); + + public HotKey SecondHotKey { get; } = new(VirtualKey.F5); + + public bool IsExecutable => context.CanRefresh; + + public RefreshItemsAction() + { + context.PropertyChanged += Context_PropertyChanged; + } + + public async Task ExecuteAsync() + { + context.ShellPage?.Refresh_Click(); + } + + private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case nameof(IContentPageContext.CanRefresh): + OnPropertyChanged(nameof(IsExecutable)); + break; + } + } + } +} diff --git a/src/Files.App/Actions/Content/Run/RunAsAdminAction.cs b/src/Files.App/Actions/Content/Run/RunAsAdminAction.cs index c0842bee73e6..69e5272269e7 100644 --- a/src/Files.App/Actions/Content/Run/RunAsAdminAction.cs +++ b/src/Files.App/Actions/Content/Run/RunAsAdminAction.cs @@ -5,10 +5,6 @@ using Files.App.Extensions; using Files.App.Shell; using Files.Backend.Helpers; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; namespace Files.App.Actions diff --git a/src/Files.App/Actions/Content/Selection/ToggleSelectAction.cs b/src/Files.App/Actions/Content/Selection/ToggleSelectAction.cs new file mode 100644 index 000000000000..1a9c95f7fed7 --- /dev/null +++ b/src/Files.App/Actions/Content/Selection/ToggleSelectAction.cs @@ -0,0 +1,33 @@ +using Files.App.Commands; +using Files.App.Extensions; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Input; +using System.Threading.Tasks; +using Windows.System; + +namespace Files.App.Actions +{ + internal class ToggleSelectAction : IAction + { + public string Label { get; } = "ToggleSelect".GetLocalizedResource(); + public string Description => "TODO: Need to be described."; + + public HotKey HotKey { get; } = new(VirtualKey.Space, VirtualKeyModifiers.Control); + + public bool IsExecutable => GetFocusedElement() is not null; + + public Task ExecuteAsync() + { + if (GetFocusedElement() is SelectorItem item) + { + item.IsSelected = !item.IsSelected; + } + return Task.CompletedTask; + } + + private static SelectorItem? GetFocusedElement() + { + return FocusManager.GetFocusedElement(App.Window.Content.XamlRoot) as SelectorItem; + } + } +} diff --git a/src/Files.App/Actions/FileSystem/CopyPathAction.cs b/src/Files.App/Actions/FileSystem/CopyPathAction.cs index 1179cde68965..2abc2374e221 100644 --- a/src/Files.App/Actions/FileSystem/CopyPathAction.cs +++ b/src/Files.App/Actions/FileSystem/CopyPathAction.cs @@ -1,5 +1,4 @@ -using CommunityToolkit.Mvvm.ComponentModel; -using CommunityToolkit.Mvvm.DependencyInjection; +using CommunityToolkit.Mvvm.DependencyInjection; using Files.App.Commands; using Files.App.Contexts; using Files.App.Extensions; diff --git a/src/Files.App/Actions/FileSystem/OpenItemAction.cs b/src/Files.App/Actions/FileSystem/OpenItemAction.cs index 2529605d3ca0..f211e9d5f575 100644 --- a/src/Files.App/Actions/FileSystem/OpenItemAction.cs +++ b/src/Files.App/Actions/FileSystem/OpenItemAction.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Threading.Tasks; using Windows.Storage; +using Windows.System; namespace Files.App.Actions { @@ -23,9 +24,12 @@ internal class OpenItemAction : ObservableObject, IAction public RichGlyph Glyph => new(opacityStyle: "ColorIconOpenFile"); + public HotKey HotKey => new(VirtualKey.Enter); + private const int MaxOpenCount = 10; - public bool IsExecutable => context.HasSelection && context.SelectedItems.Count <= MaxOpenCount; + public bool IsExecutable => context.HasSelection && context.SelectedItems.Count <= MaxOpenCount && + !(context.ShellPage is ColumnShellPage && context.SelectedItem?.PrimaryItemAttribute == StorageItemTypes.Folder); public OpenItemAction() { diff --git a/src/Files.App/Actions/FileSystem/RenameAction.cs b/src/Files.App/Actions/FileSystem/RenameAction.cs new file mode 100644 index 000000000000..9f75fe93f15b --- /dev/null +++ b/src/Files.App/Actions/FileSystem/RenameAction.cs @@ -0,0 +1,67 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.DependencyInjection; +using Files.App.Commands; +using Files.App.Contexts; +using Files.App.Extensions; +using System.Threading.Tasks; +using Windows.System; + +namespace Files.App.Actions +{ + internal class RenameAction : ObservableObject, IAction + { + private readonly IContentPageContext context = Ioc.Default.GetRequiredService(); + + public string Label { get; } = "Rename".GetLocalizedResource(); + + public string Description { get; } = "TODO"; + + public HotKey HotKey { get; } = new(VirtualKey.F2); + + public RichGlyph Glyph { get; } = new(opacityStyle: "ColorIconRename"); + + public bool IsExecutable => + context.ShellPage is not null && + IsPageTypeValid() && + context.ShellPage.SlimContentPage is not null && + IsSelectionValid(); + + public RenameAction() + { + context.PropertyChanged += Context_PropertyChanged; + } + + public Task ExecuteAsync() + { + context.ShellPage?.SlimContentPage?.ItemManipulationModel.StartRenameItem(); + return Task.CompletedTask; + } + + private void Context_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case nameof(IContentPageContext.ShellPage): + case nameof(IContentPageContext.PageType): + case nameof(IContentPageContext.HasSelection): + case nameof(IContentPageContext.SelectedItems): + OnPropertyChanged(nameof(IsExecutable)); + break; + } + } + + private bool IsSelectionValid() + { + return context.HasSelection && context.SelectedItems.Count == 1; + } + + private bool IsPageTypeValid() + { + return context.PageType is + not ContentPageTypes.None and + not ContentPageTypes.Home and + not ContentPageTypes.RecycleBin and + not ContentPageTypes.ZipFolder; + } + } +} diff --git a/src/Files.App/Actions/Global/SearchAction.cs b/src/Files.App/Actions/Global/SearchAction.cs new file mode 100644 index 000000000000..389d4f840675 --- /dev/null +++ b/src/Files.App/Actions/Global/SearchAction.cs @@ -0,0 +1,49 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.DependencyInjection; +using Files.App.Commands; +using Files.App.Contexts; +using Files.App.Extensions; +using System.ComponentModel; +using System.Threading.Tasks; +using Windows.System; + +namespace Files.App.Actions +{ + internal class SearchAction : ObservableObject, IAction + { + private readonly IContentPageContext context = Ioc.Default.GetRequiredService(); + + public string Label { get; } = "Search".GetLocalizedResource(); + + public string Description { get; } = "TODO: Need to be described."; + + public HotKey HotKey { get; } = new(VirtualKey.F, VirtualKeyModifiers.Control); + + public HotKey SecondHotKey { get; } = new(VirtualKey.F3); + + public RichGlyph Glyph { get; } = new(); + + public bool IsExecutable => !context.IsSearchBoxVisible; + + public SearchAction() + { + context.PropertyChanged += Context_PropertyChanged; + } + + public Task ExecuteAsync() + { + context.ShellPage!.ToolbarViewModel.SwitchSearchBoxVisibility(); + return Task.CompletedTask; + } + + private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case nameof(IContentPageContext.IsSearchBoxVisible): + OnPropertyChanged(nameof(IsExecutable)); + break; + } + } + } +} diff --git a/src/Files.App/Actions/Navigation/NavigateBackAction.cs b/src/Files.App/Actions/Navigation/NavigateBackAction.cs new file mode 100644 index 000000000000..24ddeec2916b --- /dev/null +++ b/src/Files.App/Actions/Navigation/NavigateBackAction.cs @@ -0,0 +1,50 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.DependencyInjection; +using Files.App.Commands; +using Files.App.Contexts; +using Files.App.Extensions; +using System.ComponentModel; +using System.Threading.Tasks; +using Windows.System; + +namespace Files.App.Actions +{ + internal class NavigateBackAction : ObservableObject, IAction + { + private readonly IContentPageContext context = Ioc.Default.GetRequiredService(); + + public string Label { get; } = "Back".GetLocalizedResource(); + + public string Description { get; } = "NavigateBack".GetLocalizedResource(); + + public HotKey HotKey { get; } = new(VirtualKey.Left, VirtualKeyModifiers.Menu); + public HotKey SecondHotKey { get; } = new(VirtualKey.Back); + public HotKey ThirdHotKey { get; } = new(VirtualKey.XButton1); + public HotKey MediaHotKey { get; } = new(VirtualKey.GoBack); + + public RichGlyph Glyph { get; } = new("\uE72B"); + + public bool IsExecutable => context.CanGoBack; + + public NavigateBackAction() + { + context.PropertyChanged += Context_PropertyChanged; + } + + public Task ExecuteAsync() + { + context.ShellPage!.Back_Click(); + return Task.CompletedTask; + } + + private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case nameof(IContentPageContext.CanGoBack): + OnPropertyChanged(nameof(IsExecutable)); + break; + } + } + } +} diff --git a/src/Files.App/Actions/Navigation/NavigateForwardAction.cs b/src/Files.App/Actions/Navigation/NavigateForwardAction.cs new file mode 100644 index 000000000000..1651cad21f98 --- /dev/null +++ b/src/Files.App/Actions/Navigation/NavigateForwardAction.cs @@ -0,0 +1,49 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.DependencyInjection; +using Files.App.Commands; +using Files.App.Contexts; +using Files.App.Extensions; +using System.ComponentModel; +using System.Threading.Tasks; +using Windows.System; + +namespace Files.App.Actions +{ + internal class NavigateForwardAction : ObservableObject, IAction + { + private readonly IContentPageContext context = Ioc.Default.GetRequiredService(); + + public string Label { get; } = "Forward".GetLocalizedResource(); + + public string Description { get; } = "NavigateForward".GetLocalizedResource(); + + public HotKey HotKey { get; } = new(VirtualKey.Right, VirtualKeyModifiers.Menu); + public HotKey SecondHotKey { get; } = new(VirtualKey.XButton2); + public HotKey MediaHotKey { get; } = new(VirtualKey.GoForward); + + public RichGlyph Glyph { get; } = new("\uE72A"); + + public bool IsExecutable => context.CanGoForward; + + public NavigateForwardAction() + { + context.PropertyChanged += Context_PropertyChanged; + } + + public Task ExecuteAsync() + { + context.ShellPage!.Forward_Click(); + return Task.CompletedTask; + } + + private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case nameof(IContentPageContext.CanGoForward): + OnPropertyChanged(nameof(IsExecutable)); + break; + } + } + } +} diff --git a/src/Files.App/Actions/Navigation/NavigateUpAction.cs b/src/Files.App/Actions/Navigation/NavigateUpAction.cs new file mode 100644 index 000000000000..4ef98e595b8e --- /dev/null +++ b/src/Files.App/Actions/Navigation/NavigateUpAction.cs @@ -0,0 +1,48 @@ + +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.DependencyInjection; +using Files.App.Commands; +using Files.App.Contexts; +using Files.App.Extensions; +using System.ComponentModel; +using System.Threading.Tasks; +using Windows.System; + +namespace Files.App.Actions +{ + internal class NavigateUpAction : ObservableObject, IAction + { + private readonly IContentPageContext context = Ioc.Default.GetRequiredService(); + + public string Label { get; } = "Up".GetLocalizedResource(); + + public string Description { get; } = "NavigateUp".GetLocalizedResource(); + + public HotKey HotKey { get; } = new(VirtualKey.Up, VirtualKeyModifiers.Menu); + + public RichGlyph Glyph { get; } = new("\uE74A"); + + public bool IsExecutable => context.CanNavigateToParent; + + public NavigateUpAction() + { + context.PropertyChanged += Context_PropertyChanged; + } + + public Task ExecuteAsync() + { + context.ShellPage!.Up_Click(); + return Task.CompletedTask; + } + + private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case nameof(IContentPageContext.CanNavigateToParent): + OnPropertyChanged(nameof(IsExecutable)); + break; + } + } + } +} diff --git a/src/Files.App/Actions/Navigation/ReopenClosedTabAction.cs b/src/Files.App/Actions/Navigation/ReopenClosedTabAction.cs new file mode 100644 index 000000000000..01e92ccc7742 --- /dev/null +++ b/src/Files.App/Actions/Navigation/ReopenClosedTabAction.cs @@ -0,0 +1,51 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.DependencyInjection; +using Files.App.Commands; +using Files.App.Contexts; +using Files.App.Extensions; +using Files.App.UserControls.MultitaskingControl; +using System.ComponentModel; +using System.Threading.Tasks; +using Windows.System; + +namespace Files.App.Actions +{ + internal class ReopenClosedTabAction : ObservableObject, IAction + { + private readonly IMultitaskingContext context = Ioc.Default.GetRequiredService(); + + public string Label { get; } = "ReopenClosedTab".GetLocalizedResource(); + + public string Description { get; } = "TODO: Need to be described"; + + public HotKey HotKey { get; } = new(VirtualKey.T, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift); + + public bool IsExecutable => + context.Control is not null && + !BaseMultitaskingControl.IsRestoringClosedTab && + BaseMultitaskingControl.RecentlyClosedTabs.Count > 0; + + public ReopenClosedTabAction() + { + context.PropertyChanged += Context_PropertyChanged; + BaseMultitaskingControl.StaticPropertyChanged += BaseMultitaskingControl_StaticPropertyChanged; + } + + public Task ExecuteAsync() + { + context.Control!.ReopenClosedTab(); + return Task.CompletedTask; + } + + private void Context_PropertyChanged(object? _, PropertyChangedEventArgs e) + { + if (e.PropertyName is nameof(IMultitaskingContext.Control)) + OnPropertyChanged(nameof(IsExecutable)); + } + + private void BaseMultitaskingControl_StaticPropertyChanged(object? sender, PropertyChangedEventArgs e) + { + OnPropertyChanged(nameof(IsExecutable)); + } + } +} diff --git a/src/Files.App/Actions/Open/OpenSettingsAction.cs b/src/Files.App/Actions/Open/OpenSettingsAction.cs new file mode 100644 index 000000000000..912df47c168e --- /dev/null +++ b/src/Files.App/Actions/Open/OpenSettingsAction.cs @@ -0,0 +1,30 @@ +using CommunityToolkit.Mvvm.DependencyInjection; +using Files.App.Commands; +using Files.App.Extensions; +using Files.Backend.Extensions; +using Files.Backend.Services; +using Files.Backend.ViewModels.Dialogs; +using System.Threading.Tasks; +using Windows.System; + +namespace Files.App.Actions +{ + internal class OpenSettingsAction : IAction + { + private readonly IDialogService dialogService = Ioc.Default.GetRequiredService(); + + private readonly SettingsDialogViewModel viewModel = new(); + + public string Label => "Settings".GetLocalizedResource(); + + public string Description => "Settings".GetLocalizedResource(); + + public HotKey HotKey { get; } = new((VirtualKey)188, VirtualKeyModifiers.Control); + + public async Task ExecuteAsync() + { + var dialog = dialogService.GetDialog(viewModel); + await dialog.TryShowAsync(); + } + } +} diff --git a/src/Files.App/Actions/Start/PinToStartAction.cs b/src/Files.App/Actions/Start/PinToStartAction.cs index b8b767f54cff..b116db690f27 100644 --- a/src/Files.App/Actions/Start/PinToStartAction.cs +++ b/src/Files.App/Actions/Start/PinToStartAction.cs @@ -3,10 +3,6 @@ using Files.App.Contexts; using Files.App.Extensions; using Files.App.Filesystem; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; namespace Files.App.Actions diff --git a/src/Files.App/Actions/Start/UnpinFromStartAction.cs b/src/Files.App/Actions/Start/UnpinFromStartAction.cs index 5d33d42109cd..8c8c8db2c395 100644 --- a/src/Files.App/Actions/Start/UnpinFromStartAction.cs +++ b/src/Files.App/Actions/Start/UnpinFromStartAction.cs @@ -3,10 +3,6 @@ using Files.App.Contexts; using Files.App.Extensions; using Files.App.Filesystem; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; namespace Files.App.Actions diff --git a/src/Files.App/App.xaml.cs b/src/Files.App/App.xaml.cs index 6a86546228c8..b67afa8a8d03 100644 --- a/src/Files.App/App.xaml.cs +++ b/src/Files.App/App.xaml.cs @@ -183,7 +183,6 @@ protected override void OnLaunched(LaunchActivatedEventArgs e) // Initialize MainWindow here EnsureWindowIsInitialized(); - host = Host.CreateDefaultBuilder() .ConfigureServices(services => services @@ -228,15 +227,14 @@ protected override void OnLaunched(LaunchActivatedEventArgs e) .AddSingleton() .AddSingleton() .AddSingleton() - .AddScoped() - .AddScoped() - .AddScoped() - .AddScoped() - .AddScoped() + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() ) .Build(); Ioc.Default.ConfigureServices(host.Services); - EnsureSettingsAndConfigurationAreBootstrapped(); _ = InitializeAppComponentsAsync().ContinueWith(t => Logger.Warn(t.Exception, "Error during InitializeAppComponentsAsync()"), TaskContinuationOptions.OnlyOnFaulted); diff --git a/src/Files.App/BaseLayout.cs b/src/Files.App/BaseLayout.cs index ad6fe5f9ec86..ebdc48e2907c 100644 --- a/src/Files.App/BaseLayout.cs +++ b/src/Files.App/BaseLayout.cs @@ -382,6 +382,7 @@ protected virtual void BaseFolderSettings_LayoutModeChangeRequested(object? send // Remove old layout from back stack ParentShellPageInstance.RemoveLastPageFromBackStack(); + ParentShellPageInstance.ResetNavigationStackLayoutMode(); } ParentShellPageInstance.FilesystemViewModel.UpdateEmptyTextType(); @@ -877,8 +878,6 @@ protected virtual void Page_CharacterReceived(UIElement sender, CharacterReceive protected void FileList_DragItemsStarting(object sender, DragItemsStartingEventArgs e) { - SelectedItems!.AddRange(e.Items.OfType()); - try { var shellItemList = e.Items.OfType().Select(x => new VA.ShellItem(x.ItemPath)).ToArray(); diff --git a/src/Files.App/Commands/CommandCodes.cs b/src/Files.App/Commands/CommandCodes.cs index adc46bf72b7a..2b27fddbfa2a 100644 --- a/src/Files.App/Commands/CommandCodes.cs +++ b/src/Files.App/Commands/CommandCodes.cs @@ -10,6 +10,7 @@ public enum CommandCodes EnterCompactOverlay, ExitCompactOverlay, ToggleCompactOverlay, + Search, // Show ToggleShowHiddenItems, @@ -32,11 +33,14 @@ public enum CommandCodes OpenItem, OpenItemWithApplicationPicker, OpenParentFolder, + RefreshItems, + Rename, // Selection SelectAll, InvertSelection, ClearSelection, + ToggleSelect, // Share ShareItem, @@ -78,6 +82,7 @@ public enum CommandCodes RotateRight, // Open + OpenSettings, OpenTerminal, OpenTerminalAsAdmin, @@ -125,6 +130,11 @@ public enum CommandCodes // Navigation NewTab, + NavigateBack, + NavigateForward, + NavigateUp, + + // Other DuplicateCurrentTab, DuplicateSelectedTab, CloseTabsToTheLeftCurrent, @@ -133,5 +143,6 @@ public enum CommandCodes CloseTabsToTheRightSelected, CloseOtherTabsCurrent, CloseOtherTabsSelected, + ReopenClosedTab, } } diff --git a/src/Files.App/Commands/Manager/CommandManager.cs b/src/Files.App/Commands/Manager/CommandManager.cs index 436bc9de25c2..983fe7465371 100644 --- a/src/Files.App/Commands/Manager/CommandManager.cs +++ b/src/Files.App/Commands/Manager/CommandManager.cs @@ -28,16 +28,20 @@ internal class CommandManager : ICommandManager public IRichCommand EnterCompactOverlay => commands[CommandCodes.EnterCompactOverlay]; public IRichCommand ExitCompactOverlay => commands[CommandCodes.ExitCompactOverlay]; public IRichCommand ToggleCompactOverlay => commands[CommandCodes.ToggleCompactOverlay]; + public IRichCommand Search => commands[CommandCodes.Search]; public IRichCommand ToggleShowHiddenItems => commands[CommandCodes.ToggleShowHiddenItems]; public IRichCommand ToggleShowFileExtensions => commands[CommandCodes.ToggleShowFileExtensions]; public IRichCommand TogglePreviewPane => commands[CommandCodes.TogglePreviewPane]; public IRichCommand SelectAll => commands[CommandCodes.SelectAll]; public IRichCommand InvertSelection => commands[CommandCodes.InvertSelection]; public IRichCommand ClearSelection => commands[CommandCodes.ClearSelection]; + public IRichCommand ToggleSelect => commands[CommandCodes.ToggleSelect]; public IRichCommand ShareItem => commands[CommandCodes.ShareItem]; public IRichCommand EmptyRecycleBin => commands[CommandCodes.EmptyRecycleBin]; public IRichCommand RestoreRecycleBin => commands[CommandCodes.RestoreRecycleBin]; public IRichCommand RestoreAllRecycleBin => commands[CommandCodes.RestoreAllRecycleBin]; + public IRichCommand RefreshItems => commands[CommandCodes.RefreshItems]; + public IRichCommand Rename => commands[CommandCodes.Rename]; public IRichCommand CreateShortcut => commands[CommandCodes.CreateShortcut]; public IRichCommand CreateShortcutFromDialog => commands[CommandCodes.CreateShortcutFromDialog]; public IRichCommand CreateFolder => commands[CommandCodes.CreateFolder]; @@ -70,6 +74,7 @@ internal class CommandManager : ICommandManager public IRichCommand OpenItem => commands[CommandCodes.OpenItem]; public IRichCommand OpenItemWithApplicationPicker => commands[CommandCodes.OpenItemWithApplicationPicker]; public IRichCommand OpenParentFolder => commands[CommandCodes.OpenParentFolder]; + public IRichCommand OpenSettings => commands[CommandCodes.OpenSettings]; public IRichCommand OpenTerminal => commands[CommandCodes.OpenTerminal]; public IRichCommand OpenTerminalAsAdmin => commands[CommandCodes.OpenTerminalAsAdmin]; public IRichCommand LayoutDecreaseSize => commands[CommandCodes.LayoutDecreaseSize]; @@ -109,6 +114,9 @@ internal class CommandManager : ICommandManager public IRichCommand GroupDescending => commands[CommandCodes.GroupDescending]; public IRichCommand ToggleGroupDirection => commands[CommandCodes.ToggleGroupDirection]; public IRichCommand NewTab => commands[CommandCodes.NewTab]; + public IRichCommand NavigateBack => commands[CommandCodes.NavigateBack]; + public IRichCommand NavigateForward => commands[CommandCodes.NavigateForward]; + public IRichCommand NavigateUp => commands[CommandCodes.NavigateUp]; public IRichCommand DuplicateCurrentTab => commands[CommandCodes.DuplicateCurrentTab]; public IRichCommand DuplicateSelectedTab => commands[CommandCodes.DuplicateSelectedTab]; public IRichCommand CloseTabsToTheLeftCurrent => commands[CommandCodes.CloseTabsToTheLeftCurrent]; @@ -117,6 +125,7 @@ internal class CommandManager : ICommandManager public IRichCommand CloseTabsToTheRightSelected => commands[CommandCodes.CloseTabsToTheRightSelected]; public IRichCommand CloseOtherTabsCurrent => commands[CommandCodes.CloseOtherTabsCurrent]; public IRichCommand CloseOtherTabsSelected => commands[CommandCodes.CloseOtherTabsSelected]; + public IRichCommand ReopenClosedTab => commands[CommandCodes.ReopenClosedTab]; public CommandManager() { @@ -151,16 +160,20 @@ public CommandManager() [CommandCodes.EnterCompactOverlay] = new EnterCompactOverlayAction(), [CommandCodes.ExitCompactOverlay] = new ExitCompactOverlayAction(), [CommandCodes.ToggleCompactOverlay] = new ToggleCompactOverlayAction(), + [CommandCodes.Search] = new SearchAction(), [CommandCodes.ToggleShowHiddenItems] = new ToggleShowHiddenItemsAction(), [CommandCodes.ToggleShowFileExtensions] = new ToggleShowFileExtensionsAction(), [CommandCodes.TogglePreviewPane] = new TogglePreviewPaneAction(), [CommandCodes.SelectAll] = new SelectAllAction(), [CommandCodes.InvertSelection] = new InvertSelectionAction(), [CommandCodes.ClearSelection] = new ClearSelectionAction(), + [CommandCodes.ToggleSelect] = new ToggleSelectAction(), [CommandCodes.ShareItem] = new ShareItemAction(), [CommandCodes.EmptyRecycleBin] = new EmptyRecycleBinAction(), [CommandCodes.RestoreRecycleBin] = new RestoreRecycleBinAction(), [CommandCodes.RestoreAllRecycleBin] = new RestoreAllRecycleBinAction(), + [CommandCodes.RefreshItems] = new RefreshItemsAction(), + [CommandCodes.Rename] = new RenameAction(), [CommandCodes.CreateShortcut] = new CreateShortcutAction(), [CommandCodes.CreateShortcutFromDialog] = new CreateShortcutFromDialogAction(), [CommandCodes.CreateFolder] = new CreateFolderAction(), @@ -193,6 +206,7 @@ public CommandManager() [CommandCodes.OpenItem] = new OpenItemAction(), [CommandCodes.OpenItemWithApplicationPicker] = new OpenItemWithApplicationPickerAction(), [CommandCodes.OpenParentFolder] = new OpenParentFolderAction(), + [CommandCodes.OpenSettings] = new OpenSettingsAction(), [CommandCodes.OpenTerminal] = new OpenTerminalAction(), [CommandCodes.OpenTerminalAsAdmin] = new OpenTerminalAsAdminAction(), [CommandCodes.LayoutDecreaseSize] = new LayoutDecreaseSizeAction(), @@ -232,6 +246,9 @@ public CommandManager() [CommandCodes.GroupDescending] = new GroupDescendingAction(), [CommandCodes.ToggleGroupDirection] = new ToggleGroupDirectionAction(), [CommandCodes.NewTab] = new NewTabAction(), + [CommandCodes.NavigateBack] = new NavigateBackAction(), + [CommandCodes.NavigateForward] = new NavigateForwardAction(), + [CommandCodes.NavigateUp] = new NavigateUpAction(), [CommandCodes.DuplicateCurrentTab] = new DuplicateCurrentTabAction(), [CommandCodes.DuplicateSelectedTab] = new DuplicateSelectedTabAction(), [CommandCodes.CloseTabsToTheLeftCurrent] = new CloseTabsToTheLeftCurrentAction(), @@ -240,6 +257,7 @@ public CommandManager() [CommandCodes.CloseTabsToTheRightSelected] = new CloseTabsToTheRightSelectedAction(), [CommandCodes.CloseOtherTabsCurrent] = new CloseOtherTabsCurrentAction(), [CommandCodes.CloseOtherTabsSelected] = new CloseOtherTabsSelectedAction(), + [CommandCodes.ReopenClosedTab] = new ReopenClosedTabAction(), }; [DebuggerDisplay("Command None")] diff --git a/src/Files.App/Commands/Manager/ICommandManager.cs b/src/Files.App/Commands/Manager/ICommandManager.cs index 98af4711cc63..b063fa21aac2 100644 --- a/src/Files.App/Commands/Manager/ICommandManager.cs +++ b/src/Files.App/Commands/Manager/ICommandManager.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; namespace Files.App.Commands @@ -15,6 +14,7 @@ public interface ICommandManager : IEnumerable IRichCommand EnterCompactOverlay { get; } IRichCommand ExitCompactOverlay { get; } IRichCommand ToggleCompactOverlay { get; } + IRichCommand Search { get; } IRichCommand ToggleShowHiddenItems { get; } IRichCommand ToggleShowFileExtensions { get; } @@ -29,6 +29,7 @@ public interface ICommandManager : IEnumerable IRichCommand SelectAll { get; } IRichCommand InvertSelection { get; } IRichCommand ClearSelection { get; } + IRichCommand ToggleSelect { get; } IRichCommand ShareItem { get; } IRichCommand CreateFolder { get; } IRichCommand CreateShortcut { get; } @@ -39,6 +40,8 @@ public interface ICommandManager : IEnumerable IRichCommand OpenItem { get; } IRichCommand OpenItemWithApplicationPicker { get; } IRichCommand OpenParentFolder { get; } + IRichCommand RefreshItems { get; } + IRichCommand Rename { get; } IRichCommand PinToStart { get; } IRichCommand UnpinFromStart { get; } @@ -67,6 +70,7 @@ public interface ICommandManager : IEnumerable IRichCommand RotateLeft { get; } IRichCommand RotateRight { get; } + IRichCommand OpenSettings { get; } IRichCommand OpenTerminal { get; } IRichCommand OpenTerminalAsAdmin { get; } @@ -110,6 +114,10 @@ public interface ICommandManager : IEnumerable IRichCommand ToggleGroupDirection { get; } IRichCommand NewTab { get; } + IRichCommand NavigateBack { get; } + IRichCommand NavigateForward { get; } + IRichCommand NavigateUp { get; } + IRichCommand DuplicateCurrentTab { get; } IRichCommand DuplicateSelectedTab { get; } IRichCommand CloseTabsToTheLeftCurrent { get; } @@ -118,5 +126,6 @@ public interface ICommandManager : IEnumerable IRichCommand CloseTabsToTheRightSelected { get; } IRichCommand CloseOtherTabsCurrent { get; } IRichCommand CloseOtherTabsSelected { get; } + IRichCommand ReopenClosedTab { get; } } } diff --git a/src/Files.App/Contexts/ContentPage/ContentPageContext.cs b/src/Files.App/Contexts/ContentPage/ContentPageContext.cs index 1e5d1f3a042c..92bdb4c64aa5 100644 --- a/src/Files.App/Contexts/ContentPage/ContentPageContext.cs +++ b/src/Files.App/Contexts/ContentPage/ContentPageContext.cs @@ -3,6 +3,7 @@ using Files.App.Filesystem; using Files.App.UserControls.MultitaskingControl; using Files.App.ViewModels; +using Files.App.Views.LayoutModes; using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -21,6 +22,8 @@ internal class ContentPageContext : ObservableObject, IContentPageContext public IShellPage? ShellPage => context?.PaneOrColumn; + public Type PageLayoutType => ShellPage?.CurrentPageType ?? typeof(DetailsLayoutBrowser); + private ContentPageTypes pageType = ContentPageTypes.None; public ContentPageTypes PageType => pageType; @@ -34,6 +37,16 @@ internal class ContentPageContext : ObservableObject, IContentPageContext private IReadOnlyList selectedItems = emptyItems; public IReadOnlyList SelectedItems => selectedItems; + public bool CanRefresh => ShellPage is not null && ShellPage.ToolbarViewModel.CanRefresh; + + public bool CanGoBack => ShellPage is not null && ShellPage.ToolbarViewModel.CanGoBack; + + public bool CanGoForward => ShellPage is not null && ShellPage.ToolbarViewModel.CanGoForward; + + public bool CanNavigateToParent => ShellPage is not null && ShellPage.ToolbarViewModel.CanNavigateToParent; + + public bool IsSearchBoxVisible => ShellPage is not null && ShellPage.ToolbarViewModel.IsSearchBoxVisible; + public ContentPageContext() { context.Changing += Context_Changing; @@ -45,6 +58,7 @@ private void Context_Changing(object? sender, EventArgs e) { if (ShellPage is IShellPage page) { + page.PropertyChanged -= Page_PropertyChanged; page.ContentChanged -= Page_ContentChanged; page.InstanceViewModel.PropertyChanged -= InstanceViewModel_PropertyChanged; page.ToolbarViewModel.PropertyChanged -= ToolbarViewModel_PropertyChanged; @@ -60,6 +74,7 @@ private void Context_Changed(object? sender, EventArgs e) { if (ShellPage is IShellPage page) { + page.PropertyChanged += Page_PropertyChanged; page.ContentChanged += Page_ContentChanged; page.InstanceViewModel.PropertyChanged += InstanceViewModel_PropertyChanged; page.ToolbarViewModel.PropertyChanged += ToolbarViewModel_PropertyChanged; @@ -73,6 +88,16 @@ private void Context_Changed(object? sender, EventArgs e) OnPropertyChanged(nameof(ShellPage)); } + private void Page_PropertyChanged(object? sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case nameof(ShellPage.CurrentPageType): + OnPropertyChanged(nameof(PageLayoutType)); + break; + } + } + private void Page_ContentChanged(object? sender, TabItemArguments e) => Update(); private void InstanceViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e) @@ -96,7 +121,12 @@ private void ToolbarViewModel_PropertyChanged(object? sender, PropertyChangedEve { switch (e.PropertyName) { + case nameof(ToolbarViewModel.CanGoBack): + case nameof(ToolbarViewModel.CanGoForward): + case nameof(ToolbarViewModel.CanNavigateToParent): case nameof(ToolbarViewModel.HasItem): + case nameof(ToolbarViewModel.CanRefresh): + case nameof(ToolbarViewModel.IsSearchBoxVisible): OnPropertyChanged(e.PropertyName); break; case nameof(ToolbarViewModel.SelectedItems): @@ -118,6 +148,10 @@ private void Update() OnPropertyChanged(nameof(Folder)); OnPropertyChanged(nameof(HasItem)); + OnPropertyChanged(nameof(CanGoBack)); + OnPropertyChanged(nameof(CanGoForward)); + OnPropertyChanged(nameof(CanNavigateToParent)); + OnPropertyChanged(nameof(CanRefresh)); } private void UpdatePageType() diff --git a/src/Files.App/Contexts/ContentPage/IContentPageContext.cs b/src/Files.App/Contexts/ContentPage/IContentPageContext.cs index d1c2993389f9..f88f792121ac 100644 --- a/src/Files.App/Contexts/ContentPage/IContentPageContext.cs +++ b/src/Files.App/Contexts/ContentPage/IContentPageContext.cs @@ -1,4 +1,5 @@ using Files.App.Filesystem; +using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,11 +11,20 @@ public interface IContentPageContext : INotifyPropertyChanged ContentPageTypes PageType { get; } + Type PageLayoutType { get; } + ListedItem? Folder { get; } bool HasItem { get; } bool HasSelection { get; } + bool CanRefresh { get; } ListedItem? SelectedItem { get; } IReadOnlyList SelectedItems { get; } + + bool CanGoBack { get; } + bool CanGoForward { get; } + bool CanNavigateToParent { get; } + + bool IsSearchBoxVisible { get; } } } diff --git a/src/Files.App/DataModels/AppModel.cs b/src/Files.App/DataModels/AppModel.cs index dbc322dfdd3e..fc319998aaa4 100644 --- a/src/Files.App/DataModels/AppModel.cs +++ b/src/Files.App/DataModels/AppModel.cs @@ -1,14 +1,10 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.DependencyInjection; -using Files.App.ServicesImplementation.Settings; using Files.App.ViewModels; using Files.App.Views; using Files.Backend.Services.Settings; using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Media; -using System; using Windows.ApplicationModel.DataTransfer; -using Windows.System.Profile; namespace Files.App.DataModels { diff --git a/src/Files.App/DataModels/NavigationControlItems/LocationItem.cs b/src/Files.App/DataModels/NavigationControlItems/LocationItem.cs index 0dcd9f86970c..ba486e88a133 100644 --- a/src/Files.App/DataModels/NavigationControlItems/LocationItem.cs +++ b/src/Files.App/DataModels/NavigationControlItems/LocationItem.cs @@ -5,7 +5,6 @@ using Files.App.Helpers; using Files.App.Shell; using Files.Shared; -using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Media.Imaging; using System; using System.IO; diff --git a/src/Files.App/Dialogs/FilesystemOperationDialog.xaml.cs b/src/Files.App/Dialogs/FilesystemOperationDialog.xaml.cs index 9f865a18c9b9..149408a9fc47 100644 --- a/src/Files.App/Dialogs/FilesystemOperationDialog.xaml.cs +++ b/src/Files.App/Dialogs/FilesystemOperationDialog.xaml.cs @@ -7,7 +7,6 @@ using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media; using System; -using System.Linq; using System.Threading.Tasks; // The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 diff --git a/src/Files.App/Dialogs/ReorderSidebarItemsDialog.xaml.cs b/src/Files.App/Dialogs/ReorderSidebarItemsDialog.xaml.cs index ab3533fc471e..58952a79ad23 100644 --- a/src/Files.App/Dialogs/ReorderSidebarItemsDialog.xaml.cs +++ b/src/Files.App/Dialogs/ReorderSidebarItemsDialog.xaml.cs @@ -1,8 +1,6 @@ using CommunityToolkit.WinUI.UI; using Files.App.DataModels.NavigationControlItems; using Files.App.Extensions; -using Files.App.Filesystem; -using Files.App.ServicesImplementation; using Files.App.ViewModels.Dialogs; using Files.Backend.ViewModels.Dialogs; using Files.Shared.Enums; @@ -10,7 +8,6 @@ using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Input; using System; -using System.Diagnostics; using System.Threading.Tasks; using Windows.ApplicationModel.DataTransfer; diff --git a/src/Files.App/Filesystem/FileTagsManager.cs b/src/Files.App/Filesystem/FileTagsManager.cs index 0f4bc5359252..a8f21a38e1c4 100644 --- a/src/Files.App/Filesystem/FileTagsManager.cs +++ b/src/Files.App/Filesystem/FileTagsManager.cs @@ -1,5 +1,4 @@ using CommunityToolkit.Mvvm.DependencyInjection; -using CommunityToolkit.Mvvm.Input; using Files.App.DataModels.NavigationControlItems; using Files.Backend.Services.Settings; using Files.Shared; diff --git a/src/Files.App/Filesystem/Security/AccessControlEntry.cs b/src/Files.App/Filesystem/Security/AccessControlEntry.cs index 79464f0a01e4..191b4c1f5a64 100644 --- a/src/Files.App/Filesystem/Security/AccessControlEntry.cs +++ b/src/Files.App/Filesystem/Security/AccessControlEntry.cs @@ -3,7 +3,6 @@ using Files.App.Extensions; using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Linq; namespace Files.App.Filesystem.Security @@ -30,10 +29,17 @@ public AccessControlType AccessControlType } } + public string AccessControlTypeHumanized + => AccessControlType switch + { + AccessControlType.Allow => "Allow", + _ => "Deny" // AccessControlType.Deny + }; + public string AccessControlTypeGlyph => AccessControlType switch { - AccessControlType.Allow => "\xF13E", + AccessControlType.Allow => "\xE73E", _ => "\xF140" // AccessControlType.Deny }; diff --git a/src/Files.App/Filesystem/Security/Principal.cs b/src/Files.App/Filesystem/Security/Principal.cs index 364593d2079f..4554ef316fa0 100644 --- a/src/Files.App/Filesystem/Security/Principal.cs +++ b/src/Files.App/Filesystem/Security/Principal.cs @@ -1,5 +1,4 @@ using CommunityToolkit.Mvvm.ComponentModel; -using Files.App.Extensions; using System.Collections.Generic; using System.Text; using static Vanara.PInvoke.AdvApi32; @@ -25,11 +24,14 @@ public string Glyph public string? Name { get; set; } - public string DisplayName - => string.IsNullOrEmpty(Name) ? "SecurityUnknownAccount".GetLocalizedResource() : Name; + public string? DisplayName + => string.IsNullOrEmpty(Name) ? Sid : Name; - public string FullNameOrSid - => string.IsNullOrEmpty(Name) ? Sid : string.IsNullOrEmpty(Domain) ? Name : $"{Domain}\\{Name}"; + public string? FullNameOrSid + => string.IsNullOrEmpty(Domain) ? Sid : $"{Domain}\\{Name}"; + + public string? FullNameHumanized + => string.IsNullOrEmpty(Domain) ? string.Empty : $"({Domain}\\{Name})"; public List Groups { get; set; } diff --git a/src/Files.App/Helpers/ContextFlyoutItemHelper.cs b/src/Files.App/Helpers/ContextFlyoutItemHelper.cs index 1a94430c8723..52149e17e8f3 100644 --- a/src/Files.App/Helpers/ContextFlyoutItemHelper.cs +++ b/src/Files.App/Helpers/ContextFlyoutItemHelper.cs @@ -190,22 +190,10 @@ public static List GetBaseItemMenuItems( new ContextMenuFlyoutItemViewModelBuilder(commands.GroupDescending){IsVisible = true}.Build(), }, }, - new ContextMenuFlyoutItemViewModel() + new ContextMenuFlyoutItemViewModelBuilder(commands.RefreshItems) { - Text = "BaseLayoutContextFlyoutRefresh/Text".GetLocalizedResource(), - Glyph = "\uE72C", - ShowInRecycleBin = true, - ShowInSearchPage = true, - ShowInFtpPage = true, - ShowInZipPage = true, - Command = commandsViewModel.RefreshCommand, - KeyboardAccelerator = new KeyboardAccelerator - { - Key = VirtualKey.F5, - IsEnabled = false, - }, - ShowItem = !itemsSelected - }, + IsVisible = !itemsSelected, + }.Build(), new ContextMenuFlyoutItemViewModel() { ItemType = ItemType.Separator, @@ -385,27 +373,11 @@ public static List GetBaseItemMenuItems( IsVisible = itemsSelected && (!selectedItems.FirstOrDefault()?.IsShortcut ?? false) && !currentInstanceViewModel.IsPageTypeRecycleBin, }.Build(), - new ContextMenuFlyoutItemViewModel() + new ContextMenuFlyoutItemViewModelBuilder(commands.Rename) { - Text = "Rename".GetLocalizedResource(), IsPrimary = true, - OpacityIcon = new OpacityIconModel() - { - OpacityIconStyle = "ColorIconRename", - }, - Command = commandsViewModel.RenameItemCommand, - SingleItemOnly = true, - ShowInSearchPage = true, - ShowInFtpPage = true, - ShowInZipPage = true, - ShowInRecycleBin = false, - KeyboardAccelerator = new KeyboardAccelerator - { - Key = VirtualKey.F2, - IsEnabled = false, - }, - ShowItem = itemsSelected - }, + IsVisible = itemsSelected + }.Build(), new ContextMenuFlyoutItemViewModelBuilder(commands.ShareItem) { IsPrimary = true diff --git a/src/Files.App/Helpers/FilePropertiesHelpers.cs b/src/Files.App/Helpers/FilePropertiesHelpers.cs index a901baae5aea..8743e0265133 100644 --- a/src/Files.App/Helpers/FilePropertiesHelpers.cs +++ b/src/Files.App/Helpers/FilePropertiesHelpers.cs @@ -1,6 +1,5 @@ using Files.App.Dialogs; using Files.App.Extensions; -using Files.App.Views; using Microsoft.UI; using Microsoft.UI.Windowing; using Microsoft.UI.Xaml.Controls; @@ -70,7 +69,7 @@ public static async Task OpenPropertiesWindowAsync(object item, IShellPage assoc IsMaximizable = false, MinWidth = 460, MinHeight = 550, - Width = 600, + Width = 800, Height = 550, Content = frame, Backdrop = new WinUIEx.MicaSystemBackdrop(), @@ -103,6 +102,7 @@ public static async Task OpenPropertiesWindowAsync(object item, IShellPage assoc Y = displayArea.WorkArea.Y + Math.Max(0, Math.Min(displayArea.WorkArea.Height - appWindow.Size.Height, pointerPosition.Y - displayArea.WorkArea.Y)), }; + appWindow.Move(appWindowPos); } } @@ -111,6 +111,7 @@ public static async Task OpenPropertiesWindowAsync(object item, IShellPage assoc var dialog = new PropertiesDialog(); dialog.propertiesFrame.Tag = dialog; Navigate(dialog.propertiesFrame); + await dialog.ShowAsync(ContentDialogPlacement.Popup); } diff --git a/src/Files.App/Helpers/MultitaskingTabsHelpers.cs b/src/Files.App/Helpers/MultitaskingTabsHelpers.cs index acd01bf22a11..0d22f6eba52e 100644 --- a/src/Files.App/Helpers/MultitaskingTabsHelpers.cs +++ b/src/Files.App/Helpers/MultitaskingTabsHelpers.cs @@ -1,7 +1,5 @@ using Files.App.UserControls.MultitaskingControl; using Files.App.ViewModels; -using Microsoft.UI.Xaml.Controls; -using System; using System.Linq; using System.Threading.Tasks; diff --git a/src/Files.App/Helpers/ShellContextMenuHelper.cs b/src/Files.App/Helpers/ShellContextMenuHelper.cs index 21a0b6b59bbb..db4908206b67 100644 --- a/src/Files.App/Helpers/ShellContextMenuHelper.cs +++ b/src/Files.App/Helpers/ShellContextMenuHelper.cs @@ -16,7 +16,6 @@ using Microsoft.UI.Xaml.Media.Imaging; using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Threading; diff --git a/src/Files.App/Helpers/WallpaperHelpers.cs b/src/Files.App/Helpers/WallpaperHelpers.cs index 7a1cdbb8492f..f4af58b454f4 100644 --- a/src/Files.App/Helpers/WallpaperHelpers.cs +++ b/src/Files.App/Helpers/WallpaperHelpers.cs @@ -28,7 +28,7 @@ public static async void SetAsBackground(WallpaperType type, string filePath) public static void SetSlideshow(string[] filePaths) { - if (filePaths is null || filePaths.Any()) + if (filePaths is null || !filePaths.Any()) return; var idList = filePaths.Select(Shell32.IntILCreateFromPath).ToArray(); @@ -40,12 +40,6 @@ public static void SetSlideshow(string[] filePaths) // Set wallpaper to fill desktop. wallpaper.SetPosition(Shell32.DESKTOP_WALLPAPER_POSITION.DWPOS_FILL); - - // TODO: Should we handle multiple monitors? - // var monitors = wallpaper.GetMonitorDevicePathCount(); - wallpaper.GetMonitorDevicePathAt(0, out var monitorId); - // Advance the slideshow to reflect the change. - wallpaper.AdvanceSlideshow(monitorId, Shell32.DESKTOP_SLIDESHOW_DIRECTION.DSD_FORWARD); } } } diff --git a/src/Files.App/IAddressToolbar.cs b/src/Files.App/IAddressToolbar.cs index 6c52cdca74ec..92a25fcabfab 100644 --- a/src/Files.App/IAddressToolbar.cs +++ b/src/Files.App/IAddressToolbar.cs @@ -39,12 +39,6 @@ public interface IAddressToolbar public event ItemDraggedOverPathItemEventHandler ItemDraggedOverPathItem; - public event EventHandler BackRequested; - - public event EventHandler ForwardRequested; - - public event EventHandler UpRequested; - public event EventHandler RefreshRequested; public event EventHandler RefreshWidgetsRequested; diff --git a/src/Files.App/IShellPage.cs b/src/Files.App/IShellPage.cs index 0bd184f1e0bc..6808ba6072ab 100644 --- a/src/Files.App/IShellPage.cs +++ b/src/Files.App/IShellPage.cs @@ -7,7 +7,7 @@ namespace Files.App { - public interface IShellPage : ITabItemContent, IMultiPaneInfo, IDisposable + public interface IShellPage : ITabItemContent, IMultiPaneInfo, IDisposable, INotifyPropertyChanged { ItemViewModel FilesystemViewModel { get; } @@ -27,6 +27,10 @@ public interface IShellPage : ITabItemContent, IMultiPaneInfo, IDisposable void Refresh_Click(); + void Back_Click(); + + void Forward_Click(); + void Up_Click(); void UpdatePathUIToWorkingDirectory(string newWorkingDir, string singleItemOverride = null); @@ -49,6 +53,11 @@ public interface IShellPage : ITabItemContent, IMultiPaneInfo, IDisposable void RemoveLastPageFromBackStack(); + /// + /// Replaces any outdated entries with those of the correct page type + /// + void ResetNavigationStackLayoutMode(); + void SubmitSearch(string query, bool searchUnindexedItems); /// diff --git a/src/Files.App/Interacts/BaseLayoutCommandImplementationModel.cs b/src/Files.App/Interacts/BaseLayoutCommandImplementationModel.cs index 5a345f681c1f..7cd3dbe40d69 100644 --- a/src/Files.App/Interacts/BaseLayoutCommandImplementationModel.cs +++ b/src/Files.App/Interacts/BaseLayoutCommandImplementationModel.cs @@ -73,11 +73,6 @@ public void Dispose() #region Command Implementation - public virtual void RenameItem(RoutedEventArgs e) - { - itemManipulationModel.StartRenameItem(); - } - public virtual void ShowProperties(RoutedEventArgs e) { if (SlimContentPage.ItemContextMenuFlyout.IsOpen) @@ -291,11 +286,6 @@ public virtual async Task Drop(DragEventArgs e) deferral.Complete(); } - public virtual void RefreshItems(RoutedEventArgs e) - { - associatedInstance.Refresh_Click(); - } - public void SearchUnindexedItems(RoutedEventArgs e) { associatedInstance.SubmitSearch(associatedInstance.InstanceViewModel.CurrentSearchQuery, true); diff --git a/src/Files.App/Interacts/BaseLayoutCommandsViewModel.cs b/src/Files.App/Interacts/BaseLayoutCommandsViewModel.cs index 2cdcec7de2e0..92693e355378 100644 --- a/src/Files.App/Interacts/BaseLayoutCommandsViewModel.cs +++ b/src/Files.App/Interacts/BaseLayoutCommandsViewModel.cs @@ -27,7 +27,6 @@ public BaseLayoutCommandsViewModel(IBaseLayoutCommandImplementationModel command private void InitializeCommands() { - RenameItemCommand = new RelayCommand(CommandsModel.RenameItem); ShowPropertiesCommand = new RelayCommand(CommandsModel.ShowProperties); OpenFileLocationCommand = new RelayCommand(CommandsModel.OpenFileLocation); OpenDirectoryInNewTabCommand = new RelayCommand(CommandsModel.OpenDirectoryInNewTab); @@ -38,7 +37,6 @@ private void InitializeCommands() PointerWheelChangedCommand = new RelayCommand(CommandsModel.PointerWheelChanged); DragOverCommand = new AsyncRelayCommand(CommandsModel.DragOver); DropCommand = new AsyncRelayCommand(CommandsModel.Drop); - RefreshCommand = new RelayCommand(CommandsModel.RefreshItems); SearchUnindexedItems = new RelayCommand(CommandsModel.SearchUnindexedItems); CreateFolderWithSelection = new AsyncRelayCommand(CommandsModel.CreateFolderWithSelection); PlayAllCommand = new AsyncRelayCommand(CommandsModel.PlayAll); @@ -49,8 +47,6 @@ private void InitializeCommands() #region Commands - public ICommand RenameItemCommand { get; private set; } - public ICommand ShowPropertiesCommand { get; private set; } public ICommand OpenFileLocationCommand { get; private set; } @@ -71,8 +67,6 @@ private void InitializeCommands() public ICommand DropCommand { get; private set; } - public ICommand RefreshCommand { get; private set; } - public ICommand SearchUnindexedItems { get; private set; } public ICommand CreateFolderWithSelection { get; private set; } diff --git a/src/Files.App/Interacts/IBaseLayoutCommandImplementationModel.cs b/src/Files.App/Interacts/IBaseLayoutCommandImplementationModel.cs index acf5a1c6ac0d..b1fffe2664e9 100644 --- a/src/Files.App/Interacts/IBaseLayoutCommandImplementationModel.cs +++ b/src/Files.App/Interacts/IBaseLayoutCommandImplementationModel.cs @@ -9,8 +9,6 @@ namespace Files.App.Interacts { public interface IBaseLayoutCommandImplementationModel : IDisposable { - void RenameItem(RoutedEventArgs e); - void ShowProperties(RoutedEventArgs e); void OpenFileLocation(RoutedEventArgs e); @@ -31,8 +29,6 @@ public interface IBaseLayoutCommandImplementationModel : IDisposable Task Drop(DragEventArgs e); - void RefreshItems(RoutedEventArgs e); - void SearchUnindexedItems(RoutedEventArgs e); Task CreateFolderWithSelection(RoutedEventArgs e); diff --git a/src/Files.App/MainWindow.xaml.cs b/src/Files.App/MainWindow.xaml.cs index d936db8dc581..e555bdcdd51a 100644 --- a/src/Files.App/MainWindow.xaml.cs +++ b/src/Files.App/MainWindow.xaml.cs @@ -75,10 +75,9 @@ public async Task InitializeApplication(object activatedEventArgs) // WINUI3 bug: when launching from commandline the argument is not ICommandLineActivatedEventArgs (#10370) var ppm = CommandLineParser.ParseUntrustedCommands(launchArgs.Arguments); if (ppm.IsEmpty()) - { - ppm = new ParsedCommands() { new ParsedCommand() { Type = ParsedCommandType.Unknown, Args = new() { "." } } }; - } - await InitializeFromCmdLineArgs(rootFrame, ppm); + rootFrame.Navigate(typeof(MainPage), null, new SuppressNavigationTransitionInfo()); + else + await InitializeFromCmdLineArgs(rootFrame, ppm); } else if (rootFrame.Content is null) { @@ -123,10 +122,9 @@ public async Task InitializeApplication(object activatedEventArgs) case "cmd": var ppm = CommandLineParser.ParseUntrustedCommands(unescapedValue); if (ppm.IsEmpty()) - { - ppm = new ParsedCommands() { new ParsedCommand() { Type = ParsedCommandType.Unknown, Args = new() { "." } } }; - } - await InitializeFromCmdLineArgs(rootFrame, ppm); + rootFrame.Navigate(typeof(MainPage), null, new SuppressNavigationTransitionInfo()); + else + await InitializeFromCmdLineArgs(rootFrame, ppm); break; } } diff --git a/src/Files.App/ResourceDictionaries/NavigationViewItemButtonStyle.xaml b/src/Files.App/ResourceDictionaries/NavigationViewItemButtonStyle.xaml index ee3478425227..ab241370b9e8 100644 --- a/src/Files.App/ResourceDictionaries/NavigationViewItemButtonStyle.xaml +++ b/src/Files.App/ResourceDictionaries/NavigationViewItemButtonStyle.xaml @@ -57,6 +57,8 @@ 1,1,1,1 40 + 2,0,0,0 + 2,0,0,2 + + + - - - + - + - + - - + - - - - - - - + - + + + + + + + + + + + + + + + + + + + FontFamily="{StaticResource SymbolThemeFontFamily}" + FontSize="16" + Glyph="{x:Bind ViewModel.AccessControlList.Owner.Glyph, Mode=OneWay}" /> - - - - - -  ( - - ) - - - - - - - + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + Text="{helpers:ResourceString Name=Permissions}" /> + Spacing="8"> + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - -  ( - - ) - - + Text="{x:Bind AccessControlTypeHumanized, Mode=OneWay}" + TextTrimming="CharacterEllipsis" + TextWrapping="NoWrap" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + TextTrimming="CharacterEllipsis" + TextWrapping="NoWrap" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + BorderThickness="0,1,0,0" + ColumnSpacing="12"> - + + - - - + + + + + + + + + + + + + + + + + + + Height="1" + Background="{ThemeResource DividerStrokeColorDefault}" /> + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + Grid.Column="1" + Style="{StaticResource BodyTextBlockStyle}" + ToolTipService.ToolTip="{x:Bind Principal.FullNameOrSid}"> + + + + + + + + + + + - + + RowSpacing="8"> - - - - - - - - + + + + + + + + + + + + + + + + Background="{ThemeResource DividerStrokeColorDefault}" /> + Text="{helpers:ResourceString Name=Deny}" /> + diff --git a/src/Files.App/Views/Settings/AboutPage.xaml.cs b/src/Files.App/Views/Settings/AboutPage.xaml.cs index 48d9249b7629..dacf27da728d 100644 --- a/src/Files.App/Views/Settings/AboutPage.xaml.cs +++ b/src/Files.App/Views/Settings/AboutPage.xaml.cs @@ -1,5 +1,4 @@ using CommunityToolkit.WinUI.UI.Controls; -using Files.App.ViewModels.Settings; using Microsoft.UI.Xaml.Controls; using System; using Windows.System; diff --git a/src/Files.App/Views/Settings/TagsPage.xaml.cs b/src/Files.App/Views/Settings/TagsPage.xaml.cs index 58cebde0dc2c..04cff0830741 100644 --- a/src/Files.App/Views/Settings/TagsPage.xaml.cs +++ b/src/Files.App/Views/Settings/TagsPage.xaml.cs @@ -1,8 +1,5 @@ -using CommunityToolkit.WinUI.Helpers; using CommunityToolkit.WinUI.UI; -using Files.App.Helpers; using Files.Backend.ViewModels.FileTags; -using Microsoft.UI; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls.Primitives; diff --git a/src/Files.Backend/AppModels/TaggedItemModel.cs b/src/Files.Backend/AppModels/TaggedItemModel.cs index 6e74857cae4a..d7c24d1dd21a 100644 --- a/src/Files.Backend/AppModels/TaggedItemModel.cs +++ b/src/Files.Backend/AppModels/TaggedItemModel.cs @@ -2,10 +2,10 @@ namespace Files.Backend.AppModels { - /// + /// /// Represents an item that is tagged. /// /// Tag UIDs that the item is tagged with. /// The item that contains the tags. - public sealed record class TaggedItemModel(string[] TagUids, ILocatableStorable Storable); + public sealed record class TaggedItemModel(string[] TagUids, ILocatableStorable Storable); } diff --git a/src/Files.Backend/Models/IImageModel.cs b/src/Files.Backend/Models/IImageModel.cs index 80b51a9b0578..a35fe030a230 100644 --- a/src/Files.Backend/Models/IImageModel.cs +++ b/src/Files.Backend/Models/IImageModel.cs @@ -1,9 +1,9 @@ namespace Files.Backend.Models { - /// - /// Represents a model that represents an image which can be displayed in the UI. - /// - public interface IImageModel + /// + /// Represents a model that represents an image which can be displayed in the UI. + /// + public interface IImageModel { } } diff --git a/src/Files.Backend/Services/IImageService.cs b/src/Files.Backend/Services/IImageService.cs index 37bc72de951d..747f48ab4807 100644 --- a/src/Files.Backend/Services/IImageService.cs +++ b/src/Files.Backend/Services/IImageService.cs @@ -6,10 +6,10 @@ namespace Files.Backend.Services { - /// - /// Represents a service used for data to image conversion. - /// - public interface IImageService + /// + /// Represents a service used for data to image conversion. + /// + public interface IImageService { /// /// Gets associated item icon of provided . May return null if the icon is inaccessible. diff --git a/src/Files.Shared/Helpers/PathHelpers.cs b/src/Files.Shared/Helpers/PathHelpers.cs index a52abf040b31..048e83299c34 100644 --- a/src/Files.Shared/Helpers/PathHelpers.cs +++ b/src/Files.Shared/Helpers/PathHelpers.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; namespace Files.Shared.Helpers {