request iconnectiontree interface in more places

This commit is contained in:
David Sparer
2019-01-22 06:01:33 -06:00
parent f78ca1e9fd
commit 4b736176bf
5 changed files with 11 additions and 12 deletions

View File

@@ -42,7 +42,7 @@ namespace mRemoteNG.Tree
public IEnumerable<ConnectionInfo> GetRecursiveChildList(ContainerInfo container)
{
return container.GetRecursiveChildList();
return container?.GetRecursiveChildList() ?? new ConnectionInfo[0];
}
public void RenameNode(ConnectionInfo connectionInfo, string newName)

View File

@@ -7,13 +7,13 @@ namespace mRemoteNG.Tree
{
public class NodeSearcher
{
private readonly ConnectionTreeModel _connectionTreeModel;
private readonly IConnectionTreeModel _connectionTreeModel;
private List<ConnectionInfo> Matches { get; set; }
public ConnectionInfo CurrentMatch { get; private set; }
public NodeSearcher(ConnectionTreeModel connectionTreeModel)
public NodeSearcher(IConnectionTreeModel connectionTreeModel)
{
_connectionTreeModel = connectionTreeModel;
}

View File

@@ -24,7 +24,7 @@ namespace mRemoteNG.UI.Controls
private bool _nodeInEditMode;
private bool _allowEdit;
private ConnectionContextMenu _contextMenu;
private ConnectionTreeModel _connectionTreeModel;
private IConnectionTreeModel _connectionTreeModel;
public ConnectionInfo SelectedNode => (ConnectionInfo) SelectedObject;
@@ -38,7 +38,7 @@ namespace mRemoteNG.UI.Controls
public ITreeNodeClickHandler<ConnectionInfo> SingleClickHandler { get; set; } = new TreeNodeCompositeClickHandler();
public ConnectionTreeModel ConnectionTreeModel
public IConnectionTreeModel ConnectionTreeModel
{
get { return _connectionTreeModel; }
set
@@ -158,7 +158,7 @@ namespace mRemoteNG.UI.Controls
padding;
}
private void PopulateTreeView(ConnectionTreeModel newModel)
private void PopulateTreeView(IConnectionTreeModel newModel)
{
SetObjects(newModel.RootNodes);
RegisterModelUpdateHandlers(newModel);
@@ -167,14 +167,14 @@ namespace mRemoteNG.UI.Controls
AutoResizeColumn(Columns[0]);
}
private void RegisterModelUpdateHandlers(ConnectionTreeModel newModel)
private void RegisterModelUpdateHandlers(IConnectionTreeModel newModel)
{
_puttySessionsManager.PuttySessionsCollectionChanged += OnPuttySessionsCollectionChanged;
newModel.CollectionChanged += HandleCollectionChanged;
newModel.PropertyChanged += HandleCollectionPropertyChanged;
}
private void UnregisterModelUpdateHandlers(ConnectionTreeModel oldConnectionTreeModel)
private void UnregisterModelUpdateHandlers(IConnectionTreeModel oldConnectionTreeModel)
{
_puttySessionsManager.PuttySessionsCollectionChanged -= OnPuttySessionsCollectionChanged;
@@ -221,7 +221,7 @@ namespace mRemoteNG.UI.Controls
#region ConnectionTree Behavior
public RootNodeInfo GetRootConnectionNode()
{
return (RootNodeInfo)ConnectionTreeModel.RootNodes.First(item => item is RootNodeInfo);
return (RootNodeInfo)ConnectionTreeModel.RootNodes.FirstOrDefault(item => item is RootNodeInfo);
}
public void Invoke(Action action)

View File

@@ -8,7 +8,7 @@ namespace mRemoteNG.UI.Controls
{
public interface IConnectionTree
{
ConnectionTreeModel ConnectionTreeModel { get; set; }
IConnectionTreeModel ConnectionTreeModel { get; set; }
ConnectionInfo SelectedNode { get; }

View File

@@ -27,7 +27,6 @@ namespace mRemoteNG.UI.Window
public ConnectionTree ConnectionTree
{
get { return olvConnections; }
set { olvConnections = value; }
}
public ConnectionTreeWindow() : this(new DockContent())
@@ -43,6 +42,7 @@ namespace mRemoteNG.UI.Window
SetConnectionTreeEventHandlers();
Settings.Default.PropertyChanged += OnAppSettingsChanged;
ApplyLanguage();
ConnectionTree.ConnectionTreeModel = Runtime.ConnectionsService.ConnectionTreeModel;
}
private void OnAppSettingsChanged(object o, PropertyChangedEventArgs propertyChangedEventArgs)
@@ -54,7 +54,6 @@ namespace mRemoteNG.UI.Window
}
PlaceSearchBar(Settings.Default.PlaceSearchBarAboveConnectionTree);
}
private void PlaceSearchBar(bool placeSearchBarAboveConnectionTree)