Ejemplo n.º 1
0
        public override void Layout(GraphicsSettings settings, Size maximumSize)
        {
            int width  = 0;
            int height = 0;

            SyncSectionsToColumns(HeaderColumnSection.DisplayMode.Header);

            Point pt = new Point(Location.X, Location.Y);

            int reservedSpace = LayoutController == null ? 0 : LayoutController.ReservedNearSpace;

            bool first = true;

            foreach (Section hcs in Children)
            {
                hcs.Location = pt;
                hcs.Layout(settings, new Size(maximumSize.Width - pt.X, _isVisible ? maximumSize.Height - pt.Y : 0));
                if (first)
                {
                    hcs.Size = new Size(hcs.Size.Width + reservedSpace, hcs.Size.Height);
                    first    = false;
                }
                pt     = new Point(hcs.Rectangle.Right, pt.Y);
                width += hcs.Rectangle.Width;
                if (hcs.Size.Height > height)
                {
                    height = hcs.Size.Height;
                }
            }
            if (height == 0 && _isVisible)
            {
                if (VisualStyleRenderer.IsSupported)
                {
                    VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Header.Item.Normal);

                    height = renderer.GetPartSize(settings.Graphics, ThemeSizeType.True).Height;
                }
                else
                {
                    height = SystemFonts.DialogFont.Height + 6;
                }
            }
            _idealWidth = width;
            if (height < MinimumHeight)
            {
                height = MinimumHeight;
            }
            Size = new Size(Math.Max(maximumSize.Width, _idealWidth), height);
            if (LayoutController != null)
            {
                LayoutController.HeaderLayedOut();
            }
        }