From c15f50a4300d2431fa773dc521b81f33011ce035 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Mon, 4 Aug 2025 11:26:48 -0400 Subject: [PATCH 1/2] Feature: Added action to toggle dual pane mode --- .../Actions/Show/ToggleDualPaneAction.cs | 46 +++++++++++++++++++ .../Data/Commands/Manager/CommandCodes.cs | 1 + .../Data/Commands/Manager/CommandManager.cs | 2 + .../Data/Commands/Manager/ICommandManager.cs | 1 + .../Data/Contracts/IShellPanesPage.cs | 5 ++ src/Files.App/Strings/en-US/Resources.resw | 6 +++ src/Files.App/Views/ShellPanesPage.xaml.cs | 12 +++++ 7 files changed, 73 insertions(+) create mode 100644 src/Files.App/Actions/Show/ToggleDualPaneAction.cs diff --git a/src/Files.App/Actions/Show/ToggleDualPaneAction.cs b/src/Files.App/Actions/Show/ToggleDualPaneAction.cs new file mode 100644 index 000000000000..627f052c32e4 --- /dev/null +++ b/src/Files.App/Actions/Show/ToggleDualPaneAction.cs @@ -0,0 +1,46 @@ +// Copyright (c) Files Community +// Licensed under the MIT License. + +namespace Files.App.Actions +{ + internal sealed partial class ToggleDualPaneAction : ObservableObject, IToggleAction + { + private readonly IContentPageContext ContentPageContext = Ioc.Default.GetRequiredService(); + private readonly IGeneralSettingsService generalSettingsService = Ioc.Default.GetRequiredService(); + + public string Label + => Strings.ToggleDualPane.GetLocalizedResource(); + + public string Description + => Strings.ToggleDualPaneDescription.GetLocalizedResource(); + + public bool IsOn + => ContentPageContext.IsMultiPaneActive; + + public ToggleDualPaneAction() + { + ContentPageContext.PropertyChanged += ContentPageContext_PropertyChanged; + } + + public Task ExecuteAsync(object? parameter = null) + { + if (IsOn) + ContentPageContext.ShellPage?.PaneHolder.CloseOtherPane(); + else + ContentPageContext.ShellPage!.PaneHolder.OpenSecondaryPane(arrangement: generalSettingsService.ShellPaneArrangementOption); + + return Task.CompletedTask; + } + + private void ContentPageContext_PropertyChanged(object? sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case nameof(IContentPageContext.ShellPage): + case nameof(IContentPageContext.IsMultiPaneActive): + OnPropertyChanged(nameof(IsOn)); + break; + } + } + } +} diff --git a/src/Files.App/Data/Commands/Manager/CommandCodes.cs b/src/Files.App/Data/Commands/Manager/CommandCodes.cs index 7c3cfcb448e0..100ee5b89476 100644 --- a/src/Files.App/Data/Commands/Manager/CommandCodes.cs +++ b/src/Files.App/Data/Commands/Manager/CommandCodes.cs @@ -28,6 +28,7 @@ public enum CommandCodes ToggleToolbar, ToggleShelfPane, ToggleFilterHeader, + ToggleDualPane, // File System CopyItem, diff --git a/src/Files.App/Data/Commands/Manager/CommandManager.cs b/src/Files.App/Data/Commands/Manager/CommandManager.cs index 12e4518885ad..626f6e4c29fb 100644 --- a/src/Files.App/Data/Commands/Manager/CommandManager.cs +++ b/src/Files.App/Data/Commands/Manager/CommandManager.cs @@ -59,6 +59,7 @@ public IRichCommand this[HotKey hotKey] public IRichCommand ToggleToolbar => commands[CommandCodes.ToggleToolbar]; public IRichCommand ToggleShelfPane => commands[CommandCodes.ToggleShelfPane]; public IRichCommand ToggleFilterHeader => commands[CommandCodes.ToggleFilterHeader]; + public IRichCommand ToggleDualPane => commands[CommandCodes.ToggleDualPane]; public IRichCommand SelectAll => commands[CommandCodes.SelectAll]; public IRichCommand InvertSelection => commands[CommandCodes.InvertSelection]; public IRichCommand ClearSelection => commands[CommandCodes.ClearSelection]; @@ -266,6 +267,7 @@ public IEnumerator GetEnumerator() => [CommandCodes.ToggleToolbar] = new ToggleToolbarAction(), [CommandCodes.ToggleShelfPane] = new ToggleShelfPaneAction(), [CommandCodes.ToggleFilterHeader] = new ToggleFilterHeaderAction(), + [CommandCodes.ToggleDualPane] = new ToggleDualPaneAction(), [CommandCodes.SelectAll] = new SelectAllAction(), [CommandCodes.InvertSelection] = new InvertSelectionAction(), [CommandCodes.ClearSelection] = new ClearSelectionAction(), diff --git a/src/Files.App/Data/Commands/Manager/ICommandManager.cs b/src/Files.App/Data/Commands/Manager/ICommandManager.cs index 56d91bdb5732..a2b5ff7c6191 100644 --- a/src/Files.App/Data/Commands/Manager/ICommandManager.cs +++ b/src/Files.App/Data/Commands/Manager/ICommandManager.cs @@ -33,6 +33,7 @@ public interface ICommandManager : IEnumerable IRichCommand ToggleToolbar { get; } IRichCommand ToggleShelfPane { get; } IRichCommand ToggleFilterHeader { get; } + IRichCommand ToggleDualPane { get; } IRichCommand CopyItem { get; } IRichCommand CopyItemPath { get; } diff --git a/src/Files.App/Data/Contracts/IShellPanesPage.cs b/src/Files.App/Data/Contracts/IShellPanesPage.cs index afeace482ef9..d2e6e1ba6ee8 100644 --- a/src/Files.App/Data/Contracts/IShellPanesPage.cs +++ b/src/Files.App/Data/Contracts/IShellPanesPage.cs @@ -54,6 +54,11 @@ public interface IShellPanesPage : IDisposable, INotifyPropertyChanged /// public void CloseActivePane(); + /// + /// Closes the non active/focused pane. + /// + public void CloseOtherPane(); + /// /// Focuses the other pane. /// diff --git a/src/Files.App/Strings/en-US/Resources.resw b/src/Files.App/Strings/en-US/Resources.resw index dc6dc947fbbf..b078f103dcc7 100644 --- a/src/Files.App/Strings/en-US/Resources.resw +++ b/src/Files.App/Strings/en-US/Resources.resw @@ -1106,6 +1106,12 @@ Toggle visibility of the filter header + + Toggle dual pane + + + Toggle dual pane mode + No preview available diff --git a/src/Files.App/Views/ShellPanesPage.xaml.cs b/src/Files.App/Views/ShellPanesPage.xaml.cs index 9617ed607149..ceb126b9f2dd 100644 --- a/src/Files.App/Views/ShellPanesPage.xaml.cs +++ b/src/Files.App/Views/ShellPanesPage.xaml.cs @@ -336,6 +336,18 @@ ShellPaneArrangement is ShellPaneArrangement.Vertical } } + /// + public void CloseOtherPane() + { + if (!IsMultiPaneActive) + return; + + if (ActivePane == (IShellPage)GetPane(0)!) + RemovePane(1); + else + RemovePane(0); + } + /// public void CloseActivePane() { From 4cc1ea79347825c7ee73d951de4e1d57087d559d Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Mon, 4 Aug 2025 11:29:40 -0400 Subject: [PATCH 2/2] Update ToggleDualPaneAction.cs --- src/Files.App/Actions/Show/ToggleDualPaneAction.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Actions/Show/ToggleDualPaneAction.cs b/src/Files.App/Actions/Show/ToggleDualPaneAction.cs index 627f052c32e4..a7004a0957ec 100644 --- a/src/Files.App/Actions/Show/ToggleDualPaneAction.cs +++ b/src/Files.App/Actions/Show/ToggleDualPaneAction.cs @@ -27,7 +27,7 @@ public Task ExecuteAsync(object? parameter = null) if (IsOn) ContentPageContext.ShellPage?.PaneHolder.CloseOtherPane(); else - ContentPageContext.ShellPage!.PaneHolder.OpenSecondaryPane(arrangement: generalSettingsService.ShellPaneArrangementOption); + ContentPageContext.ShellPage?.PaneHolder.OpenSecondaryPane(arrangement: generalSettingsService.ShellPaneArrangementOption); return Task.CompletedTask; }