Exemple #1
0
        private void MeasureOverflowedItems(
            int overflowedItemsCount,
            SizeF availableSize,
            float sumOfSpace,
            ref SizeF totalSize)
        {
            bool flag = this.Orientation == Orientation.Horizontal;

            for (int index = 0; index < overflowedItemsCount; ++index)
            {
                RadCommandBarBaseItem child = this.overflowPanel.Children[0] as RadCommandBarBaseItem;
                if (child != null)
                {
                    if (!child.VisibleInStrip)
                    {
                        child.Measure(SizeF.Empty);
                        this.items.Add(child);
                        this.OnItemOutOfOverflow((object)child, new EventArgs());
                    }
                    else
                    {
                        child.Measure(LayoutUtils.InfinitySize);
                        float num1 = flag ? child.DesiredSize.Width : child.DesiredSize.Height;
                        float num2 = flag ? availableSize.Width : availableSize.Height;
                        if ((double)sumOfSpace + (double)num1 > (double)num2)
                        {
                            break;
                        }
                        this.items.Add(child);
                        this.OnItemOutOfOverflow((object)child, new EventArgs());
                        if (flag)
                        {
                            child.Measure(new SizeF(availableSize.Width - sumOfSpace, availableSize.Height));
                            totalSize.Width += child.DesiredSize.Width;
                            totalSize.Height = Math.Max(totalSize.Height, child.DesiredSize.Height);
                        }
                        else
                        {
                            child.Measure(new SizeF(availableSize.Width, availableSize.Height - sumOfSpace));
                            totalSize.Height += child.DesiredSize.Height;
                            totalSize.Width   = Math.Max(totalSize.Width, child.DesiredSize.Width);
                        }
                        sumOfSpace += num1;
                    }
                }
            }
        }
Exemple #2
0
        internal SizeF GetExpectedSize(SizeF availableSize)
        {
            SizeF result = SizeF.Empty;

            foreach (RadElement child in this.Children)
            {
                RadCommandBarBaseItem item = child as RadCommandBarBaseItem;
                if (item == null || !item.VisibleInStrip)
                {
                    continue;
                }

                item.Measure(availableSize);
                if (this.Orientation == System.Windows.Forms.Orientation.Horizontal)
                {
                    result.Width += item.DesiredSize.Width;
                    result.Height = Math.Max(result.Height, item.DesiredSize.Height);
                }
                else
                {
                    result.Height += item.DesiredSize.Height;
                    result.Width   = Math.Max(result.Width, item.DesiredSize.Width);
                }
            }

            foreach (RadElement child in this.overflowPannel.Children)
            {
                RadCommandBarBaseItem item = child as RadCommandBarBaseItem;
                if (item == null || !item.VisibleInStrip)
                {
                    continue;
                }

                child.Measure(availableSize);
                if (this.Orientation == System.Windows.Forms.Orientation.Horizontal)
                {
                    result.Width += child.DesiredSize.Width;
                    result.Height = Math.Max(result.Height, child.DesiredSize.Height);
                }
                else
                {
                    result.Height += child.DesiredSize.Height;
                    result.Width   = Math.Max(result.Width, child.DesiredSize.Width);
                }
            }

            return(result);
        }
Exemple #3
0
        internal SizeF GetExpectedSize(SizeF availableSize)
        {
            SizeF empty = SizeF.Empty;

            foreach (RadElement child in this.Children)
            {
                RadCommandBarBaseItem commandBarBaseItem = child as RadCommandBarBaseItem;
                if (commandBarBaseItem != null && commandBarBaseItem.VisibleInStrip)
                {
                    commandBarBaseItem.Measure(availableSize);
                    if (this.Orientation == Orientation.Horizontal)
                    {
                        empty.Width += commandBarBaseItem.DesiredSize.Width;
                        empty.Height = Math.Max(empty.Height, commandBarBaseItem.DesiredSize.Height);
                    }
                    else
                    {
                        empty.Height += commandBarBaseItem.DesiredSize.Height;
                        empty.Width   = Math.Max(empty.Width, commandBarBaseItem.DesiredSize.Width);
                    }
                }
            }
            foreach (RadElement child in this.overflowPanel.Children)
            {
                RadCommandBarBaseItem commandBarBaseItem = child as RadCommandBarBaseItem;
                if (commandBarBaseItem != null && commandBarBaseItem.VisibleInStrip)
                {
                    child.Measure(availableSize);
                    if (this.Orientation == Orientation.Horizontal)
                    {
                        empty.Width += child.DesiredSize.Width;
                        empty.Height = Math.Max(empty.Height, child.DesiredSize.Height);
                    }
                    else
                    {
                        empty.Height += child.DesiredSize.Height;
                        empty.Width   = Math.Max(empty.Width, child.DesiredSize.Width);
                    }
                }
            }
            return(empty);
        }
