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

This commit is contained in:
David Sparer
2016-09-27 10:36:30 -06:00
parent 20339c1452
commit 60b387ac56

View File

@@ -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