Exemple #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="host">host window</param>
        public FormsDocker(IWin32Window host)
        {
            _host     = new FormWrapper(host, 14, 4);
            _guider   = new DockGuider(_host);
            _layout   = new DockLayout(_host);
            _autohide = new Autohide(_host, 9, _animationCommand);

            _layout.BeginMoveByMouse       += OnPositionerBeginMoveByMouse;
            _layout.MoveByMouse            += OnPositionerMoveByMouse;
            _layout.EndMoveByMouse         += OnPositionerEndMoveByMouse;
            _layout.DestroyFormsTabbedView += OnDestroyFormsTabbedView;
            _layout.ShowFloatingWindows    += OnShowFloatingWindows;

            _autohide.SetHostContainerDock += OnSetHostContainerDock;

            _guider.ApplyDock    += OnApplyDock;
            _animationTimer.Tick += OnTimedAnimation;

            _animationTimer.Interval = 50;
            _animationTimer.Enabled  = true;

            _focusDetector.ControlGotFocus += OnControlGotFocus;
            _focusDetector.MessageFiltered += OnMessageFiltered;
            Application.AddMessageFilter(_focusDetector);
        }
Exemple #2
0
        /// <summary>
        /// Remove the container
        /// </summary>
        /// <param name="container">container to remove</param>
        private void RemoveContainer(DockingContainer container)
        {
            Debug.Assert(container.Parent != null, "Docked container must be hosted somewere");

            container.SetModeEmpty();

            DockingContainer containerParent = container.Parent as DockingContainer;

            if (containerParent == null)
            {
                Debug.Assert(container.Parent.Handle == _host.Handle, "Parents of FormsTabbedView should be only DockingContainer or _host");
            }
            else
            {
                DockingContainer 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)
                    {
                        DockingContainer leftPane  = otherContainer.LeftPane;
                        DockingContainer rightPane = otherContainer.RightPane;

                        otherContainer.SetModeEmpty();

                        containerParent.SetModeHSplit(leftPane, rightPane);
                    }
                    else if (otherContainer.TopPane != null)
                    {
                        DockingContainer topPane    = otherContainer.TopPane;
                        DockingContainer 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, DockableMode.None);
                    }
                }

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

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