ComponentFactory.Krypton.Ribbon.VisualPopupGroup.ShowCalculatingSize C# (CSharp) Method

ShowCalculatingSize() public method

Show the group popup relative to the parent group instance.
public ShowCalculatingSize ( ViewDrawRibbonGroup parentGroup, Rectangle parentScreenRect ) : void
parentGroup ViewDrawRibbonGroup Parent group instance.
parentScreenRect System.Drawing.Rectangle Screen rectangle of the parent.
return void
        public void ShowCalculatingSize(ViewDrawRibbonGroup parentGroup,
                                        Rectangle parentScreenRect)
        {
            Size popupSize;

            // Prevent ribbon from laying out the same group as we are
            // about to get the preferred size from. This reentrancy can
            // happen if the group has a custom control that is then moved
            // to be reparented to the popup group and so therefore cause
            // a layout of the main ribbon.
            _ribbon.SuspendLayout();
            SuspendLayout();

            try
            {
                // Find the size the group requests to be
                using (ViewLayoutContext context = new ViewLayoutContext(this, Renderer))
                    popupSize = _viewGroup.GetPreferredSize(context);

                // Override the height to enforce the correct group height
                popupSize.Height = _ribbon.CalculatedValues.GroupHeight;

                // Mark the group as showing as a popup
                _ribbonGroup.ShowingAsPopup = true;

                // Request we be shown below the parent screen rect
                Show(CalculateBelowPopupRect(parentScreenRect, popupSize));
            }
            finally
            {
                // Reverse the suspend call
                _ribbon.ResumeLayout();
                ResumeLayout();
            }
        }

Usage Example

Example #1
0
        private void OnCollapsedClick(object sender, MouseEventArgs e)
        {
            // We do not operate the collapsed button at design time
            if (!_ribbon.InDesignMode)
            {
                // We are pressed until the popup window is removed
                _pressed = true;
                _container.Refresh();

                // Create the popup window for the group
                _popupGroup = new VisualPopupGroup(_ribbon, _ribbonGroup, _ribbon.Renderer);

                // We need to know when disposed so the pressed state can be reversed
                _popupGroup.Disposed += new EventHandler(OnVisualPopupGroupDisposed);

                // Ask the popup to show itself relative to ourself
                _popupGroup.ShowCalculatingSize(this, _container.RectangleToScreen(ClientRectangle));
            }
        }
All Usage Examples Of ComponentFactory.Krypton.Ribbon.VisualPopupGroup::ShowCalculatingSize