using System.Linq; using mRemoteNG.Container; using mRemoteNG.UI.Controls; namespace mRemoteNG.Tree { public class PreviouslyOpenedFolderExpander : IConnectionTreeDelegate { public void Execute(IConnectionTree connectionTree) { var rootNode = connectionTree.GetRootConnectionNode(); var containerList = connectionTree.ConnectionTreeModel.GetRecursiveChildList(rootNode).OfType(); var previouslyExpandedNodes = containerList.Where(container => container.IsExpanded); connectionTree.ExpandedObjects = previouslyExpandedNodes; connectionTree.InvokeRebuildAll(true); } } }