From 60b387ac56907ee89a1f69b41533e69cc0feeb2c Mon Sep 17 00:00:00 2001 From: David Sparer Date: Tue, 27 Sep 2016 10:36:30 -0600 Subject: [PATCH] Adding a new node will expand the parent container, select the new node, and ensure the new node is visible. Extracted a method since these actions are identical for both containers and connections --- mRemoteV1/UI/Window/ConnectionTreeWindow.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs index 126c4b42d..bbc17c87c 100644 --- a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs +++ b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs @@ -503,9 +503,7 @@ namespace mRemoteNG.UI.Window { try { - var newConnectionInfo = new ConnectionInfo(); - var selectedContainer = SelectedNode as ContainerInfo; - newConnectionInfo.SetParent(selectedContainer ?? SelectedNode.Parent); + AddNode(new ConnectionInfo()); } catch (Exception ex) { @@ -517,9 +515,7 @@ namespace mRemoteNG.UI.Window { try { - var newContainerInfo = new ContainerInfo(); - var selectedContainer = SelectedNode as ContainerInfo; - newContainerInfo.SetParent(selectedContainer ?? SelectedNode.Parent); + AddNode(new ContainerInfo()); } catch (Exception ex) { @@ -527,6 +523,16 @@ namespace mRemoteNG.UI.Window } } + private void AddNode(IHasParent newNode) + { + var selectedContainer = SelectedNode as ContainerInfo; + var parent = selectedContainer ?? SelectedNode.Parent; + newNode.SetParent(parent); + olvConnections.Expand(parent); + olvConnections.SelectObject(newNode); + olvConnections.EnsureModelVisible(newNode); + } + private void DisconnectConnection(ConnectionInfo connectionInfo) { try