/// <summary> /// Add a docked window into the dock control /// </summary> /// <param name="dockControl">The window to be docked</param> /// <param name="icon">The icon of the window</param> /// <param name="caption">The caption of the window</param> /// <param name="defaultWidth">The default width of the label</param> public void AddDockWindow(Control dockControl, Image icon, string caption, int defaultWidth) { DockItem item; item = new DockItem(dockControl, icon, caption); tabDock.AddTab(caption, icon, defaultWidth, item); ShowDockWindow(item); m_iFireDock = 0; tmFireDock.Enabled = true; }
/// <summary> /// Remove a docked window /// </summary> /// <param name="item">The dock item to be removed</param> public void RemoveDockWindow(DockItem item) { for (int i = 0; i < tabDock.TabCount; i++) { if (tabDock.TabItems(i).Tag.Equals(item)) { tabDock.RemoveTab(i); item.m_control.Parent = null; } } }
/// <summary> /// Display a docked window /// </summary> /// <param name="item"></param> private void ShowDockWindow(DockItem item) { for (int i = 0; i < tabDock.TabCount; i++) { if (!tabDock.TabItems(i).Tag.Equals(item)) { ((DockItem)tabDock.TabItems(i).Tag).m_control.Parent = null; } } this.pbIcon.Image = item.m_icon; this.lbTitle.Text = item.m_caption; item.m_control.Parent = this; item.m_control.Dock = DockStyle.Fill; item.m_control.Visible = true; item.m_control.Enabled = true; item.m_control.BringToFront(); }
/// <summary> /// Fire the DockItemFloating event /// </summary> /// <param name="item"></param> public void FireFloating(DockItem item) { bool bCanceled = false; if (DockItemFloating != null) { DockItemFloating(item.m_control, item.m_icon, item.m_caption, ref bCanceled); } if (!bCanceled) { RemoveDockWindow(item); } }