Exemple #4
0
        protected override SizeF MeasureOverride(SizeF availableSize)
        {
            SizeF totalSize    = SizeF.Empty;
            bool  isHorizontal = this.Orientation == Orientation.Horizontal;
            float sumOfSpace   = 0;
            bool  overflowed   = false;
            int   currentIndex;
            int   visibleItemsCount    = this.items.Count;
            int   overflowedItemsCount = this.overflowPannel.Children.Count;

            if (visibleItemsCount == 0 && overflowedItemsCount == 0)//run out of items to arrange - simulate MinSize
            {
                return(isHorizontal ? new SizeF(30, 0) : new SizeF(0, 30));
            }

            CommandBarStripElement parent = (this.Parent as CommandBarStripElement);

            for (currentIndex = 0; currentIndex < visibleItemsCount; ++currentIndex)
            {
                RadCommandBarBaseItem child = this.items[currentIndex] as RadCommandBarBaseItem;
                if (child == null)
                {
                    continue;
                }

                if (!child.VisibleInStrip && parent.Site == null)
                {
                    child.Measure(SizeF.Empty);
                    continue;
                }

                child.Measure(LayoutUtils.InfinitySize);
                float desiredSpace   = isHorizontal ? child.DesiredSize.Width : child.DesiredSize.Height;
                float availableSpace = isHorizontal ? availableSize.Width : availableSize.Height;

                if (parent.Site != null)
                {
                    //do nothing - we are in design time
                }
                else if (sumOfSpace + desiredSpace > availableSpace && this.allowOverflow)
                {
                    overflowed = true;
                    break;
                }
                else
                {
                    if (isHorizontal)
                    {
                        child.Measure(new SizeF(
                                          Math.Max(availableSize.Width - sumOfSpace, 0),
                                          availableSize.Height));
                    }
                    else
                    {
                        child.Measure(new SizeF(
                                          availableSize.Width,
                                          Math.Max(availableSize.Height - sumOfSpace, 0)));
                    }
                }

                if (isHorizontal)
                {
                    totalSize.Width += child.DesiredSize.Width;
                    totalSize.Height = Math.Max(totalSize.Height, child.DesiredSize.Height);
                }
                else
                {
                    totalSize.Height += child.DesiredSize.Height;
                    totalSize.Width   = Math.Max(totalSize.Width, child.DesiredSize.Width);
                }

                sumOfSpace += desiredSpace;
            }

            if (overflowed && parent.Site == null && this.allowOverflow)
            {
                this.HandleOverflowedItems(visibleItemsCount, currentIndex);
            }
            else if (parent.Site == null)
            {
                this.MeasureOverflowedItems(overflowedItemsCount, availableSize, sumOfSpace, ref totalSize);
            }

            if (this.overflowPannel.Children.Count > 0)
            {
                if (this.Orientation == System.Windows.Forms.Orientation.Horizontal)
                {
                    totalSize.Width = availableSize.Width;
                }
                else
                {
                    totalSize.Height = availableSize.Height;
                }
            }

            return(totalSize);
        }
Exemple #5
0
        protected override SizeF MeasureOverride(SizeF availableSize)
        {
            SizeF empty      = SizeF.Empty;
            bool  flag1      = this.Orientation == Orientation.Horizontal;
            float sumOfSpace = 0.0f;
            bool  flag2      = false;
            int   count1     = this.items.Count;
            int   count2     = this.overflowPanel.Children.Count;

            if (count1 == 0 && count2 == 0)
            {
                return(RadControl.GetDpiScaledSize(flag1 ? new SizeF(30f, 0.0f) : new SizeF(0.0f, 30f)));
            }
            CommandBarStripElement parent = this.Parent as CommandBarStripElement;
            int currentIndex;

            for (currentIndex = 0; currentIndex < count1; ++currentIndex)
            {
                RadCommandBarBaseItem commandBarBaseItem = this.items[currentIndex];
                if (commandBarBaseItem != null)
                {
                    if (!commandBarBaseItem.VisibleInStrip && parent.Site == null)
                    {
                        commandBarBaseItem.Measure(SizeF.Empty);
                    }
                    else
                    {
                        commandBarBaseItem.Measure(LayoutUtils.InfinitySize);
                        float num1 = flag1 ? commandBarBaseItem.DesiredSize.Width : commandBarBaseItem.DesiredSize.Height;
                        float num2 = flag1 ? availableSize.Width : availableSize.Height;
                        if (parent.Site == null)
                        {
                            if ((double)sumOfSpace + (double)num1 > (double)num2 && this.allowOverflow)
                            {
                                flag2 = true;
                                break;
                            }
                            if (flag1)
                            {
                                commandBarBaseItem.Measure(new SizeF(Math.Max(availableSize.Width - sumOfSpace, 0.0f), availableSize.Height));
                            }
                            else
                            {
                                commandBarBaseItem.Measure(new SizeF(availableSize.Width, Math.Max(availableSize.Height - sumOfSpace, 0.0f)));
                            }
                        }
                        if (flag1)
                        {
                            empty.Width += commandBarBaseItem.DesiredSize.Width;
                            empty.Height = Math.Max(empty.Height, commandBarBaseItem.DesiredSize.Height);
                        }
                        else
                        {
                            empty.Height += commandBarBaseItem.DesiredSize.Height;
                            empty.Width   = Math.Max(empty.Width, commandBarBaseItem.DesiredSize.Width);
                        }
                        sumOfSpace += num1;
                    }
                }
            }
            if (flag2 && parent.Site == null && this.allowOverflow)
            {
                this.HandleOverflowedItems(count1, currentIndex);
            }
            else if (parent.Site == null)
            {
                this.MeasureOverflowedItems(count2, availableSize, sumOfSpace, ref empty);
            }
            if (this.overflowPanel.Children.Count > 0)
            {
                if (this.Orientation == Orientation.Horizontal)
                {
                    empty.Width = availableSize.Width;
                }
                else
                {
                    empty.Height = availableSize.Height;
                }
            }
            return(empty);
        }