From 16693779381755d9aed85bf2dfc9ff4a429a0238 Mon Sep 17 00:00:00 2001 From: Pedro Rodrigues Date: Sat, 9 Sep 2017 17:17:23 +0100 Subject: [PATCH] Use root node when creating new connection/folder and no node is selected --- mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs b/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs index cf7c8ff56..7def618fb 100644 --- a/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs +++ b/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs @@ -204,11 +204,12 @@ namespace mRemoteNG.UI.Controls private void AddNode(ConnectionInfo newNode) { - if (SelectedNode == null) return; + // use root node if no node is selected + ConnectionInfo parentNode = (SelectedNode == null) ? Roots.Cast().First(item => item is RootNodeInfo) : SelectedNode; DefaultConnectionInfo.Instance.SaveTo(newNode); DefaultConnectionInheritance.Instance.SaveTo(newNode.Inheritance); - var selectedContainer = SelectedNode as ContainerInfo; - var parent = selectedContainer ?? SelectedNode?.Parent; + var selectedContainer = parentNode as ContainerInfo; + var parent = selectedContainer ?? parentNode?.Parent; newNode.SetParent(parent); Expand(parent); SelectObject(newNode, true);