Ejemplo n.º 1
1
      /// <summary>
      /// Remove the container
      /// </summary>
      /// <param name="container">container to remove</param>
      private void RemoveContainer(DockableContainer container)
      {
         Debug.Assert(container.Parent != null, "Docked container must be hosted somewere");

         container.SetModeEmpty();

         DockableContainer containerParent = container.Parent as DockableContainer;
         if (containerParent == null)
         {
            Debug.Assert(container.Parent.Handle == _host.Handle, "Parents of FormsTabbedView should be only DockableContainer or _host");
         }
         else
         {
            DockableContainer otherContainer = containerParent.OtherPane(container);
            Debug.Assert(otherContainer != null, "Container in container means that parent container has contained two containers and a splitter");
            
            FormsTabbedView otherView  = otherContainer.SingleChild;
            FormsTabbedView linkedView = otherContainer.LinkedView;

            if (otherView == null && linkedView == null)
            {
               if (otherContainer.LeftPane != null)
               {
                  DockableContainer leftPane    = otherContainer.LeftPane;
                  DockableContainer rightPane   = otherContainer.RightPane;

                  otherContainer.SetModeEmpty();

                  containerParent.SetModeHSplit(leftPane, rightPane);
               }
               else if (otherContainer.TopPane != null)
               {
                  DockableContainer topPane     = otherContainer.TopPane;
                  DockableContainer bottomPane  = otherContainer.BottomPane;

                  otherContainer.SetModeEmpty();

                  containerParent.SetModeVSplit(topPane, bottomPane);
               }
            }
            else
            {
               Debug.Assert((otherView == null || linkedView == null), "Other container must have a view");

               otherContainer.SetModeEmpty();

               if (otherView != null)
               {
                  containerParent.SetModeSingleChild(otherView);
               }
               else
               {
                  containerParent.SetModeLinked(linkedView);
                  AutoHidePanel linkedPanel = (AutoHidePanel)linkedView.Parent;
                  linkedPanel.RestoreParent = containerParent;
                  Autohide.HideRestoreContainers(linkedPanel);
               }

               // If floating container inside host
               if (containerParent.Parent.Handle == _host.Handle && containerParent.Dock == DockStyle.None)
               {
                  Debug.Assert(linkedView == null, "Can't have linked view in floating container");
                  SetViewDock(otherView, DockStyle.None, DockStyle.None, zDockMode.None);
               }
            }

            otherContainer.Parent = null;
            otherContainer.Splitter.Parent = null;
            otherContainer.Dispose();
         }

         container.Parent = null;
         container.Splitter.Parent = null;
         container.Dispose();
      }
Ejemplo n.º 2
0
        /// <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();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Undock the view
        /// </summary>
        /// <param name="view">view</param>
        /// <param name="floatingBounds">floating bounds</param>
        public void Undock(FormsTabbedView view, Rectangle floatingBounds)
        {
            DockableContainer container = (DockableContainer)view.Parent;

            container.SetModeEmpty();

            RemoveContainer(container);

            CreateFloatingContainer(view, floatingBounds);
        }
Ejemplo n.º 4
0
      /// <summary>
      /// Dock in parent container
      /// </summary>
      /// <param name="containerToDock">container to dock</param>
      /// <param name="containerWhereToDock">container where to dock</param>
      /// <param name="dock">dock</param>
      private void DockInParentContainer(DockableContainer containerToDock, DockableContainer containerWhereToDock, DockStyle dock)
      {
         FormsTabbedView formTabbedView   = containerToDock.SingleChild;
         FormsTabbedView parentTabbedView = containerWhereToDock.SingleChild;

         containerToDock.SingleChild.SaveFloatingSize();
         containerToDock.Splitter.Visible = false;
         containerToDock.SetModeEmpty();

         if (dock != DockStyle.Fill)
         {
            containerWhereToDock.SetModeEmpty();
         }

         RemoveContainer(containerToDock);

         DockStyle parentDock     = DockStyle.None;
         switch (dock)
         {
            case DockStyle.Left:
               SplitHorizontally(formTabbedView, parentTabbedView, containerWhereToDock);
               parentDock = DockStyle.Right;
               break;

            case DockStyle.Right:
               SplitHorizontally(parentTabbedView, formTabbedView, containerWhereToDock);
               parentDock = DockStyle.Left;
               break;

            case DockStyle.Top:
               SplitVertically(formTabbedView, parentTabbedView, containerWhereToDock);
               parentDock = DockStyle.Bottom;
               break;

            case DockStyle.Bottom:
               SplitVertically(parentTabbedView, formTabbedView, containerWhereToDock);
               parentDock = DockStyle.Top;
               break;

            case DockStyle.Fill:
               parentDock = parentTabbedView.HostContainerDock;
               DockFillInParentContainer(formTabbedView, parentTabbedView);
               OnDestroyFormsTabbedView(formTabbedView);
               break;

            default:
               throw new InvalidOperationException();
         }

         if (parentTabbedView.HostContainerDock != DockStyle.None)
         {  // Keep the parent logical dock if already docked
            if (parentDock != parentTabbedView.CurrentDock)
            {
               SetViewDock(parentTabbedView, parentTabbedView.HostContainerDock, parentDock, parentTabbedView.CurrentDockMode);
            }
            parentDock = parentTabbedView.HostContainerDock;
         }

         UpdateViewButtons(parentTabbedView);

         if (dock != DockStyle.Fill)
         {
            SetViewDock(formTabbedView, parentDock, dock, parentTabbedView.CurrentDockMode);
         }
      }
