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);
        }
Example #2
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 #3
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 #4
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 #5
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;
            }
Example #7
0
 public AbstractSize(Orientation naturalOrientation, Orientation actualOrientation, double realWidth, double realHeight)
 {
     this = new AbstractSize(naturalOrientation, actualOrientation);
     this._abstractSize = this.IsNatural ? new Size(realWidth, realHeight) : new Size(realHeight, realWidth);
 }
Example #8
0
 public AbstractSize(Orientation naturalOrientation, Orientation actualOrientation, Size realSize)
 {
     this = new AbstractSize(naturalOrientation, actualOrientation);
     this._abstractSize = this.IsNatural ? realSize : AbstractSize.Invert(realSize);
 }