private SizeF ContextGroupsMeasure(SizeF availableSize)
        {
            SizeF result                 = SizeF.Empty;
            SizeF measureSize            = new SizeF();
            ContextualTabGroup rightMost = this.GetRightMostGroup(this.IsDesignMode);

            if (rightMost != this.rightMostGroup)
            {
                this.rightMostGroup = rightMost;
                this.showTabGroups  = true;
            }

            int emptyGroupsCount = this.GetEmptyGroupsCount();

            for (int i = this.contextualTabGroups.Count - 1; i > -1; i--)
            {
                ContextualTabGroup tabGroup = this.contextualTabGroups[i] as ContextualTabGroup;

                if (tabGroup != null)
                {
                    if (tabGroup.TabItems.Count == 0)
                    {
                        if (this.IsDesignMode)
                        {
                            float groupWidth = 100;

                            if (emptyGroupsCount > 0 && ((this.rightEmptySpace / emptyGroupsCount) < 100))
                            {
                                groupWidth = ((this.rightEmptySpace) / emptyGroupsCount);
                            }

                            if (groupWidth < 20)
                            {
                                groupWidth = 0;
                            }

                            measureSize   = new SizeF(groupWidth, availableSize.Height);
                            result.Width += tabGroup.DesiredSize.Width;
                            result.Height = tabGroup.DesiredSize.Height;
                        }
                        else
                        {
                            measureSize   = Size.Empty;
                            result.Width += tabGroup.DesiredSize.Width;
                            result.Height = tabGroup.DesiredSize.Height;
                        }
                    }
                    else
                    {
                        if (tabGroup == rightMost)
                        {
                            SizeF groupSize = this.PerformMeasureWithShrink(availableSize, tabGroup);

                            if (!this.showTabGroups)
                            {
                                measureSize = Size.Empty;
                            }
                            else
                            {
                                measureSize = groupSize;
                            }
                            result.Width += tabGroup.DesiredSize.Width;
                            result.Height = tabGroup.DesiredSize.Height;
                        }
                        else
                        {
                            if (this.showTabGroups)
                            {
                                measureSize   = new SizeF(this.CalculateGroupWidth(tabGroup), availableSize.Height);
                                result.Width += tabGroup.DesiredSize.Width;
                                result.Height = tabGroup.DesiredSize.Height;
                            }
                            else
                            {
                                measureSize   = SizeF.Empty;
                                result.Width += tabGroup.DesiredSize.Width;
                            }
                        }
                    }
                }

                if (tabGroup.Visibility == ElementVisibility.Visible)
                {
                    tabGroup.Measure(measureSize);
                }
                else
                {
                    tabGroup.Measure(SizeF.Empty);
                }
            }

            return(result);
        }
Exemple #2
0
        private SizeF ContextGroupsMeasure(SizeF availableSize)
        {
            SizeF empty          = SizeF.Empty;
            SizeF availableSize1 = new SizeF();
            ContextualTabGroup rightMostGroup = this.GetRightMostGroup(this.IsDesignMode);

            if (rightMostGroup != this.rightMostGroup)
            {
                this.rightMostGroup = rightMostGroup;
                this.showTabGroups  = true;
            }
            int emptyGroupsCount = this.GetEmptyGroupsCount();

            for (int index = this.RibbonBarElement.ContextualTabGroups.Count - 1; index > -1; --index)
            {
                ContextualTabGroup contextualTabGroup = this.RibbonBarElement.ContextualTabGroups[index] as ContextualTabGroup;
                if (contextualTabGroup != null)
                {
                    if (contextualTabGroup.TabItems.Count == 0)
                    {
                        if (this.IsDesignMode)
                        {
                            float width = 100f;
                            if (emptyGroupsCount > 0 && (double)this.rightEmptySpace / (double)emptyGroupsCount < 100.0)
                            {
                                width = this.rightEmptySpace / (float)emptyGroupsCount;
                            }
                            if ((double)width < 20.0)
                            {
                                width = 0.0f;
                            }
                            availableSize1 = new SizeF(width, availableSize.Height);
                            empty.Width   += Math.Max(contextualTabGroup.DesiredSize.Width, (float)contextualTabGroup.MinSize.Width);
                            empty.Height   = Math.Max(contextualTabGroup.DesiredSize.Height, (float)contextualTabGroup.MinSize.Height);
                        }
                        else
                        {
                            availableSize1 = (SizeF)Size.Empty;
                            empty.Width   += Math.Max(contextualTabGroup.DesiredSize.Width, (float)contextualTabGroup.MinSize.Width);
                            empty.Height   = Math.Max(contextualTabGroup.DesiredSize.Height, (float)contextualTabGroup.MinSize.Height);
                        }
                    }
                    else if (contextualTabGroup == rightMostGroup)
                    {
                        SizeF sizeF = this.PerformMeasureWithShrink(availableSize, contextualTabGroup);
                        availableSize1 = this.showTabGroups ? sizeF : (SizeF)Size.Empty;
                        empty.Width   += contextualTabGroup.DesiredSize.Width;
                        empty.Height   = contextualTabGroup.DesiredSize.Height;
                    }
                    else if (this.showTabGroups)
                    {
                        availableSize1 = new SizeF(this.CalculateGroupWidth(contextualTabGroup), availableSize.Height);
                        empty.Width   += Math.Max(contextualTabGroup.DesiredSize.Width, (float)contextualTabGroup.MinSize.Width);
                        empty.Height   = Math.Max(contextualTabGroup.DesiredSize.Height, (float)contextualTabGroup.MinSize.Height);
                    }
                    else
                    {
                        availableSize1 = SizeF.Empty;
                        empty.Width   += Math.Max(contextualTabGroup.DesiredSize.Width, (float)contextualTabGroup.MinSize.Width);
                    }
                }
                if (contextualTabGroup.Visibility == ElementVisibility.Visible)
                {
                    contextualTabGroup.Measure(availableSize1);
                }
                else
                {
                    contextualTabGroup.Measure(SizeF.Empty);
                }
            }
            return(empty);
        }