コード例 #1
0
        private float DetermineStretchedItemU(
            int start,
            int end,
            RadElementCollection internalChildren,
            float totalU)
        {
            List <RadElement> radElementList = new List <RadElement>();

            for (int index = start; index < end; ++index)
            {
                RadElement internalChild = internalChildren[index];
                if (internalChild != null && internalChild.Visibility != ElementVisibility.Collapsed)
                {
                    radElementList.Add(internalChild);
                }
            }
            int   count = radElementList.Count;
            float num1  = totalU / (float)count;
            float num2  = totalU;

            radElementList.Sort(new Comparison <RadElement>(this.ElementComparisonBySizeDesc));
            for (int index = 0; index < radElementList.Count; ++index)
            {
                RadElement             radElement = radElementList[index];
                WrapLayoutPanel.UVSize uvSize     = new WrapLayoutPanel.UVSize(this.Orientation, radElement.DesiredSize.Width, radElement.DesiredSize.Height);
                if ((double)uvSize.U > (double)num1)
                {
                    num2 -= uvSize.U;
                    --count;
                    num1 = num2 / (float)count;
                }
            }
            return(num1);
        }
コード例 #2
0
        protected override SizeF ArrangeOverride(SizeF finalSize)
        {
            int   start      = 0;
            float itemWidth  = this.ItemWidth;
            float itemHeight = this.ItemHeight;
            float VPosition  = 0.0f;
            float itemU      = this.Orientation == Orientation.Horizontal ? itemWidth : itemHeight;
            float totalU     = this.Orientation == Orientation.Horizontal ? finalSize.Width : finalSize.Height;

            WrapLayoutPanel.UVSize uvSize1 = new WrapLayoutPanel.UVSize(this.Orientation);
            WrapLayoutPanel.UVSize uvSize2 = new WrapLayoutPanel.UVSize(this.Orientation, finalSize.Width, finalSize.Height);
            bool flag1    = !float.IsNaN(itemWidth);
            bool flag2    = !float.IsNaN(itemHeight);
            bool useItemU = this.Orientation == Orientation.Horizontal ? flag1 : flag2;
            RadElementCollection children = this.Children;
            int index = 0;

            for (int count = children.Count; index < count; ++index)
            {
                RadElement radElement = children[index];
                if (radElement != null)
                {
                    WrapLayoutPanel.UVSize uvSize3 = new WrapLayoutPanel.UVSize(this.Orientation, flag1 ? itemWidth : radElement.DesiredSize.Width, flag2 ? itemHeight : radElement.DesiredSize.Height);
                    if (DoubleUtil.GreaterThan(uvSize1.U + uvSize3.U, uvSize2.U))
                    {
                        this.ArrangeLine(VPosition, uvSize1.V, start, index, useItemU, itemU, totalU);
                        VPosition += uvSize1.V;
                        uvSize1    = uvSize3;
                        if (DoubleUtil.GreaterThan(uvSize3.U, uvSize2.U))
                        {
                            this.ArrangeLine(VPosition, uvSize3.V, index, ++index, useItemU, itemU, totalU);
                            VPosition += uvSize3.V;
                            uvSize1    = new WrapLayoutPanel.UVSize(this.Orientation);
                        }
                        start = index;
                    }
                    else
                    {
                        uvSize1.U += uvSize3.U;
                        uvSize1.V  = Math.Max(uvSize3.V, uvSize1.V);
                    }
                }
            }
            if (start < children.Count)
            {
                this.ArrangeLine(VPosition, uvSize1.V, start, children.Count, useItemU, itemU, totalU);
            }
            return(finalSize);
        }
コード例 #3
0
        protected override SizeF MeasureOverride(SizeF constraint)
        {
            WrapLayoutPanel.UVSize uvSize1 = new WrapLayoutPanel.UVSize(this.Orientation);
            WrapLayoutPanel.UVSize uvSize2 = new WrapLayoutPanel.UVSize(this.Orientation);
            WrapLayoutPanel.UVSize uvSize3 = new WrapLayoutPanel.UVSize(this.Orientation, constraint.Width, constraint.Height);
            float itemWidth               = this.ItemWidth;
            float itemHeight              = this.ItemHeight;
            bool  flag1                   = !float.IsNaN(itemWidth);
            bool  flag2                   = !float.IsNaN(itemHeight);
            SizeF availableSize           = new SizeF(flag1 ? itemWidth : constraint.Width, flag2 ? itemHeight : constraint.Height);
            RadElementCollection children = this.Children;
            int index = 0;

            for (int count = children.Count; index < count; ++index)
            {
                RadElement radElement = children[index];
                if (radElement != null)
                {
                    radElement.Measure(availableSize);
                    WrapLayoutPanel.UVSize uvSize4 = new WrapLayoutPanel.UVSize(this.Orientation, flag1 ? itemWidth : radElement.DesiredSize.Width, flag2 ? itemHeight : radElement.DesiredSize.Height);
                    if (DoubleUtil.GreaterThan(uvSize1.U + uvSize4.U, uvSize3.U))
                    {
                        uvSize2.U  = Math.Max(uvSize1.U, uvSize2.U);
                        uvSize2.V += uvSize1.V;
                        uvSize1    = uvSize4;
                        if (DoubleUtil.GreaterThan(uvSize4.U, uvSize3.U))
                        {
                            uvSize2.U  = Math.Max(uvSize4.U, uvSize2.U);
                            uvSize2.V += uvSize4.V;
                            uvSize1    = new WrapLayoutPanel.UVSize(this.Orientation);
                        }
                    }
                    else
                    {
                        uvSize1.U += uvSize4.U;
                        uvSize1.V  = Math.Max(uvSize4.V, uvSize1.V);
                    }
                }
            }
            uvSize2.U  = Math.Max(uvSize1.U, uvSize2.U);
            uvSize2.V += uvSize1.V;
            return(new SizeF(uvSize2.Width, uvSize2.Height));
        }
コード例 #4
0
        private void ArrangeLine(
            float VPosition,
            float lineV,
            int start,
            int end,
            bool useItemU,
            float itemU,
            float totalU)
        {
            float num1 = 0.0f;
            bool  flag = this.Orientation == Orientation.Horizontal;
            RadElementCollection children = this.Children;
            float num2 = 0.0f;

            if (this.stretchItems)
            {
                num2 = this.DetermineStretchedItemU(start, end, children, totalU);
            }
            for (int index = start; index < end; ++index)
            {
                RadElement radElement = children[index];
                if (radElement != null)
                {
                    WrapLayoutPanel.UVSize uvSize = new WrapLayoutPanel.UVSize(this.Orientation, radElement.DesiredSize.Width, radElement.DesiredSize.Height);
                    float num3 = useItemU ? itemU : uvSize.U;
                    if (this.stretchItems && radElement.Visibility != ElementVisibility.Collapsed && (double)num3 < (double)num2)
                    {
                        num3 = num2;
                    }
                    RectangleF finalRect = new RectangleF(flag ? num1 : VPosition, flag ? VPosition : num1, flag ? num3 : lineV, flag ? lineV : num3);
                    if (this.RightToLeft && flag)
                    {
                        finalRect.X = totalU - finalRect.X - finalRect.Width;
                    }
                    radElement.Arrange(finalRect);
                    num1 += num3;
                }
            }
        }