Duplicating nodes now works

This commit is contained in:
David Sparer
2016-09-07 14:36:52 -06:00
parent 8bf5004147
commit 5ea2304d5e
5 changed files with 23 additions and 8 deletions

View File

@@ -670,7 +670,8 @@ namespace mRemoteNG.Connection
#region Public Methods
public virtual ConnectionInfo Clone()
{
var newConnectionInfo = (ConnectionInfo)MemberwiseClone();
var newConnectionInfo = new ConnectionInfo();
newConnectionInfo.CopyFrom(this);
newConnectionInfo.ConstantID = MiscTools.CreateConstantID();
newConnectionInfo.SetParent(Parent);
newConnectionInfo.OpenConnections = new ProtocolList();
@@ -718,7 +719,7 @@ namespace mRemoteNG.Connection
return filteredProperties;
}
public void SetParent(ContainerInfo parent)
public virtual void SetParent(ContainerInfo parent)
{
parent?.AddChild(this);
}

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using mRemoteNG.Connection;
using System.ComponentModel;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Tools;
using mRemoteNG.Tree;
@@ -66,9 +67,17 @@ namespace mRemoteNG.Container
public override ConnectionInfo Clone()
{
var newContainer = new ContainerInfo();
newContainer.CopyFrom(base.Clone());
foreach (var child in Children)
newContainer.AddChild(child.Clone());
newContainer.CopyFrom(this);
newContainer.ConstantID = MiscTools.CreateConstantID();
newContainer.SetParent(Parent);
newContainer.OpenConnections = new ProtocolList();
newContainer.Inheritance = Inheritance.Clone();
foreach (var child in Children.ToArray())
{
var newChild = child.Clone();
newChild.RemoveParent();
newContainer.AddChild(newChild);
}
return newContainer;
}

View File

@@ -37,6 +37,10 @@ namespace mRemoteNG.Tree
connectionInfo?.Dispose();
}
public void CloneNode(ConnectionInfo connectionInfo)
{
connectionInfo.Clone();
}
}
}

View File

@@ -175,7 +175,7 @@ namespace mRemoteNG.Tree
{
ContainerInfo oldContainerInfo = (ContainerInfo) oldTreeNode.Tag;
ContainerInfo newContainerInfo = oldContainerInfo.Clone();
ContainerInfo newContainerInfo = (ContainerInfo)oldContainerInfo.Clone();
ConnectionInfo newConnectionInfo = oldContainerInfo.Clone();
newContainerInfo.CopyFrom(newConnectionInfo);

View File

@@ -654,9 +654,10 @@ namespace mRemoteNG.UI.Window
//TODO Fix for TreeListView
private void cMenTreeDuplicate_Click(object sender, EventArgs e)
{
ConnectionTreeNode.CloneNode(tvConnections.SelectedNode);
{
SelectedNode.Clone();
Runtime.SaveConnectionsBG();
olvConnections.RebuildAll(true);
}
private void cMenTreeRename_Click(object sender, EventArgs e)