mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Moved the code for generating a recursive list of children to ContainerInfo where it makes more sense. Left a helper function in ConnectionTreeModel where it may still be useful
This commit is contained in:
@@ -33,7 +33,7 @@ namespace mRemoteNGTests.Tree
|
||||
folder1.Add(folder2);
|
||||
root.Add(con1);
|
||||
_connectionTreeModel.AddRootNode(root);
|
||||
var connectionList = _connectionTreeModel.GetChildList(root);
|
||||
var connectionList = _connectionTreeModel.GetRecursiveChildList(root);
|
||||
Assert.That(connectionList, Is.EquivalentTo(new[] {folder1,folder2,con1}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,5 +62,31 @@ namespace mRemoteNG.Container
|
||||
{
|
||||
IsExpanded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<ConnectionInfo> GetRecursiveChildList()
|
||||
{
|
||||
var childList = new List<ConnectionInfo>();
|
||||
foreach (var child in Children)
|
||||
{
|
||||
childList.Add(child);
|
||||
var childContainer = child as ContainerInfo;
|
||||
if (childContainer != null)
|
||||
childList.AddRange(GetRecursiveChildList(childContainer));
|
||||
}
|
||||
return childList;
|
||||
}
|
||||
|
||||
private IEnumerable<ConnectionInfo> GetRecursiveChildList(ContainerInfo container)
|
||||
{
|
||||
var childList = new List<ConnectionInfo>();
|
||||
foreach (var child in container.Children)
|
||||
{
|
||||
childList.Add(child);
|
||||
var childContainer = child as ContainerInfo;
|
||||
if (childContainer != null)
|
||||
childList.AddRange(GetRecursiveChildList(childContainer));
|
||||
}
|
||||
return childList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,17 +14,9 @@ namespace mRemoteNG.Tree
|
||||
RootNodes.Add(rootNode);
|
||||
}
|
||||
|
||||
public IEnumerable<ConnectionInfo> GetChildList(ContainerInfo container)
|
||||
public IEnumerable<ConnectionInfo> GetRecursiveChildList(ContainerInfo container)
|
||||
{
|
||||
var childList = new List<ConnectionInfo>();
|
||||
foreach (var child in container.Children)
|
||||
{
|
||||
childList.Add(child);
|
||||
var childContainer = child as ContainerInfo;
|
||||
if (childContainer != null)
|
||||
childList.AddRange(GetChildList(childContainer));
|
||||
}
|
||||
return childList;
|
||||
return container.GetRecursiveChildList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ namespace mRemoteNG.UI.Window
|
||||
|
||||
public void ExpandPreviouslyOpenedFolders()
|
||||
{
|
||||
var containerList = ConnectionTreeModel.GetChildList(GetRootConnectionNode()).OfType<ContainerInfo>();
|
||||
var containerList = ConnectionTreeModel.GetRecursiveChildList(GetRootConnectionNode()).OfType<ContainerInfo>();
|
||||
var previouslyExpandedNodes = containerList.Where(container => container.IsExpanded);
|
||||
olvConnections.ExpandedObjects = previouslyExpandedNodes;
|
||||
olvConnections.RebuildAll(true);
|
||||
|
||||
Reference in New Issue
Block a user