protected override bool ProcessKeyPreview(ref System.Windows.Forms.Message m) { const int WM_CHAR = 0x102; const int WM_SYSCHAR = 0x106; const int WM_SYSKEYDOWN = 0x104; //const int WM_SYSKEYUP = 0x105; const int WM_IME_CHAR = 0x286; KeyEventArgs e = null; if ((m.Msg != WM_CHAR) && (m.Msg != WM_SYSCHAR) && (m.Msg != WM_IME_CHAR)) { e = new KeyEventArgs(((Keys)((int)((long)m.WParam))) | ModifierKeys); if ((m.Msg == WM_KEYDOWN) || (m.Msg == WM_SYSKEYDOWN)) { TrappedKeyDown(e); } if (e.SuppressKeyPress) { tab.tabs["chat"].Select(); METAboltTab stab = tab.GetTab(toName); stab.Close(); } if (e.Handled) { return(e.Handled); } } return(base.ProcessKeyPreview(ref m)); }
public METAboltTab AddTab(string name, string label, Control control) { // WORKAROUND: one should never add tab that alrady exists // but under some weird conditions disconnect/connect // fire in the wrong order if (TabExists(name)) { Logger.Log("Force closing tab '" + name + "'", Helpers.LogLevel.Warning, client); ForceCloseTab(name); } control.Visible = false; control.Dock = DockStyle.Fill; toolStripContainer1.ContentPanel.Controls.Add(control); ToolStripButton button = (ToolStripButton)tstTabs.Items.Add(label); button.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; button.Image = null; button.AutoToolTip = false; button.Tag = name.ToLower(); button.AllowDrop = true; button.Click += new EventHandler(TabButtonClick); METAboltTab tab = new METAboltTab(instance, button, control, name.ToLower(), label); if (control is METAboltTabControl) { ((METAboltTabControl)control).METAboltTab = tab; } tab.TabAttached += new EventHandler(tab_TabAttached); tab.TabDetached += new EventHandler(tab_TabDetached); tab.TabSelected += new EventHandler(tab_TabSelected); tab.TabClosed += new EventHandler(tab_TabClosed); tab.TabHidden += new EventHandler(tab_TabHidden); tabs.Add(name.ToLower(), tab); if (OnTabAdded != null) { try { OnTabAdded(this, new TabEventArgs(tab)); } catch (Exception) { } } button.MouseDown += (msender, margs) => { if (margs.Button == MouseButtons.Middle) { if (tab.AllowClose) { tab.Close(); } else if (tab.AllowHide) { tab.Hide(); } } }; return(tab); }
private void frmDetachedTab_FormClosing(object sender, FormClosingEventArgs e) { if (tab.Detached) { if (tab.AllowClose) { tab.Close(); } else { tab.AttachTo(strip, container); } } }
private void frmDetachedTab_FormClosing(object sender, FormClosingEventArgs e) { tab.Control.TextChanged -= new EventHandler(Control_TextChanged); if (tab.Detached) { if (tab.CloseOnDetachedClose) { tab.Close(); } else { tab.AttachTo(strip, container); } } }
private void tbtnCloseTab_Click(object sender, EventArgs e) { METAboltTab tab = selectedTab; if (tab.Merged) { return; } else if (tab.AllowClose) { tab.Close(); } else if (tab.AllowHide) { tab.Hide(); } }
private void ForceCloseTab(string name) { if (!TabExists(name)) { return; } METAboltTab tab = tabs[name]; if (tab.Merged) { SplitTab(tab); } tab.AllowClose = true; tab.Close(); tab = null; }