public override Size MeasureSize(object sender, RibbonElementMeasureSizeEventArgs e)
        {
            if (e.SizeMode == RibbonElementSizeMode.DropDown)
            {
                if (string.IsNullOrEmpty(Text))
                {
                    return new Size(1, 1);
                }

                var sz = e.Graphics.MeasureString(Text, new Font(Owner.Font, FontStyle.Bold)).ToSize();
                SetLastMeasuredSize(new Size(sz.Width + Owner.ItemMargin.Horizontal,
                                             sz.Height + Owner.ItemMargin.Vertical));
            }
            else
            {
                SetLastMeasuredSize(new Size(2,
                                             OwnerPanel.ContentBounds.Height - Owner.ItemPadding.Vertical -
                                             Owner.ItemMargin.Vertical));
            }

            return LastMeasuredSize;
        }
        public override Size MeasureSize(object sender, RibbonElementMeasureSizeEventArgs e)
        {
            ///For RibbonItemGroup, size is always compact, and it's designed to be on an horizontal flow
            ///tab panel.
            ///
            int minWidth = 16;
            int widthSum = 0;
            int maxHeight = 16;

            foreach (RibbonItem item in Items)
            {
                Size s = item.MeasureSize(this, new RibbonElementMeasureSizeEventArgs(e.Graphics, RibbonElementSizeMode.Compact));
                widthSum += s.Width + 1;
                maxHeight = Math.Max(maxHeight, s.Height);
            }

            widthSum -= 1;

            widthSum = Math.Max(widthSum, minWidth);

            if (Site != null && Site.DesignMode)
            {
                widthSum += 10;
            }

            Size result = new Size(widthSum, maxHeight);
            SetLastMeasuredSize(result);
            return result;
        }