Fixed bug where loading a new connection file or creating a new one would not update the connection tree

This commit is contained in:
David Sparer
2016-09-29 11:01:06 -06:00
parent 14d56c3e28
commit a71cf6080f
3 changed files with 11 additions and 11 deletions

View File

@@ -228,12 +228,10 @@ namespace mRemoteNG.App
}
var rootConnectionNode = ConnectionTreeModel.RootNodes.First(node => !(node is RootPuttySessionsNodeInfo));
ConnectionTreeModel.RemoveRootNode(rootConnectionNode);
// Load config
connectionsLoader.ConnectionFileName = filename;
connectionsLoader.LoadConnections(false);
ConnectionTreeModel = connectionsLoader.LoadConnections(false);
Windows.TreeForm.ConnectionTreeModel = ConnectionTreeModel;
}
catch (Exception ex)
{
@@ -270,7 +268,7 @@ namespace mRemoteNG.App
{
if (withDialog)
{
var loadDialog = Tools.Controls.ConnectionsLoadDialog();
var loadDialog = Controls.ConnectionsLoadDialog();
if (loadDialog.ShowDialog() != DialogResult.OK) return;
connectionsLoader.ConnectionFileName = loadDialog.FileName;
}
@@ -283,7 +281,8 @@ namespace mRemoteNG.App
}
connectionsLoader.UseDatabase = Settings.Default.UseSQLServer;
connectionsLoader.LoadConnections(false);
ConnectionTreeModel = connectionsLoader.LoadConnections(false);
Windows.TreeForm.ConnectionTreeModel = ConnectionTreeModel;
if (Settings.Default.UseSQLServer)
{

View File

@@ -3,6 +3,7 @@ using mRemoteNG.Config.DatabaseConnectors;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Putty;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Tree;
using mRemoteNG.UI.Forms;
@@ -14,7 +15,7 @@ namespace mRemoteNG.Config.Connections
public string ConnectionFileName { get; set; }
public void LoadConnections(bool import)
public ConnectionTreeModel LoadConnections(bool import)
{
IDeserializer deserializer;
if (UseDatabase)
@@ -32,14 +33,15 @@ namespace mRemoteNG.Config.Connections
}
var connectionTreeModel = deserializer.Deserialize();
Runtime.ConnectionTreeModel = connectionTreeModel;
frmMain.Default.AreWeUsingSqlServerForSavingConnections = UseDatabase;
frmMain.Default.ConnectionsFileName = ConnectionFileName;
if (import) return;
if (import) return connectionTreeModel;
PuttySessionsManager.Instance.AddSessions();
Runtime.ConnectionTreeModel.RootNodes.AddRange(PuttySessionsManager.Instance.RootPuttySessionsNodes);
connectionTreeModel.RootNodes.AddRange(PuttySessionsManager.Instance.RootPuttySessionsNodes);
return connectionTreeModel;
}
}
}

View File

@@ -171,7 +171,6 @@ namespace mRemoteNG.UI.Forms
Opacity = 1;
ConnectionTreeWindow = Windows.TreeForm;
ConnectionTreeWindow.ConnectionTreeModel = Runtime.ConnectionTreeModel;
}
private void ApplySpecialSettingsForPortableVersion()