Exemple #1
0
        /// <summary>
        /// Dock the form in host
        /// </summary>
        /// <param name="containerToDock">container to dock</param>
        /// <param name="dock">dock</param>
        /// <param name="mode">mode</param>
        private void DockInHost(DockingContainer container, DockStyle dock, DockableMode mode)
        {
            Rectangle availableBounds = FormWrapper.GetFillScreenRectangle(_host);

            container.SingleChild.SaveFloatingSize();
            container.Splitter.Visible = false;

            if (_host.Contains(container.Splitter) == false && dock != DockStyle.Fill)
            {
                _host.AddLast(container.Splitter);
            }

            if (mode == DockableMode.Inner)
            {
                if (dock != DockStyle.Fill)
                {
                    _host.MoveFirst(container);
                    _host.MoveFirst(container.Splitter);
                }
            }
            else
            {
                if (dock != DockStyle.Fill)
                {
                    _host.MoveLast(container.Splitter);
                    _host.MoveLast(container);
                }
            }

            container.Dock = dock;

            if (dock != DockStyle.Fill)
            {
                container.Splitter.Dock    = dock;
                container.Splitter.Visible = true;
            }
            else
            {
                container.SingleChild.ButtonsRenderer = new TopUnitButtonDrawer();
            }

            // Must call this again after splitter is docked and made visible, to have proper splitter.
            // Must have this if/else block also before making the splitter visible to prevent flickering
            if (mode == DockableMode.Inner)
            {
                if (dock != DockStyle.Fill)
                {
                    _host.MoveFirst(container);
                    _host.MoveFirst(container.Splitter);

                    if (availableBounds.IsEmpty == false)
                    {
                        if (dock == DockStyle.Left || dock == DockStyle.Right)
                        {
                            if (container.Width >= availableBounds.Width - MinAvailableSize)
                            {
                                container.Width = availableBounds.Width - MinAvailableSize;
                            }
                        }
                        else if (dock == DockStyle.Top || dock == DockStyle.Bottom)
                        {
                            if (container.Height >= availableBounds.Height - MinAvailableSize)
                            {
                                container.Height = availableBounds.Height - MinAvailableSize;
                            }
                        }
                    }
                }
            }
            else
            {
                if (dock != DockStyle.Fill)
                {
                    _host.MoveLast(container.Splitter);
                    _host.MoveLast(container);
                }
            }

            SetViewDock(container.SingleChild, dock, dock, mode);
        }