From 85aeb059fc9f4ffb5cd84d5cdd11afda7af47226 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Sat, 5 Jan 2019 20:47:33 -0500 Subject: [PATCH] find the correct InterfaceControl on conn change --- mRemoteV1/Connection/InterfaceControl.cs | 10 +++++++++- mRemoteV1/UI/Forms/frmMain.cs | 8 +++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mRemoteV1/Connection/InterfaceControl.cs b/mRemoteV1/Connection/InterfaceControl.cs index 0c4846e1d..87596e81c 100644 --- a/mRemoteV1/Connection/InterfaceControl.cs +++ b/mRemoteV1/Connection/InterfaceControl.cs @@ -41,5 +41,13 @@ namespace mRemoteNG.Connection return null; } - } + + public static InterfaceControl FindInterfaceControl(ConnectionTab tab) + { + if (tab.Controls[0] is InterfaceControl ic) + return ic; + + return null; + } + } } \ No newline at end of file diff --git a/mRemoteV1/UI/Forms/frmMain.cs b/mRemoteV1/UI/Forms/frmMain.cs index f63734192..343c9c956 100644 --- a/mRemoteV1/UI/Forms/frmMain.cs +++ b/mRemoteV1/UI/Forms/frmMain.cs @@ -522,9 +522,11 @@ namespace mRemoteNG.UI.Forms private void ActivateConnection() { - var w = pnlDock.Controls[0] as DockPanel; - if (!(w?.ActiveDocument is ConnectionTab tab)) return; - var ifc = (InterfaceControl)tab.ActiveControl; + var cw = pnlDock.ActiveDocument as ConnectionWindow; + var dp = cw?.ActiveControl as DockPane; + + if (!(dp?.ActiveContent is ConnectionTab tab)) return; + var ifc = InterfaceControl.FindInterfaceControl(tab); if (ifc == null) return; ifc.Protocol.Focus();