mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user