From 7f80cad356431ead480b99b5f901a2febd836a9c Mon Sep 17 00:00:00 2001 From: David Sparer Date: Wed, 10 May 2017 19:59:56 -0600 Subject: [PATCH] moved property from Runtime to ConnectionsService --- mRemoteV1/App/Runtime.cs | 15 +++++---------- mRemoteV1/Config/Connections/ConnectionsSaver.cs | 2 +- .../Multiuser/RemoteConnectionsSyncronizer.cs | 2 +- mRemoteV1/Connection/ConnectionsService.cs | 10 ++++++++-- mRemoteV1/Tools/NotificationAreaIcon.cs | 2 +- mRemoteV1/UI/Controls/ConnectionContextMenu.cs | 4 ++-- mRemoteV1/UI/Controls/QuickConnectToolStrip.cs | 2 +- mRemoteV1/UI/Menu/MainFileMenu.cs | 4 ++-- .../UI/Window/ActiveDirectoryImportWindow.cs | 2 +- 9 files changed, 22 insertions(+), 21 deletions(-) diff --git a/mRemoteV1/App/Runtime.cs b/mRemoteV1/App/Runtime.cs index cb8bda5a..35539ab1 100644 --- a/mRemoteV1/App/Runtime.cs +++ b/mRemoteV1/App/Runtime.cs @@ -42,11 +42,6 @@ namespace mRemoteNG.App private static DateTime LastSqlUpdate { get; set; } public static ExternalToolsService ExternalToolsService { get; } = new ExternalToolsService(); public static SecureString EncryptionKey { get; set; } = new RootNodeInfo(RootNodeType.Connection).PasswordString.ConvertToSecureString(); - public static ConnectionTreeModel ConnectionTreeModel - { - get { return Windows.TreeForm.ConnectionTree.ConnectionTreeModel; } - set { Windows.TreeForm.ConnectionTree.ConnectionTreeModel = value; } - } public static ICredentialRepositoryList CredentialProviderCatalog { get; } = new CredentialRepositoryList(); public static ConnectionsService ConnectionsService { get; } = new ConnectionsService(); #endregion @@ -92,8 +87,8 @@ namespace mRemoteNG.App } connectionsLoader.UseDatabase = Settings.Default.UseSQLServer; - ConnectionTreeModel = connectionsLoader.LoadConnections(CredentialProviderCatalog.GetCredentialRecords(), false); - Windows.TreeForm.ConnectionTree.ConnectionTreeModel = ConnectionTreeModel; + ConnectionsService.ConnectionTreeModel = connectionsLoader.LoadConnections(CredentialProviderCatalog.GetCredentialRecords(), false); + Windows.TreeForm.ConnectionTree.ConnectionTreeModel = ConnectionsService.ConnectionTreeModel; if (Settings.Default.UseSQLServer) { @@ -227,7 +222,7 @@ namespace mRemoteNG.App public static void SaveConnections() { - if (ConnectionTreeModel == null) return; + if (ConnectionsService.ConnectionTreeModel == null) return; if (!ConnectionsService.IsConnectionsFileLoaded) return; try @@ -240,7 +235,7 @@ namespace mRemoteNG.App connectionsSaver.ConnectionFileName = ConnectionsService.GetStartupConnectionFileName(); connectionsSaver.SaveFilter = new SaveFilter(); - connectionsSaver.ConnectionTreeModel = ConnectionTreeModel; + connectionsSaver.ConnectionTreeModel = ConnectionsService.ConnectionTreeModel; if (Settings.Default.UseSQLServer) { @@ -288,7 +283,7 @@ namespace mRemoteNG.App connectionsSave.SaveFormat = ConnectionsSaver.Format.mRXML; connectionsSave.ConnectionFileName = saveFileDialog.FileName; connectionsSave.SaveFilter = new SaveFilter(); - connectionsSave.ConnectionTreeModel = ConnectionTreeModel; + connectionsSave.ConnectionTreeModel = ConnectionsService.ConnectionTreeModel; connectionsSave.SaveConnections(); diff --git a/mRemoteV1/Config/Connections/ConnectionsSaver.cs b/mRemoteV1/Config/Connections/ConnectionsSaver.cs index 2a706a0f..3e5ce82a 100644 --- a/mRemoteV1/Config/Connections/ConnectionsSaver.cs +++ b/mRemoteV1/Config/Connections/ConnectionsSaver.cs @@ -93,7 +93,7 @@ namespace mRemoteNG.Config.Connections return; } - var rootTreeNode = Runtime.ConnectionTreeModel.RootNodes.OfType().First(); + var rootTreeNode = Runtime.ConnectionsService.ConnectionTreeModel.RootNodes.OfType().First(); UpdateRootNodeTable(rootTreeNode, sqlConnector); UpdateConnectionsTable(rootTreeNode, sqlConnector); diff --git a/mRemoteV1/Config/Connections/Multiuser/RemoteConnectionsSyncronizer.cs b/mRemoteV1/Config/Connections/Multiuser/RemoteConnectionsSyncronizer.cs index ad381deb..d097fdf5 100644 --- a/mRemoteV1/Config/Connections/Multiuser/RemoteConnectionsSyncronizer.cs +++ b/mRemoteV1/Config/Connections/Multiuser/RemoteConnectionsSyncronizer.cs @@ -37,7 +37,7 @@ namespace mRemoteNG.Config.Connections.Multiuser public void Load() { - Runtime.ConnectionTreeModel = _connectionsLoader.LoadConnections(Runtime.CredentialProviderCatalog.GetCredentialRecords(), false); + Runtime.ConnectionsService.ConnectionTreeModel = _connectionsLoader.LoadConnections(Runtime.CredentialProviderCatalog.GetCredentialRecords(), false); } private void Load(object sender, ConnectionsUpdateAvailableEventArgs args) diff --git a/mRemoteV1/Connection/ConnectionsService.cs b/mRemoteV1/Connection/ConnectionsService.cs index 6540d14d..a32e4c9b 100644 --- a/mRemoteV1/Connection/ConnectionsService.cs +++ b/mRemoteV1/Connection/ConnectionsService.cs @@ -13,6 +13,12 @@ namespace mRemoteNG.Connection { public bool IsConnectionsFileLoaded { get; set; } + public ConnectionTreeModel ConnectionTreeModel + { + get { return Windows.TreeForm.ConnectionTree.ConnectionTreeModel; } + set { Windows.TreeForm.ConnectionTree.ConnectionTreeModel = value; } + } + public void NewConnections(string filename) { try @@ -30,8 +36,8 @@ namespace mRemoteNG.Connection // Load config var connectionsLoader = new ConnectionsLoader { ConnectionFileName = filename }; - Runtime.ConnectionTreeModel = connectionsLoader.LoadConnections(Runtime.CredentialProviderCatalog.GetCredentialRecords(), false); - Windows.TreeForm.ConnectionTree.ConnectionTreeModel = Runtime.ConnectionTreeModel; + ConnectionTreeModel = connectionsLoader.LoadConnections(Runtime.CredentialProviderCatalog.GetCredentialRecords(), false); + Windows.TreeForm.ConnectionTree.ConnectionTreeModel = ConnectionTreeModel; } catch (Exception ex) { diff --git a/mRemoteV1/Tools/NotificationAreaIcon.cs b/mRemoteV1/Tools/NotificationAreaIcon.cs index 919a7413..da4b62c5 100644 --- a/mRemoteV1/Tools/NotificationAreaIcon.cs +++ b/mRemoteV1/Tools/NotificationAreaIcon.cs @@ -84,7 +84,7 @@ namespace mRemoteNG.Tools }; // ReSharper disable once CoVariantArrayConversion - ToolStripItem[] rootMenuItems = menuItemsConverter.CreateToolStripDropDownItems(Runtime.ConnectionTreeModel).ToArray(); + ToolStripItem[] rootMenuItems = menuItemsConverter.CreateToolStripDropDownItems(Runtime.ConnectionsService.ConnectionTreeModel).ToArray(); _cMenCons.DropDownItems.AddRange(rootMenuItems); } diff --git a/mRemoteV1/UI/Controls/ConnectionContextMenu.cs b/mRemoteV1/UI/Controls/ConnectionContextMenu.cs index 5dd0dc41..4de4022a 100644 --- a/mRemoteV1/UI/Controls/ConnectionContextMenu.cs +++ b/mRemoteV1/UI/Controls/ConnectionContextMenu.cs @@ -719,7 +719,7 @@ namespace mRemoteNG.UI.Controls { ContainerInfo selectedNodeAsContainer; if (_connectionTree.SelectedNode == null) - selectedNodeAsContainer = Runtime.ConnectionTreeModel.RootNodes.First(); + selectedNodeAsContainer = Runtime.ConnectionsService.ConnectionTreeModel.RootNodes.First(); else selectedNodeAsContainer = _connectionTree.SelectedNode as ContainerInfo ?? _connectionTree.SelectedNode.Parent; Import.ImportFromFile(selectedNodeAsContainer); @@ -737,7 +737,7 @@ namespace mRemoteNG.UI.Controls private void OnExportFileClicked(object sender, EventArgs e) { - Export.ExportToFile(_connectionTree.SelectedNode, Runtime.ConnectionTreeModel); + Export.ExportToFile(_connectionTree.SelectedNode, Runtime.ConnectionsService.ConnectionTreeModel); } private void OnAddConnectionClicked(object sender, EventArgs e) diff --git a/mRemoteV1/UI/Controls/QuickConnectToolStrip.cs b/mRemoteV1/UI/Controls/QuickConnectToolStrip.cs index faad2208..dea83202 100644 --- a/mRemoteV1/UI/Controls/QuickConnectToolStrip.cs +++ b/mRemoteV1/UI/Controls/QuickConnectToolStrip.cs @@ -214,7 +214,7 @@ namespace mRemoteNG.UI.Controls }; // ReSharper disable once CoVariantArrayConversion - ToolStripItem[] rootMenuItems = menuItemsConverter.CreateToolStripDropDownItems(Runtime.ConnectionTreeModel).ToArray(); + ToolStripItem[] rootMenuItems = menuItemsConverter.CreateToolStripDropDownItems(Runtime.ConnectionsService.ConnectionTreeModel).ToArray(); _btnConnections.DropDownItems.AddRange(rootMenuItems); } diff --git a/mRemoteV1/UI/Menu/MainFileMenu.cs b/mRemoteV1/UI/Menu/MainFileMenu.cs index 043d9388..f6d41f5c 100644 --- a/mRemoteV1/UI/Menu/MainFileMenu.cs +++ b/mRemoteV1/UI/Menu/MainFileMenu.cs @@ -432,7 +432,7 @@ namespace mRemoteNG.UI.Menu var selectedNode = TreeWindow.SelectedNode; ContainerInfo importDestination; if (selectedNode == null) - importDestination = Runtime.ConnectionTreeModel.RootNodes.First(); + importDestination = Runtime.ConnectionsService.ConnectionTreeModel.RootNodes.First(); else importDestination = selectedNode as ContainerInfo ?? selectedNode.Parent; Import.ImportFromFile(importDestination); @@ -450,7 +450,7 @@ namespace mRemoteNG.UI.Menu private void mMenFileExport_Click(object sender, EventArgs e) { - Export.ExportToFile(Windows.TreeForm.SelectedNode, Runtime.ConnectionTreeModel); + Export.ExportToFile(Windows.TreeForm.SelectedNode, Runtime.ConnectionsService.ConnectionTreeModel); } private void mMenFileExit_Click(object sender, EventArgs e) diff --git a/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.cs b/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.cs index cd3652ae..bf5b7f4d 100644 --- a/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.cs +++ b/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.cs @@ -47,7 +47,7 @@ namespace mRemoteNG.UI.Window if (selectedNode != null) importDestination = selectedNode as ContainerInfo ?? selectedNode.Parent; else - importDestination = Runtime.ConnectionTreeModel.RootNodes.First(); + importDestination = Runtime.ConnectionsService.ConnectionTreeModel.RootNodes.First(); Import.ImportFromActiveDirectory(ActiveDirectoryTree.ADPath, importDestination, chkSubOU.Checked); }