Ejemplo n.º 5
0
        /// <summary>
        /// Dock in parent container
        /// </summary>
        /// <param name="containerToDock">container to dock</param>
        /// <param name="containerWhereToDock">container where to dock</param>
        /// <param name="dock">dock</param>
        private void DockInParentContainer(DockableContainer containerToDock, DockableContainer containerWhereToDock, DockStyle dock)
        {
            FormsTabbedView formTabbedView   = containerToDock.SingleChild;
            FormsTabbedView parentTabbedView = containerWhereToDock.SingleChild;

            containerToDock.SingleChild.SaveFloatingSize();
            containerToDock.Splitter.Visible = false;
            containerToDock.SetModeEmpty();

            if (dock != DockStyle.Fill)
            {
                containerWhereToDock.SetModeEmpty();
            }

            RemoveContainer(containerToDock);

            DockStyle parentDock = DockStyle.None;

            switch (dock)
            {
            case DockStyle.Left:
                SplitHorizontally(formTabbedView, parentTabbedView, containerWhereToDock);
                parentDock = DockStyle.Right;
                break;

            case DockStyle.Right:
                SplitHorizontally(parentTabbedView, formTabbedView, containerWhereToDock);
                parentDock = DockStyle.Left;
                break;

            case DockStyle.Top:
                SplitVertically(formTabbedView, parentTabbedView, containerWhereToDock);
                parentDock = DockStyle.Bottom;
                break;

            case DockStyle.Bottom:
                SplitVertically(parentTabbedView, formTabbedView, containerWhereToDock);
                parentDock = DockStyle.Top;
                break;

            case DockStyle.Fill:
                parentDock = parentTabbedView.HostContainerDock;
                DockFillInParentContainer(formTabbedView, parentTabbedView);
                OnDestroyFormsTabbedView(formTabbedView);
                break;

            default:
                throw new InvalidOperationException();
            }

            if (parentTabbedView.HostContainerDock != DockStyle.None)
            { // Keep the parent logical dock if already docked
                if (parentDock != parentTabbedView.CurrentDock)
                {
                    SetViewDock(parentTabbedView, parentTabbedView.HostContainerDock, parentDock, parentTabbedView.CurrentDockMode);
                }
                parentDock = parentTabbedView.HostContainerDock;
            }

            UpdateViewButtons(parentTabbedView);

            if (dock != DockStyle.Fill)
            {
                SetViewDock(formTabbedView, parentDock, dock, parentTabbedView.CurrentDockMode);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Remove the container
        /// </summary>
        /// <param name="container">container to remove</param>
        private void RemoveContainer(DockableContainer container)
        {
            Debug.Assert(container.Parent != null, "Docked container must be hosted somewere");

            container.SetModeEmpty();

            DockableContainer containerParent = container.Parent as DockableContainer;

            if (containerParent == null)
            {
                Debug.Assert(container.Parent.Handle == _host.Handle, "Parents of FormsTabbedView should be only DockableContainer or _host");
            }
            else
            {
                DockableContainer otherContainer = containerParent.OtherPane(container);
                Debug.Assert(otherContainer != null, "Container in container means that parent container has contained two containers and a splitter");

                FormsTabbedView otherView  = otherContainer.SingleChild;
                FormsTabbedView linkedView = otherContainer.LinkedView;

                if (otherView == null && linkedView == null)
                {
                    if (otherContainer.LeftPane != null)
                    {
                        DockableContainer leftPane  = otherContainer.LeftPane;
                        DockableContainer rightPane = otherContainer.RightPane;

                        otherContainer.SetModeEmpty();

                        containerParent.SetModeHSplit(leftPane, rightPane);
                    }
                    else if (otherContainer.TopPane != null)
                    {
                        DockableContainer topPane    = otherContainer.TopPane;
                        DockableContainer bottomPane = otherContainer.BottomPane;

                        otherContainer.SetModeEmpty();

                        containerParent.SetModeVSplit(topPane, bottomPane);
                    }
                }
                else
                {
                    Debug.Assert((otherView == null || linkedView == null), "Other container must have a view");

                    otherContainer.SetModeEmpty();

                    if (otherView != null)
                    {
                        containerParent.SetModeSingleChild(otherView);
                    }
                    else
                    {
                        containerParent.SetModeLinked(linkedView);
                        AutoHidePanel linkedPanel = (AutoHidePanel)linkedView.Parent;
                        linkedPanel.RestoreParent = containerParent;
                        Autohide.HideRestoreContainers(linkedPanel);
                    }

                    // If floating container inside host
                    if (containerParent.Parent.Handle == _host.Handle && containerParent.Dock == DockStyle.None)
                    {
                        Debug.Assert(linkedView == null, "Can't have linked view in floating container");
                        SetViewDock(otherView, DockStyle.None, DockStyle.None, zDockMode.None);
                    }
                }

                otherContainer.Parent          = null;
                otherContainer.Splitter.Parent = null;
                otherContainer.Dispose();
            }

            container.Parent          = null;
            container.Splitter.Parent = null;
            container.Dispose();
        }