Пример #1
0
        /// <summary>
        /// Discover the preferred size of the element.
        /// </summary>
        /// <param name="context">Layout context.</param>
        public override Size GetPreferredSize(ViewLayoutContext context)
        {
            Size preferredSize = Size.Empty;

            // Ensure the control has the correct parent
            UpdateParent(context.Control);

            // If there is a custom control associated then ask for its requested size
            if (LastCustomControl != null)
            {
                if (ActualVisible(LastCustomControl))
                {
                    preferredSize = LastCustomControl.GetPreferredSize(context.DisplayRectangle.Size);

                    // Add two pixels, one for the left and right edges that will be padded
                    preferredSize.Width += 2;
                }
            }
            else
            {
                preferredSize.Width = NULL_CONTROL_WIDTH;
            }

            if (_currentSize == GroupItemSize.Large)
            {
                preferredSize.Height = _ribbon.CalculatedValues.GroupTripleHeight;
            }
            else
            {
                preferredSize.Height = _ribbon.CalculatedValues.GroupLineHeight;
            }

            return(preferredSize);
        }