public void AttachTabFromWindow(TerminalTabControlItem tabControlToAttach) { this.mainTabControl.AddTab(tabControlToAttach); PopupTerminal popupTerminal = tabControlToAttach.FindForm() as PopupTerminal; if (popupTerminal != null) { this.UnRegisterPopUp(popupTerminal); } }
public void DetachTabToNewWindow(TerminalTabControlItem tabControlToOpen) { if (tabControlToOpen != null) { this.mainTabControl.Items.SuspendEvents(); PopupTerminal pop = new PopupTerminal(this); this.mainTabControl.RemoveTab(tabControlToOpen); pop.AddTerminal(tabControlToOpen); this.mainTabControl.Items.ResumeEvents(); this.detachedWindows.Add(pop); pop.Show(); } }
private void CreateCaptureManagerTab() { string captureTitle = "Capture Manager"; TerminalTabControlItem terminalTabPage = null; if (mainForm.InvokeRequired) { mainForm.Invoke(new MethodInvoker(delegate { terminalTabPage = new TerminalTabControlItem(captureTitle, captureTitle); })); } else { terminalTabPage = new TerminalTabControlItem(captureTitle, captureTitle); } try { terminalTabPage.AllowDrop = false; terminalTabPage.ToolTipText = captureTitle; terminalTabPage.Favorite = null; terminalTabPage.DoubleClick += this.mainForm.TerminalTabPage_DoubleClick; this.AddAndSelect(terminalTabPage); this.mainForm.UpdateControls(); ConnectionBase conn = new CaptureManagerConnection(); if (conn.InvokeRequired) { conn.Invoke(new MethodInvoker(delegate { conn.TerminalTabPage = terminalTabPage; conn.ParentForm = this.mainForm; })); } else { conn.TerminalTabPage = terminalTabPage; conn.ParentForm = this.mainForm; } conn.Connect(); conn.BringToFront(); conn.Update(); this.mainForm.UpdateControls(); } catch (Exception exc) { Log.Error("Error loading the Capture Manager Tab Page", exc); this.RemoveAndUnSelect(terminalTabPage); terminalTabPage.Dispose(); } }
public void RemoveAndUnSelect(TerminalTabControlItem toRemove) { this.mainTabControl.Items.Remove(toRemove); this.UnSelect(); }
public void AddAndSelect(TerminalTabControlItem toAdd) { //this.mainTabControl.Items.Add(toAdd); this.mainTabControl.AddTab(toAdd); this.Select(toAdd); }
/// <summary> /// Markes the selected terminal as selected. If it is in mainTabControl, /// then directly selects it, otherwise marks the selected window /// </summary> /// <param name="toSelect"> new terminal tabControl to assign as selected </param> public void Select(TerminalTabControlItem toSelect) { this.mainTabControl.SelectedItem = toSelect; }
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); } }
/// <summary> /// Creates a new connection by spawning a new thread. /// </summary> /// <param name="favorite"> </param> /// <param name="TerminalTabPage"> </param> /// <param name="parentForm"> </param> /// <remarks> /// This method calls the <see cref="ConnectionBase.Connect" /> method and requires it to be thread safe. /// </remarks> public static void CreateConnection(FavoriteConfigurationElement favorite, IHostingForm parentForm, bool waitforEnd, TerminalTabControlItem terminalTabPage, ConnectionBase conn = null) { // This might happen if the user is not allowed to // use all available connections e.g. // if the user has a freeware version. if (Limit.Contains(favorite.Protocol.ToUpper()) || terminalTabPage == null) { MessageBox.Show("You are not allowed to use that kind of connection! Please upgrade your license.", AssemblyInfo.Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!waitforEnd) { Thread t = new Thread((ThreadStart)delegate { Code(terminalTabPage, parentForm, favorite, conn); }); t.SetApartmentState(ApartmentState.STA); t.Start(); } else { Code(terminalTabPage, parentForm, favorite, conn); } }
private void CreateCaptureManagerTab() { string captureTitle = "Capture Manager"; TerminalTabControlItem terminalTabPage = null; if (mainForm.InvokeRequired) mainForm.Invoke(new MethodInvoker(delegate { terminalTabPage = new TerminalTabControlItem(captureTitle, captureTitle); })); else terminalTabPage = new TerminalTabControlItem(captureTitle, captureTitle); try { terminalTabPage.AllowDrop = false; terminalTabPage.ToolTipText = captureTitle; terminalTabPage.Favorite = null; terminalTabPage.DoubleClick += this.mainForm.TerminalTabPage_DoubleClick; this.AddAndSelect(terminalTabPage); this.mainForm.UpdateControls(); ConnectionBase conn = new CaptureManagerConnection(); if (conn.InvokeRequired) conn.Invoke(new MethodInvoker(delegate { conn.TerminalTabPage = terminalTabPage; conn.ParentForm = this.mainForm; })); else { conn.TerminalTabPage = terminalTabPage; conn.ParentForm = this.mainForm; } conn.Connect(); conn.BringToFront(); conn.Update(); this.mainForm.UpdateControls(); } catch (Exception exc) { Log.Error("Error loading the Capture Manager Tab Page", exc); this.RemoveAndUnSelect(terminalTabPage); terminalTabPage.Dispose(); } }
public void AttachTabFromWindow(TerminalTabControlItem tabControlToAttach) { this.mainTabControl.AddTab(tabControlToAttach); PopupTerminal popupTerminal = tabControlToAttach.FindForm() as PopupTerminal; if (popupTerminal != null) this.UnRegisterPopUp(popupTerminal); }