Use root node when creating new connection/folder and no node is selected

This commit is contained in:
Pedro Rodrigues
2017-09-09 17:17:23 +01:00
parent 66f2c55343
commit 1669377938

View File

@@ -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<ConnectionInfo>().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);