private static void Code(TerminalTabControlItem terminalTabPage, IHostingForm parentForm, FavoriteConfigurationElement favorite, ConnectionBase conn = null) { if (conn == null) { conn = CreateConnection(favorite); conn.TerminalTabPage = terminalTabPage; terminalTabPage.TabColor = FavoriteConfigurationElement.TranslateColor(favorite.TabColor); terminalTabPage.Connection = conn; } conn.Favorite = favorite; conn.ParentForm = parentForm; if (conn.Connect()) { if (conn.InvokeRequired) conn.Invoke(new MethodInvoker(delegate { conn.BringToFront(); conn.Update(); })); else { conn.BringToFront(); conn.Update(); } if (parentForm.InvokeRequired) parentForm.Invoke(new MethodInvoker(delegate { parentForm.UpdateControls(); if (favorite.DesktopSize == DesktopSize.FullScreen) parentForm.FullScreen = true; })); else { parentForm.UpdateControls(); if (favorite.DesktopSize == DesktopSize.FullScreen) parentForm.FullScreen = true; } conn.AfterConnectPlugins(); } else { string message = "Sorry, " + AssemblyInfo.Title + " was unable to create the connection. Try again or check the log for more information."; Log.Error(message); MessageBox.Show(message, AssemblyInfo.Title, MessageBoxButtons.OK, MessageBoxIcon.Error); if (parentForm.InvokeRequired) parentForm.Invoke(new MethodInvoker(delegate { parentForm.RemoveAndUnSelect(terminalTabPage); })); else parentForm.RemoveAndUnSelect(terminalTabPage); } if (conn.Connected && favorite.NewWindow) { if (parentForm.InvokeRequired) parentForm.Invoke(new MethodInvoker(delegate { parentForm.DetachTabToNewWindow(terminalTabPage); })); else parentForm.DetachTabToNewWindow(terminalTabPage); } }
private static void Code(TerminalTabControlItem terminalTabPage, IHostingForm parentForm, FavoriteConfigurationElement favorite, ConnectionBase conn = null) { if (conn == null) { conn = CreateConnection(favorite); conn.TerminalTabPage = terminalTabPage; terminalTabPage.TabColor = FavoriteConfigurationElement.TranslateColor(favorite.TabColor); terminalTabPage.Connection = conn; } conn.Favorite = favorite; conn.ParentForm = parentForm; if (conn.Connect()) { if (conn.InvokeRequired) { conn.Invoke(new MethodInvoker(delegate { conn.BringToFront(); conn.Update(); })); } else { conn.BringToFront(); conn.Update(); } if (parentForm.InvokeRequired) { parentForm.Invoke(new MethodInvoker(delegate { parentForm.UpdateControls(); if (favorite.DesktopSize == DesktopSize.FullScreen) { parentForm.FullScreen = true; } })); } else { parentForm.UpdateControls(); if (favorite.DesktopSize == DesktopSize.FullScreen) { parentForm.FullScreen = true; } } conn.AfterConnectPlugins(); } else { string message = "Sorry, " + AssemblyInfo.Title + " was unable to create the connection. Try again or check the log for more information."; Log.Error(message); MessageBox.Show(message, AssemblyInfo.Title, MessageBoxButtons.OK, MessageBoxIcon.Error); if (parentForm.InvokeRequired) { parentForm.Invoke(new MethodInvoker(delegate { parentForm.RemoveAndUnSelect(terminalTabPage); })); } else { parentForm.RemoveAndUnSelect(terminalTabPage); } } if (conn.Connected && favorite.NewWindow) { if (parentForm.InvokeRequired) { parentForm.Invoke(new MethodInvoker(delegate { parentForm.DetachTabToNewWindow(terminalTabPage); })); } else { parentForm.DetachTabToNewWindow(terminalTabPage); } } }