public RadegastTab 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); RadegastTab tab = new RadegastTab(instance, button, control, name.ToLower(), label); if (control is RadegastTabControl) { ((RadegastTabControl)control).RadegastTab = 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) { tab.Control.TextChanged -= new EventHandler(Control_TextChanged); if (tab.Detached) { if (tab.CloseOnDetachedClose) { tab.Close(); } else { tab.AttachTo(ReattachStrip, ReattachContainer); } } }
private void tbtnCloseTab_Click(object sender, EventArgs e) { RadegastTab 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; } RadegastTab tab = tabs[name]; if (tab.Merged) { SplitTab(tab); } tab.AllowClose = true; tab.Close(); tab = null; }
public RadegastTab 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); RadegastTab tab = new RadegastTab(instance, button, control, name.ToLower(), label); if (control is RadegastTabControl) ((RadegastTabControl)control).RadegastTab = 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; }