From 8f685faf9ba8749cfede3a8fd484dcce9fade2c8 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Mon, 22 Aug 2016 16:05:49 -0600 Subject: [PATCH] Refactored to reduce coupling --- mRemoteV1/Config/Putty/Config.Putty.Sessions.cs | 8 ++++---- mRemoteV1/UI/Forms/OptionsPages/AdvancedPage.cs | 2 +- mRemoteV1/UI/Window/ConnectionTreeWindow.cs | 8 +++++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mRemoteV1/Config/Putty/Config.Putty.Sessions.cs b/mRemoteV1/Config/Putty/Config.Putty.Sessions.cs index eba31b4e0..f60032df8 100644 --- a/mRemoteV1/Config/Putty/Config.Putty.Sessions.cs +++ b/mRemoteV1/Config/Putty/Config.Putty.Sessions.cs @@ -4,6 +4,7 @@ using mRemoteNG.Tree; using System.Collections.Generic; using System.ComponentModel; using System.Windows.Forms; +using mRemoteNG.App; namespace mRemoteNG.Config.Putty @@ -11,10 +12,9 @@ namespace mRemoteNG.Config.Putty public class Sessions { #region Public Methods - private delegate void AddSessionsToTreeDelegate(); - public static void AddSessionsToTree() + private delegate void AddSessionsToTreeDelegate(TreeView treeView); + public static void AddSessionsToTree(TreeView treeView) { - TreeView treeView = ConnectionTree.TreeView; if (treeView == null) { return ; @@ -139,7 +139,7 @@ namespace mRemoteNG.Config.Putty public static void SessionChanged(object sender, Provider.SessionChangedEventArgs e) { - AddSessionsToTree(); + AddSessionsToTree(Windows.treeForm.tvConnections); } #endregion diff --git a/mRemoteV1/UI/Forms/OptionsPages/AdvancedPage.cs b/mRemoteV1/UI/Forms/OptionsPages/AdvancedPage.cs index 00d1ed0de..6751a8f2c 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/AdvancedPage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/AdvancedPage.cs @@ -80,7 +80,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages if (puttyPathChanged) { PuttyBase.PuttyPath = Settings.Default.UseCustomPuttyPath ? Settings.Default.CustomPuttyPath : GeneralAppInfo.PuttyPath; - Sessions.AddSessionsToTree(); + Sessions.AddSessionsToTree(Windows.treeForm.tvConnections); } Settings.Default.MaxPuttyWaitTime = (int) numPuttyWaitTime.Value; diff --git a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs index f7f4101cc..91590f95a 100644 --- a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs +++ b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs @@ -909,7 +909,13 @@ namespace mRemoteNG.UI.Window public void txtSearch_TextChanged(object sender, EventArgs e) { - tvConnections.SelectedNode = ConnectionTree.Find(tvConnections.Nodes[0], txtSearch.Text); + try + { + tvConnections.SelectedNode = ConnectionTree.Find(tvConnections.Nodes[0], txtSearch.Text); + } + catch (Exception) + { + } } public void tvConnections_KeyPress(object sender, KeyPressEventArgs e)