From b9718edfd3d47762be417e6b6d967e6fabfd1fb9 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Wed, 14 Sep 2016 13:07:08 -0600 Subject: [PATCH] Folders will now expand when scrolling through search results --- mRemoteV1/UI/Window/ConnectionTreeWindow.cs | 29 ++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs index 4e9082a3e..898cb7c5e 100644 --- a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs +++ b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs @@ -821,17 +821,15 @@ namespace mRemoteNG.UI.Window { //tvConnections.SelectedNode = tvConnections.SelectedNode.PrevVisibleNode; var match = _nodeSearcher.PreviousMatch(); - olvConnections.SelectObject(match); - olvConnections.EnsureModelVisible(match); - e.Handled = true; + JumpToNode(match); + e.Handled = true; } else if (e.KeyCode == Keys.Down) { //tvConnections.SelectedNode = tvConnections.SelectedNode.NextVisibleNode; var match = _nodeSearcher.NextMatch(); - olvConnections.SelectObject(match); - olvConnections.EnsureModelVisible(match); - e.Handled = true; + JumpToNode(match); + e.Handled = true; } else { @@ -849,9 +847,22 @@ namespace mRemoteNG.UI.Window { var matches = _nodeSearcher.SearchByName(txtSearch.Text); var match = matches.First(); - olvConnections.SelectObject(match); - olvConnections.EnsureModelVisible(match); - } + JumpToNode(match); + } + + private void JumpToNode(ConnectionInfo connectionInfo) + { + ExpandParentsRecursive(connectionInfo); + olvConnections.SelectObject(connectionInfo); + olvConnections.EnsureModelVisible(connectionInfo); + } + + private void ExpandParentsRecursive(ConnectionInfo connectionInfo) + { + if (connectionInfo.Parent == null) return; + olvConnections.Expand(connectionInfo.Parent); + ExpandParentsRecursive(connectionInfo.Parent); + } //TODO Fix for TreeListView private void tvConnections_KeyPress(object sender, KeyPressEventArgs e)