/// <summary> /// Add sorted floating containers to the list /// </summary> /// <param name="containers">containers</param> private void AddSortedFloatingContainers(List <DockableContainer> containers) { List <DockableContainer> containersToBringInFront = new List <DockableContainer>(); foreach (DockableFormInfo info in _dockableForms) { FormsTabbedView view = HierarchyUtility.GetTabbedView(info.DockableForm); if (view.IsDocked) { continue; } DockableContainer container = HierarchyUtility.GetClosestDockableContainer(info.DockableForm); if (_host.Contains(container) == false) { continue; } if (containersToBringInFront.Contains(container) == false) { containersToBringInFront.Add(container); } } SortContainersBasedOnTheirZOrder(containersToBringInFront); containers.AddRange(containersToBringInFront); }
/// <summary> /// Remove the form /// </summary> /// <param name="info">info about form to remove</param> public void Remove(DockableFormInfo info) { if (info == null) { return; } FormsTabbedView view = HierarchyUtility.GetTabbedView(info.DockableForm); if (view != null) { if (view.Count == 1 && view.IsDocked) { _layout.Undock(view); } if (view.Count == 1) { _host.Remove(view.Parent); DockableContainer container = HierarchyUtility.GetClosestDockableContainer(info.DockableForm); container.SetModeEmpty(); view.Remove(info); } else { if (view.Remove(info) == false) { if (SelectedFormInfo == info) { SelectedFormInfo = null; } return; } } } if (SelectedFormInfo == info) { SelectedFormInfo = null; } _dockableForms.Remove(info); info.SelectedChanged -= OnFormSelectedChanged; info.ShowAutoPanel -= OnShowFormAutoPanel; info.ExplicitDisposing -= OnInfoDisposing; if (info.IsAutoHideMode) { _autohide.ArrangeAutoButtonsPanels(); } info.Dispose(); }
/// <summary> /// Start showing form /// </summary> /// <param name="form">form to show</param> /// <param name="width">width of the form</param> /// <param name="height">height of the form</param> private void StartShowForm(Form form, int width, int height) { _previewPane.Visible = false; FormsTabbedView view = HierarchyUtility.GetTabbedView(form); view.Size = new Size(width, height); view.SelectPage(form); StartAutoShowPane(view.Parent as AutoHidePanel); }
/// <summary> /// Set auto-hide mode /// </summary> /// <param name="info">info of the form to set</param> /// <param name="autoHide">flag indicating if should set auto-hide (true) or unset it</param> public void SetAutoHide(DockableFormInfo info, bool autoHide) { if (autoHide && info.IsAutoHideMode == false) { _autohide.SetAutoHideMode(HierarchyUtility.GetTabbedView(info.DockableForm)); } else if (autoHide == false && info.IsAutoHideMode) { _autohide.UnsetAutoHideMode(HierarchyUtility.GetTabbedView(info.DockableForm)); } }
/// <summary> /// Checks if this panel contains give panel /// </summary> /// <param name="panel">panel to check</param> /// <returns>true if this panel contains given pane</returns> public bool ContainsPanel(AutoHidePanel panel) { for (int index = ButtonsCount - 1; index >= 0; index--) { TabButton button = GetButtonAt(index); FormsTabbedView view = HierarchyUtility.GetTabbedView((Form)button.Page); if (view.Parent == panel) { return(true); } } return(false); }
/// <summary> /// Show auto form /// </summary> /// <param name="form">form to be shown</param> public void ShowAutoForm(Form form) { FormsTabbedView view = HierarchyUtility.GetTabbedView(form); AutoHidePanel panel = view.Parent as AutoHidePanel; if (panel == null) { return; } if (_leftAutoHideButtons != null) { if (_leftAutoHideButtons.ContainsPanel(panel)) { OnLeftPaneSelectButton(this, new ControlEventArgs(form)); return; } } if (_rightAutoHideButtons != null) { if (_rightAutoHideButtons.ContainsPanel(panel)) { OnRightPaneSelectButton(this, new ControlEventArgs(form)); return; } } if (_topAutoHideButtons != null) { if (_topAutoHideButtons.ContainsPanel(panel)) { OnTopPaneSelectButton(this, new ControlEventArgs(form)); return; } } if (_bottomAutoHideButtons != null) { if (_bottomAutoHideButtons.ContainsPanel(panel)) { OnBottomPaneSelectButton(this, new ControlEventArgs(form)); return; } } }
/// <summary> /// Undock view /// </summary> /// <param name="view">view to undock</param> /// <param name="hintBounds">hint bounds</param> private void Undock(Form formToUndock, Rectangle hintBounds) { FormsTabbedView view = HierarchyUtility.GetTabbedView(formToUndock); if (view.Count == 1) { _layout.Undock(view, hintBounds); } else { DockableFormInfo info = GetFormInfo(formToUndock); FormsTabbedView newView = CreateFormsTabbedView(info.DockableForm.Size, null); newView.Add(info); _layout.CreateFloatingContainer(newView, hintBounds); } }
/// <summary> /// Occurs when IsSelected property of a form is changed /// </summary> /// <param name="sender">sender of the event</param> /// <param name="e">event argument</param> private void OnFormSelectedChanged(object sender, EventArgs e) { DockableFormInfo info = (DockableFormInfo)sender; if (info.IsSelected) { SelectedFormInfo = info; } FormsTabbedView view = HierarchyUtility.GetTabbedView(info.DockableForm); if (view != null) { if (view.SelectedForm != null) { DockableFormInfo topFormInfo = GetFormInfo(view.SelectedForm); view.PagesPanel.ShowCloseButton = topFormInfo.ShowCloseButton; view.PagesPanel.ShowContextMenuButton = topFormInfo.ShowContextMenuButton; } } }
/// <summary> /// Removes the panel if is contained here /// </summary> /// <param name="panel">panel to remove</param> /// <returns>true if is removed the panel</returns> public bool Remove(AutoHidePanel panel) { bool removed = false; for (int index = ButtonsCount - 1; index >= 0; index--) { TabButton button = GetButtonAt(index); FormsTabbedView view = HierarchyUtility.GetTabbedView((Form)button.Page); if (view.Parent == panel) { RemoveButton(button); removed = true; } } panel.View.FormAdded -= OnFormAddedToPanel; panel.View.FormRemoved -= OnFormRemovedFromPanel; panel.View.FormSelected -= OnFormSelectedIntoView; return(removed); }
/// <summary> /// Add sorted fill containers to the list /// </summary> /// <param name="containers">containers</param> private void AddSortedFillContainers(List <DockableContainer> containers) { List <DockableContainer> containersToBringInFront = new List <DockableContainer>(); foreach (DockableFormInfo info in _dockableForms) { FormsTabbedView view = HierarchyUtility.GetTabbedView(info.DockableForm); if (view.HostContainerDock != DockStyle.Fill) { continue; } DockableContainer container = HierarchyUtility.GetClosestDockableContainer(info.DockableForm); while (true) { if (container.Parent as DockableContainer != null) { container = (DockableContainer)container.Parent; } else { break; } } Debug.Assert(_host.Contains(container), "Floating form views must have their parent in form"); if (containersToBringInFront.Contains(container) == false) { containersToBringInFront.Add(container); } } SortContainersBasedOnTheirZOrder(containersToBringInFront); containers.AddRange(containersToBringInFront); }