Beispiel #1
0
        private void ExpandElements(List <PreferredSizeData> list, Size availableSize, int nextLeftSaved, int rowElements)
        {
            int nextLeft            = nextLeftSaved;
            int firstCollapsedIndex = -1;

            for (int i = rowElements; i < list.Count; i++)
            {
                PreferredSizeData data = list[i];

                int step = GetDataSize(data, false).Width + data.Element.Margin.Horizontal;

                if ((firstCollapsedIndex == -1) && IsCollapsedElement(data.Element))
                {
                    firstCollapsedIndex = i;
                    nextLeftSaved       = nextLeft + step;
                }

                if (nextLeft + step > availableSize.Width)
                {
                    return;
                }

                nextLeft += step;
            }

            if (firstCollapsedIndex != -1)
            {
                ICollapsibleElement firstCollapsedElement = (ICollapsibleElement)list[firstCollapsedIndex].Element;
                if ((firstCollapsedElement.ExpandedSize != Size.Empty) &&
                    (nextLeft - firstCollapsedElement.ExpandedSize.Width + firstCollapsedElement.ExpandedSize.Width <= availableSize.Width))
                {
                    firstCollapsedElement.ExpandElement();
                    ExpandElements(list, availableSize, nextLeftSaved, firstCollapsedIndex++);
                }
            }
        }