From faa240ab972fbb50b918b6598b18f1c4e9640512 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Tue, 4 Oct 2016 14:01:36 -0600 Subject: [PATCH] Sorting tree nodes is now recursive in all cases to be more in line with user expectations --- mRemoteV1/UI/Window/ConnectionTreeWindow.cs | 24 ++++++++++----------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs index d3490f3b4..d44229bb1 100644 --- a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs +++ b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs @@ -202,8 +202,8 @@ namespace mRemoteNG.UI.Window _contextMenu.ExportFileClicked += (sender, args) => Export.ExportToFile(SelectedNode, Runtime.ConnectionTreeModel); _contextMenu.AddConnectionClicked += cMenTreeAddConnection_Click; _contextMenu.AddFolderClicked += cMenTreeAddFolder_Click; - _contextMenu.SortAscendingClicked += (sender, args) => SortNodes(ListSortDirection.Ascending); - _contextMenu.SortDescendingClicked += (sender, args) => SortNodes(ListSortDirection.Descending); + _contextMenu.SortAscendingClicked += (sender, args) => SortNodesRecursive(SelectedNode, ListSortDirection.Ascending); + _contextMenu.SortDescendingClicked += (sender, args) => SortNodesRecursive(SelectedNode, ListSortDirection.Descending); _contextMenu.MoveUpClicked += cMenTreeMoveUp_Click; _contextMenu.MoveDownClicked += cMenTreeMoveDown_Click; _contextMenu.ExternalToolClicked += (sender, args) => StartExternalApp((ExternalTool)((ToolStripMenuItem)sender).Tag); @@ -513,19 +513,17 @@ namespace mRemoteNG.UI.Window Runtime.SaveConnectionsAsync(); } - private void SortNodes(ListSortDirection sortDirection) + private void SortNodesRecursive(ConnectionInfo sortTarget, ListSortDirection sortDirection) { - var selectedNodeAsContainer = SelectedNode as ContainerInfo; - if (selectedNodeAsContainer != null) - selectedNodeAsContainer.Sort(sortDirection); - else - SelectedNode.Parent.Sort(sortDirection); - Runtime.SaveConnectionsAsync(); - } + if (sortTarget == null) + sortTarget = GetRootConnectionNode(); + + var sortTargetAsContainer = sortTarget as ContainerInfo; + if (sortTargetAsContainer != null) + sortTargetAsContainer.SortRecursive(sortDirection); + else + SelectedNode.Parent.SortRecursive(sortDirection); - private void SortNodesRecursive(ContainerInfo rootSortTarget, ListSortDirection sortDirection) - { - rootSortTarget.SortRecursive(sortDirection); Runtime.SaveConnectionsAsync(); }