From 0807e7fec16c0b3fba189d752888d79b7b17ee1e Mon Sep 17 00:00:00 2001 From: Brandon Wulf Date: Mon, 24 Jul 2017 17:41:39 -0700 Subject: [PATCH] Send commands to quickconnect created connections too! --- mRemoteV1/Tools/MultiSSHController.cs | 40 ++++++++++++++++++++------- mRemoteV1/UI/Forms/frmMain.cs | 1 + 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/mRemoteV1/Tools/MultiSSHController.cs b/mRemoteV1/Tools/MultiSSHController.cs index 60384e6b..c71ad0ea 100644 --- a/mRemoteV1/Tools/MultiSSHController.cs +++ b/mRemoteV1/Tools/MultiSSHController.cs @@ -13,6 +13,7 @@ namespace mRemoteNG.Tools class MultiSSHController { private ArrayList processHandlers = new ArrayList(); + private ArrayList quickConnectConnections = new ArrayList(); private ArrayList previousCommands = new ArrayList(); private int previousCommandIndex = 0; @@ -28,6 +29,11 @@ namespace mRemoteNG.Tools DecorateTextBox(txtBox.TextBox); } + public void ProcessNewQuickConnect(ConnectionInfo connection) + { + quickConnectConnections.Add(connection); + } + private void DecorateTextBox(TextBox toBeDecorated) { toBeDecorated.Enter += refreshActiveConnections; @@ -35,6 +41,21 @@ namespace mRemoteNG.Tools toBeDecorated.KeyUp += processKeyRelease; } + private ArrayList ProcessOpenConnections(ConnectionInfo connection) + { + ArrayList handlers = new ArrayList(); + + foreach (ProtocolBase _base in connection.OpenConnections) + { + if (_base.GetType().IsSubclassOf(typeof(PuttyBase))) + { + handlers.Add((PuttyBase)_base); + } + } + + return handlers; + } + private void SendAllKeystrokes(int keyType, int keyData) { if (processHandlers.Count == 0) @@ -50,18 +71,17 @@ namespace mRemoteNG.Tools #region Event Processors private void refreshActiveConnections(object sender, EventArgs e) { - var previouslyOpenedConnections = Runtime.ConnectionTreeModel.GetRecursiveChildList().Where(item => item.OpenConnections.Count > 0); - processHandlers.Clear(); - foreach (ConnectionInfo connection in previouslyOpenedConnections) + foreach (ConnectionInfo connection in quickConnectConnections) { - foreach (ProtocolBase _base in connection.OpenConnections) - { - if (_base.GetType().IsSubclassOf(typeof(PuttyBase))) - { - processHandlers.Add((PuttyBase)_base); - } - } + processHandlers.AddRange(ProcessOpenConnections(connection)); + } + + var connectionTreeConnections = Runtime.ConnectionTreeModel.GetRecursiveChildList().Where(item => item.OpenConnections.Count > 0); + + foreach (ConnectionInfo connection in connectionTreeConnections) + { + processHandlers.AddRange(ProcessOpenConnections(connection)); } } diff --git a/mRemoteV1/UI/Forms/frmMain.cs b/mRemoteV1/UI/Forms/frmMain.cs index 25f34aa8..f7501003 100644 --- a/mRemoteV1/UI/Forms/frmMain.cs +++ b/mRemoteV1/UI/Forms/frmMain.cs @@ -951,6 +951,7 @@ namespace mRemoteNG.UI.Forms } cmbQuickConnect.Add(connectionInfo); _connectionInitiator.OpenConnection(connectionInfo, ConnectionInfo.Force.DoNotJump); + _multiSSHController.ProcessNewQuickConnect(connectionInfo); } catch (Exception ex) {