ComponentFactory.Krypton.Toolkit.ViewDrawSplitCanvas.GetPreferredSize C# (CSharp) Method

GetPreferredSize() public method

Discover the preferred size of the element.
public GetPreferredSize ( ViewLayoutContext context ) : Size
context ViewLayoutContext Layout context.
return System.Drawing.Size
        public override Size GetPreferredSize(ViewLayoutContext context)
        {
            Debug.Assert(context != null);

            // Validate incoming reference
            if (context == null) throw new ArgumentNullException("context");

            // Ensure any content children have correct composition setting
            foreach (ViewBase child in this)
                if (child is ViewDrawContent)
                {
                    ViewDrawContent viewContent = (ViewDrawContent)child;
                    viewContent.DrawContentOnComposition = DrawCanvasOnComposition;
                }

            // Let base class find preferred size of the children
            Size preferredSize = base.GetPreferredSize(context);

            // Apply space the border takes up
            if (DrawTabBorder)
                preferredSize = CommonHelper.ApplyPadding(Orientation, preferredSize, context.Renderer.RenderTabBorder.GetTabBorderDisplayPadding(context, _paletteBorder, State, Orientation, TabBorderStyle));
            else
                preferredSize = CommonHelper.ApplyPadding(Orientation, preferredSize, context.Renderer.RenderStandardBorder.GetBorderDisplayPadding(_paletteBorder, State, Orientation));

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

            return preferredSize;
        }

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Discover the preferred size of the element.
        /// </summary>
        /// <param name="context">Layout context.</param>
        public override Size GetPreferredSize(ViewLayoutContext context)
        {
            Debug.Assert(context != null);
            Debug.Assert(_drawCanvas != null);

            // Ensure that child elements have correct palette state
            CheckPaletteState(context);

            // Delegate work to the child canvas
            return(_drawCanvas.GetPreferredSize(context));
        }