コード例 #1
0
        /// <summary>
        /// Adjusts the size of the dock container if needed after a bar has been docked to it.
        /// </summary>
        /// <param name="barToDock">Bar object that has been docked.</param>
        /// <param name="visibleChanged">Indicates that bar was already docked but its Visible property has changed</param>
        internal void AdjustContainerSize(Bar barToDock, bool visibleChanged)
        {
            if (m_Container.Owner != null && m_Container.Owner.IsLoadingLayout) return;

            // Adjust the size of the container since it dictates the size of the bars docked inside
            if (m_Container.Dock != DockStyle.Fill)
            {
                DocumentBaseContainer doc = this.GetDocumentFromBar(barToDock);
                if (doc == null) return;
                if (m_Container.Dock == DockStyle.Left || m_Container.Dock == DockStyle.Right)
                {
                    if (m_Container.Width == 0 || doc.Parent == m_DocumentDockContainer &&
                        (m_DocumentDockContainer.Orientation == eOrientation.Horizontal || visibleChanged && m_DocumentDockContainer.Documents.Count == 1))
                    {
                        int width = barToDock.GetBarDockedSize(eOrientation.Vertical);
                        if (barToDock.Width > 0 && barToDock.Width<m_Container.Width) width = barToDock.Width;
                        int clientWidth = GetClientWidth();

                        if (barToDock.Visible)
                        {
                            if (width > clientWidth)
                                width = barToDock.MinimumDockSize(eOrientation.Vertical).Width * 2;
                            if (width > clientWidth)
                                width = barToDock.MinimumDockSize(eOrientation.Vertical).Width;
                        }
                        
						if(doc.LayoutBounds.Width == 0)
							doc.SetLayoutBounds(new Rectangle(doc.LayoutBounds.X, doc.LayoutBounds.Y, width, doc.LayoutBounds.Height));
                        width += m_DocumentDockContainer.SplitterSize;
                        if (visibleChanged)
                        {
                            if(barToDock.Visible)
                                m_Container.Width += width;
                            else if(m_Container.Width>0)
                                m_Container.Width -= Math.Min(width, m_Container.Width);
                        }
                        else
                            m_Container.Width += width;
                        m_Container.Invalidate();
                    }
                }
                else if (m_Container.Dock == DockStyle.Top || m_Container.Dock == DockStyle.Bottom)
                {
                    if (m_Container.Height == 0 || doc.Parent == m_DocumentDockContainer &&
                        (m_DocumentDockContainer.Orientation == eOrientation.Vertical || visibleChanged && m_DocumentDockContainer.Documents.Count == 1))
                    {
                        int height = barToDock.GetBarDockedSize(eOrientation.Horizontal);
                        if (barToDock.Height > 0 && barToDock.Height<m_Container.Height) height = barToDock.Height;
                        int clientHeight = GetClientHeight();

                        if (barToDock.Visible)
                        {
                            if (height > clientHeight)
                                height = barToDock.MinimumDockSize(eOrientation.Horizontal).Height * 2;
                            if (height > clientHeight)
                                height = barToDock.MinimumDockSize(eOrientation.Horizontal).Height;
                        }
                        
						if(doc.LayoutBounds.Height == 0)
							doc.SetLayoutBounds(new Rectangle(doc.LayoutBounds.X, doc.LayoutBounds.Y, doc.LayoutBounds.Width, height));
                        height += m_DocumentDockContainer.SplitterSize;
                        if (visibleChanged)
                        {
                            if (barToDock.Visible)
                                m_Container.Height += height;
                            else if (m_Container.Height > 0)
                                m_Container.Height -= Math.Min(height, m_Container.Height);
                        }
                        else
                            m_Container.Height += height;
                        m_Container.Invalidate();
                    }
                }
            }
        }