From 3dc37d035912db81dc30831507963c6507d944aa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Oct 2025 17:33:38 +0000 Subject: [PATCH] Refine PanelBinder implementation and add documentation Co-authored-by: Kvarkas <3611964+Kvarkas@users.noreply.github.com> --- PANEL_BINDING_FEATURE.md | 67 ++++++++++++++++++++++++++++++ mRemoteNG/UI/Panels/PanelBinder.cs | 23 ++++------ 2 files changed, 74 insertions(+), 16 deletions(-) create mode 100644 PANEL_BINDING_FEATURE.md diff --git a/PANEL_BINDING_FEATURE.md b/PANEL_BINDING_FEATURE.md new file mode 100644 index 00000000..09ff15a4 --- /dev/null +++ b/PANEL_BINDING_FEATURE.md @@ -0,0 +1,67 @@ +# Panel Binding Feature + +## Overview +This feature allows users to bind the Connections and Config panels together when they are in auto-hide state (collapsed). When one panel is clicked to expand, the other panel will automatically expand as well. + +## How It Works + +### User Workflow +1. The user collapses both the Connections and Config panels by clicking the auto-hide pin icon (they become auto-hidden tabs on the left side) +2. The user enables the "Bind Connections and Config panels together when auto-hidden" option in Tools > Options > Tabs & Panels +3. When the user clicks on the Connections tab to expand it, the Config panel will automatically expand as well +4. Similarly, when clicking on the Config tab, the Connections panel will expand +5. Both panels stay expanded together, allowing the user to view connection settings easily +6. When the user clicks away from the panels, both collapse back to auto-hide + +### Benefits +- Reduces the number of clicks needed to view and edit connection settings +- Panels work together seamlessly when in auto-hide mode +- User can still use panels independently when they are pinned (docked) +- Configurable option allows users to enable/disable as needed + +## Implementation Details + +### Files Modified +1. **Properties/OptionsTabsPanelsPage.settings** - Added `BindConnectionsAndConfigPanels` setting (default: false) +2. **Properties/OptionsTabsPanelsPage.Designer.cs** - Added property accessor for the new setting +3. **UI/Panels/PanelBinder.cs** - NEW - Core logic for binding panel visibility +4. **UI/Forms/OptionsPages/TabsPanelsPage.cs** - Added checkbox and load/save logic +5. **UI/Forms/OptionsPages/TabsPanelsPage.Designer.cs** - Added UI checkbox control +6. **UI/Forms/frmMain.cs** - Initialize PanelBinder after panels are loaded +7. **Config/Settings/Registry/OptRegistryTabsPanelsPage.cs** - Added registry support for enterprise deployment + +### Key Classes + +#### PanelBinder +- Singleton class that manages the binding between panels +- Subscribes to VisibleChanged events on both TreeForm (Connections) and ConfigForm (Config) +- Only acts when: + - The binding setting is enabled + - Both panels are in auto-hide state + - One panel becomes visible (user clicked its tab) +- Uses a `_isProcessing` flag to prevent recursive event triggers +- Calls `Activate()` on the other panel to show it + +### How to Test + +1. Build and run mRemoteNG +2. Go to Tools > Options > Tabs & Panels +3. Verify the new checkbox "Bind Connections and Config panels together when auto-hidden" is present +4. Create a test connection in the Connections panel +5. Auto-hide both the Connections and Config panels (click the pin icon on each) +6. Both panels should now appear as collapsed tabs on the left side +7. Enable the binding option in Options +8. Click on the Connections tab - both Connections and Config should expand +9. Click away from the panels - both should collapse +10. Click on the Config tab - both panels should expand again +11. Disable the binding option +12. Verify panels now work independently when clicking their tabs +13. Pin one or both panels (dock them) +14. Verify the binding only works when BOTH panels are in auto-hide state + +## Registry Support + +Administrators can configure this setting via registry for enterprise deployment: +- Key: `HKEY_LOCAL_MACHINE\SOFTWARE\mRemoteNG\TabsAndPanels` or `HKEY_CURRENT_USER\SOFTWARE\mRemoteNG\TabsAndPanels` +- Value: `BindConnectionsAndConfigPanels` (DWORD) +- 0 = Disabled, 1 = Enabled diff --git a/mRemoteNG/UI/Panels/PanelBinder.cs b/mRemoteNG/UI/Panels/PanelBinder.cs index e11aff2d..a53506ba 100644 --- a/mRemoteNG/UI/Panels/PanelBinder.cs +++ b/mRemoteNG/UI/Panels/PanelBinder.cs @@ -29,22 +29,21 @@ namespace mRemoteNG.UI.Panels if (Windows.TreeForm != null) { Windows.TreeForm.VisibleChanged += OnTreeFormVisibleChanged; - Windows.TreeForm.DockStateChanged += OnTreeFormDockStateChanged; } if (Windows.ConfigForm != null) { Windows.ConfigForm.VisibleChanged += OnConfigFormVisibleChanged; - Windows.ConfigForm.DockStateChanged += OnConfigFormDockStateChanged; } } private void OnTreeFormVisibleChanged(object sender, EventArgs e) { + // Only act when binding is enabled and not already processing if (!OptionsTabsPanelsPage.Default.BindConnectionsAndConfigPanels || _isProcessing) return; - // Only act when the panel becomes visible + // Only act when the panel becomes visible (expanded from auto-hide) if (!Windows.TreeForm.Visible) return; @@ -55,6 +54,7 @@ namespace mRemoteNG.UI.Panels _isProcessing = true; try { + // Show the Config panel by activating it ShowPanel(Windows.ConfigForm); } finally @@ -65,10 +65,11 @@ namespace mRemoteNG.UI.Panels private void OnConfigFormVisibleChanged(object sender, EventArgs e) { + // Only act when binding is enabled and not already processing if (!OptionsTabsPanelsPage.Default.BindConnectionsAndConfigPanels || _isProcessing) return; - // Only act when the panel becomes visible + // Only act when the panel becomes visible (expanded from auto-hide) if (!Windows.ConfigForm.Visible) return; @@ -79,6 +80,7 @@ namespace mRemoteNG.UI.Panels _isProcessing = true; try { + // Show the Connections panel by activating it ShowPanel(Windows.TreeForm); } finally @@ -87,18 +89,6 @@ namespace mRemoteNG.UI.Panels } } - private void OnTreeFormDockStateChanged(object sender, EventArgs e) - { - // This event helps us track when panels transition to/from auto-hide - // We don't need to take action here, just be aware of state changes - } - - private void OnConfigFormDockStateChanged(object sender, EventArgs e) - { - // This event helps us track when panels transition to/from auto-hide - // We don't need to take action here, just be aware of state changes - } - /// /// Checks if a panel is in auto-hide state /// @@ -120,6 +110,7 @@ namespace mRemoteNG.UI.Panels { if (panel != null && IsPanelAutoHidden(panel)) { + // Activate the panel to show it from auto-hide panel.Activate(); } }