ComponentFactory.Krypton.Toolkit.ViewDrawDocker.GetNonChildSize C# (CSharp) Method

GetNonChildSize() public method

Gets the size required for all except the contents.
public GetNonChildSize ( ViewLayoutContext context ) : Size
context ViewLayoutContext Layout context.
return System.Drawing.Size
        public Size GetNonChildSize(ViewLayoutContext context)
        {
            Debug.Assert(context != null);

            // Remember the original display rectangle provided
            Rectangle originalRect = context.DisplayRectangle;
            Rectangle displayRect = context.DisplayRectangle;

            // Border size that is not applied to preferred size
            Size borderSize = Size.Empty;

            // Accumulate the size that must be provided by docking edges and then filler
            Size preferredSize = Size.Empty;

            // Track the minimize size needed to satisfy the docking edges only
            Size minimumSize = Size.Empty;

            if (!IgnoreAllBorderAndPadding)
            {
                // Apply space the border takes up
                if (IgnoreBorderSpace)
                    borderSize = CommonHelper.ApplyPadding(Orientation, borderSize, context.Renderer.RenderStandardBorder.GetBorderDisplayPadding(_paletteBorder, State, Orientation));
                else
                {
                    Padding padding = context.Renderer.RenderStandardBorder.GetBorderDisplayPadding(_paletteBorder, State, Orientation);
                    preferredSize = CommonHelper.ApplyPadding(Orientation, preferredSize, padding);
                    displayRect = CommonHelper.ApplyPadding(Orientation, displayRect, padding);
                }

                // Do we have a metric source for additional padding?
                if ((_paletteMetric != null) && (_metricPadding != PaletteMetricPadding.None))
                {
                    // Apply padding needed outside the border of the canvas
                    Padding padding = _paletteMetric.GetMetricPadding(State, _metricPadding);
                    preferredSize = CommonHelper.ApplyPadding(Orientation, preferredSize, padding);
                    displayRect = CommonHelper.ApplyPadding(Orientation, displayRect, padding);
                }
            }

            // Put back the original display rect
            context.DisplayRectangle = originalRect;

            // Enforce the minimum values from the other docking edge sizes
            preferredSize.Width = Math.Max(preferredSize.Width, minimumSize.Width);
            preferredSize.Height = Math.Max(preferredSize.Height, minimumSize.Height);

            // Enforce the border sizing as the minimum
            preferredSize.Width = Math.Max(preferredSize.Width, borderSize.Width);
            preferredSize.Height = Math.Max(preferredSize.Height, borderSize.Height);

            return preferredSize;
        }