public void AddRow(SpacingWrapPanel.RowInfo row)
            {
                AbstractSize abstractSize = row.AbstractSize;
                double       num1         = this._size.AbstractHeight + (abstractSize.AbstractHeight + (this._rows.Count > 0 ? this._rowSpacing : 0.0));

                this._rows.Add(row);
                ref AbstractSize local          = ref this._size;
        protected override Size MeasureOverride(Size constraint)
        {
            this._measureInfo.Reset();
            double       itemWidth     = this.ItemWidth;
            double       itemHeight    = this.ItemHeight;
            bool         flag1         = !double.IsNaN(itemWidth);
            bool         flag2         = !double.IsNaN(itemHeight);
            Size         availableSize = new Size(flag1 ? itemWidth : constraint.Width, flag2 ? itemHeight : constraint.Height);
            AbstractSize abstractSize  = this.MakeAbstractSize(constraint);

            SpacingWrapPanel.RowInfo row = new SpacingWrapPanel.RowInfo(this, abstractSize.AbstractWidth);
            foreach (UIElement nonCollapsedChild in this.NonCollapsedChildren)
            {
                nonCollapsedChild.Measure(availableSize);
                AbstractSize childSize = this.MakeAbstractSize(flag1 ? itemWidth : nonCollapsedChild.DesiredSize.Width, flag2 ? itemHeight : nonCollapsedChild.DesiredSize.Height);
                if (!row.AddChild(childSize))
                {
                    this._measureInfo.AddRow(row);
                    row = new SpacingWrapPanel.RowInfo(this, abstractSize.AbstractWidth);
                    row.AddChild(childSize);
                }
            }
            this._measureInfo.AddRow(row);
            return(this._measureInfo.AbstractSize.RealSize);
        }
            public void Reset()
            {
                AbstractSize abstractItemSpacing = this._panel.AbstractItemSpacing;

                this._size       = this._panel.MakeAbstractSize();
                this._rowSpacing = double.IsNaN(abstractItemSpacing.AbstractHeight) ? 0.0 : abstractItemSpacing.AbstractHeight;
                this._rows.Clear();
            }
Example #4
0
 public Measurer(List <AbstractSize> childSizes, AbstractSize availableSize, int maxWrappingLevels)
 {
     this._childSizes           = childSizes;
     this._availableWidth       = availableSize.AbstractWidth;
     this._maxWrappingLevels    = maxWrappingLevels;
     this._totalSize            = new AbstractSize(availableSize.NaturalOrientation, availableSize.ActualOrientation, 0.0, 0.0);
     this._actualWrappingLevels = 0;
     this.CalculateTotalSizeAndUpdateActualWrappingLevels();
 }
Example #5
0
        protected override Size MeasureOverride(Size availableSize)
        {
            this.MeasureNonNullChildren();
            List <AbstractSize> collapsedChildrenSizes = this.GetNonCollapsedChildrenSizes();

            if (collapsedChildrenSizes.Count == 0)
            {
                return(new Size(0.0, 0.0));
            }
            AbstractSize abstractSize = this.ConvertToAbstractSize(availableSize);

            GreedyWrapPanel.Measurer measurer = new GreedyWrapPanel.Measurer(collapsedChildrenSizes, abstractSize, this.MaxWrappingLevels);
            this.ActualWrappingLevels = measurer.ActualWrappingLevels;
            return(measurer.TotalSize.RealSize);
        }
Example #6
0
            public AbstractPoint GetPositionOfNextChild(AbstractSize childSize)
            {
                if (this._currentWrappingLevelChildrenCount >= this._childrenPerWrappingLevel)
                {
                    this.ShiftToNewWrappingLevel();
                }
                AbstractPoint currentOffset = this._currentOffset;

                if (childSize.AbstractWidth > this._currentWrappingLevelWidth)
                {
                    this._currentWrappingLevelWidth = childSize.AbstractWidth;
                }
                this.ShiftToBelowPreviousChild(childSize.AbstractHeight);
                return(currentOffset);
            }
Example #7
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            int totalCount = this.NonCollapsedChildren.Count <UIElement>();

            if (totalCount == 0)
            {
                return(finalSize);
            }
            GreedyWrapPanel.ChildArranger childArranger = new GreedyWrapPanel.ChildArranger(new AbstractPoint(Orientation.Vertical, this.Orientation, 0.0, 0.0), GreedyWrapPanel.CalculateCountPerWrappingLevel(totalCount, this.ActualWrappingLevels));
            foreach (UIElement nonCollapsedChild in this.NonCollapsedChildren)
            {
                AbstractSize  abstractSize        = this.ConvertToAbstractSize(nonCollapsedChild.DesiredSize);
                AbstractPoint positionOfNextChild = childArranger.GetPositionOfNextChild(abstractSize);
                nonCollapsedChild.Arrange(new Rect(positionOfNextChild.RealPoint, nonCollapsedChild.DesiredSize));
            }
            return(childArranger.TotalSize.RealSize);
        }
        protected override Size ArrangeOverride(Size constraint)
        {
            UIElement[]   array               = this.NonCollapsedChildren.ToArray <UIElement>();
            AbstractPoint abstractPoint       = this.MakeAbstractPoint();
            AbstractSize  abstractSize1       = this.MakeAbstractSize(constraint);
            AbstractSize  abstractItemSpacing = this.AbstractItemSpacing;
            double        itemSpacing;
            double        remainder;

            this.ComputeItemSpacing(this._measureInfo.RowCount, abstractSize1.AbstractHeight, this._measureInfo.AbstractSize.AbstractHeight, abstractItemSpacing.AbstractHeight, out itemSpacing, out remainder);
            int index1 = 0;

            for (int index2 = 0; index2 < this._measureInfo.RowCount; ++index2)
            {
                SpacingWrapPanel.RowInfo row = this._measureInfo.Rows[index2];
                int          childCount      = row.ChildCount;
                double       abstractWidth1  = abstractSize1.AbstractWidth;
                AbstractSize abstractSize2   = row.AbstractSize;
                double       abstractWidth2  = abstractSize2.AbstractWidth;
                double       abstractWidth3  = abstractItemSpacing.AbstractWidth;
                double       num1;
                double       num2;
                this.ComputeItemSpacing(childCount, abstractWidth1, abstractWidth2, abstractWidth3, out num1, out num2);
                int index3 = 0;
                while (index3 < row.ChildCount)
                {
                    UIElement    uiElement = array[index1];
                    AbstractSize childSize = row.ChildSizes[index3];
                    Rect         finalRect = new Rect(abstractPoint.RealPoint, childSize.RealSize);
                    uiElement.Arrange(finalRect);
                    double num3 = num1 + ((double)index3 < num2 ? 1.0 : 0.0);
                    abstractPoint.AbstractX += childSize.AbstractWidth + num3;
                    ++index3;
                    ++index1;
                }
                double num4 = itemSpacing + ((double)index2 < remainder ? 1.0 : 0.0);
                abstractPoint.AbstractX = 0.0;
                ref AbstractPoint local3    = ref abstractPoint;
                double            abstractY = local3.AbstractY;
                abstractSize2 = row.AbstractSize;
                double num5 = abstractSize2.AbstractHeight + num4;
                local3.AbstractY = abstractY + num5;
            }