private void CloseTabPage(object tabObject, bool checkNullException = true) { // If the handle has been disposed -> the control is non existent // -> we don't need to close it again -> Exception will be thrown -> return. try { // The TabControlItem is of base type Panel. // If the control is no panel return. if (!(tabObject is Panel)) { return; } // The following check is not needed in case of the AutoIt connection. if (checkNullException) { // Check for a valid and existing handle -> if Zero or exception return. // otherwise continue. if (((Panel)tabObject).Handle == IntPtr.Zero) { return; } } } catch { return; } if (!(tabObject is TabControlItem)) { return; } if (this.ParentForm.InvokeRequired) { InvokeCloseTabPage d = this.CloseTabPage; this.TerminalTabPage.Invoke(d, new object[] { this.TerminalTabPage, checkNullException }); return; } TabControlItem tabPage = (TabControlItem)tabObject; bool wasSelected = tabPage.Selected; this.ParentForm.RemoveTabPage(tabPage); if (wasSelected) { PostMessage(new HandleRef(this, this.Handle), WM_LEAVING_FULLSCREEN, IntPtr.Zero, IntPtr.Zero); } this.ParentForm.UpdateControls(); }
/// <summary> /// Because tabControl is cast internaly to TabControlItem, all connections should send their tab, /// which we already have in the connection. /// </summary> private void InvokeCloseTab(TerminalTabControlItem tabPage) { if (this.mainForm.InvokeRequired) { var d = new InvokeCloseTabPage(this.CloseTabPage); this.mainForm.Invoke(d, new object[] { tabPage }); } else { this.CloseTabPage(tabPage); } }
/// <summary> /// Because tabControl is cast internaly to TabControlItem, all connections should send their tab, /// which we already have in the connection. /// </summary> private void InvokeCloseTab(TerminalTabControlItem tabControl) { if (this.mainForm.InvokeRequired) { var d = new InvokeCloseTabPage(this.CloseTabPage); this.mainForm.Invoke(d, new object[] { tabControl }); } else { this.CloseTabPage(tabControl); } }