Example #1
0
        public float MeasureAutoSizeRow(RadElementCollection cells)
        {
            List <float> floatList = new List <float>();
            Dictionary <GridViewColumn, ColumnGroupsCellArrangeInfo> columnsData = this.tree.GetColumnsData();

            foreach (RadElement cell in cells)
            {
                GridCellElement gridCellElement = cell as GridCellElement;
                if (gridCellElement != null && columnsData.ContainsKey(gridCellElement.ColumnInfo))
                {
                    ColumnGroupsCellArrangeInfo groupsCellArrangeInfo = columnsData[gridCellElement.ColumnInfo];
                    if (!(gridCellElement.ColumnInfo is GridViewGroupColumn) || this.HasVisibleColumn(((GridViewGroupColumn)gridCellElement.ColumnInfo).Group))
                    {
                        while (floatList.Count <= groupsCellArrangeInfo.Depth)
                        {
                            floatList.Add(0.0f);
                        }
                        floatList[groupsCellArrangeInfo.Depth] = Math.Max(floatList[groupsCellArrangeInfo.Depth], gridCellElement.DesiredSize.Height);
                    }
                }
            }
            float num1 = 0.0f;

            foreach (float num2 in floatList)
            {
                num1 += num2;
            }
            return(num1);
        }
Example #2
0
        private float DetermineStretchedItemU(int start, int end, RadElementCollection internalChildren, float totalU)
        {
            List <RadElement> childrenSorted = new List <RadElement>();

            for (int i = start; i < end; i++)
            {
                RadElement element = internalChildren[i];
                if (element != null && element.Visibility != ElementVisibility.Collapsed)
                {
                    childrenSorted.Add(element);
                }
            }

            int   itemsCount     = childrenSorted.Count;
            float stretchedItemU = totalU / itemsCount;
            float totalStretchU  = totalU;

            childrenSorted.Sort(new Comparison <RadElement>(ElementComparisonBySizeDesc));

            for (int i = 0; i < childrenSorted.Count; i++)
            {
                RadElement element = childrenSorted[i];
                UVSize     size    = new UVSize(this.Orientation, element.DesiredSize.Width, element.DesiredSize.Height);
                if (size.U > stretchedItemU)
                {
                    totalStretchU -= size.U;
                    itemsCount--;
                    stretchedItemU = totalStretchU / itemsCount;
                }
            }
            return(stretchedItemU);
        }
Example #3
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);
        }
        protected override SizeF ArrangeOverride(SizeF finalSize)
        {
            RadElementCollection children = this.Children;

            int x = 0;
            int y = 0;

            for (int i = 0; i < children.Count; i++)
            {
                RadElement child = children[i];
                SizeF      elementPrefferedSize = child.DesiredSize;
                elementPrefferedSize.Width  = Math.Max(elementPrefferedSize.Width, this.defaultCellSize.Width);
                elementPrefferedSize.Height = Math.Max(elementPrefferedSize.Height, this.defaultCellSize.Height);
                PointF elementPosition = new PointF(x * this.defaultCellSize.Width, y * this.defaultCellSize.Height);
                elementPosition.X += (this.defaultCellSize.Width - elementPrefferedSize.Width) / 2;
                elementPosition.Y += (this.defaultCellSize.Height - elementPrefferedSize.Height) / 2;

                child.Arrange(new RectangleF(elementPosition, elementPrefferedSize));

                if (x < this.columns - 1)
                {
                    x++;
                }
                else
                {
                    x = 0;
                    y++;
                }
            }

            return(finalSize);
        }
        protected override System.Drawing.SizeF MeasureOverride(System.Drawing.SizeF constraint)
        {
            UVSize size          = new UVSize(this.Orientation);
            UVSize size2         = new UVSize(this.Orientation);
            UVSize size3         = new UVSize(this.Orientation, constraint.Width, constraint.Height);
            float  itemWidth     = this.ItemWidth;
            float  itemHeight    = this.ItemHeight;
            bool   flag          = !float.IsNaN(itemWidth);
            bool   flag2         = !float.IsNaN(itemHeight);
            SizeF  availableSize = new SizeF(flag ? itemWidth : constraint.Width, flag2 ? itemHeight : constraint.Height);
            RadElementCollection internalChildren = base.Children;
            int num3  = 0;
            int count = internalChildren.Count;

            while (num3 < count)
            {
                RadCommandBarBaseItem element = internalChildren[num3] as RadCommandBarBaseItem;
                if (element != null)
                {
                    if (!element.VisibleInStrip)
                    {
                        element.Measure(SizeF.Empty);
                    }
                    else
                    {
                        element.Measure(availableSize);
                    }

                    UVSize size5 = new UVSize(this.Orientation, flag ? itemWidth : element.DesiredSize.Width, flag2 ? itemHeight : element.DesiredSize.Height);
                    if (DoubleUtil.GreaterThan(size.U + size5.U, size3.U))
                    {
                        size2.U  = Math.Max(size.U, size2.U);
                        size2.V += size.V;
                        size     = size5;
                        if (DoubleUtil.GreaterThan(size5.U, size3.U))
                        {
                            size2.U  = Math.Max(size5.U, size2.U);
                            size2.V += size5.V;
                            size     = new UVSize(this.Orientation);
                        }
                    }
                    else
                    {
                        size.U += size5.U;
                        size.V  = Math.Max(size5.V, size.V);
                    }
                }
                num3++;
            }
            size2.U  = Math.Max(size.U, size2.U);
            size2.V += size.V;


            return(new SizeF(size2.Width, size2.Height));
        }
Example #6
0
 private GridTableElement FindTableElement(
   int index,
   RadElementCollection children)
 {
   for (int index1 = index; index1 < children.Count; ++index1)
   {
     if (children[index1] is GridTableElement)
       return (GridTableElement) children[index1];
   }
   return (GridTableElement) null;
 }
Example #7
0
        // Methods
        protected override SizeF ArrangeOverride(SizeF arrangeSize)
        {
            RadElementCollection children = base.Children;
            int   count = children.Count;
            int   effectiveChildrenCount = count - (this.LastChildFill ? 1 : 0);
            float x             = 0;
            float y             = 0;
            float elementWidth  = 0;
            float elementHeight = 0;

            for (int i = 0; i < count; i++)
            {
                RadElement element = children[i];
                if (element != null)
                {
                    SizeF      desiredSize = element.DesiredSize;
                    RectangleF finalRect   = new RectangleF(x, y,
                                                            Math.Max((float)0, (float)(arrangeSize.Width - (x + elementWidth))),
                                                            Math.Max((float)0, (float)(arrangeSize.Height - (y + elementHeight))));
                    if (i < effectiveChildrenCount)
                    {
                        switch (GetDock(element))
                        {
                        case Dock.Left:
                            x += desiredSize.Width;
                            finalRect.Width = desiredSize.Width;
                            break;

                        case Dock.Right:
                            elementWidth   += desiredSize.Width;
                            finalRect.X     = Math.Max((float)0, (float)(arrangeSize.Width - elementWidth));
                            finalRect.Width = desiredSize.Width;
                            break;

                        case Dock.Top:
                            y += desiredSize.Height;
                            finalRect.Height = desiredSize.Height;
                            break;

                        case Dock.Bottom:
                            elementHeight   += desiredSize.Height;
                            finalRect.Y      = Math.Max((float)0, (float)(arrangeSize.Height - elementHeight));
                            finalRect.Height = desiredSize.Height;
                            break;
                        }
                    }
                    element.Arrange(finalRect);
                }
            }
            return(arrangeSize);
        }
        protected override SizeF MeasureOverride(SizeF availableSize)
        {
            RadElementCollection children = this.Children;
            int   rows     = children.Count / this.columns;
            SizeF cellSize = availableSize;

            for (int i = 0; i < children.Count; i++)
            {
                RadElement child = children[i];
                child.Measure(cellSize);
            }

            return(new SizeF(this.columns * this.defaultCellSize.Width, rows * this.defaultCellSize.Height));
        }
Example #9
0
        protected override SizeF MeasureOverride(SizeF constraint)
        {
            float width;
            RadElementCollection internalChildren = this.Children;
            SizeF size          = new SizeF();
            SizeF availableSize = constraint;
            bool  flag          = this.Orientation == Orientation.Horizontal;

            if (flag)
            {
                availableSize.Width = float.PositiveInfinity;
                width = constraint.Width;
            }
            else
            {
                availableSize.Height = float.PositiveInfinity;
                width = constraint.Height;
            }
            int num5  = 0;
            int count = internalChildren.Count;

            while (num5 < count)
            {
                RadElement element = internalChildren[num5];
                if (element != null)
                {
                    float height;
                    element.Measure(availableSize);
                    SizeF desiredSize = Size.Empty;
                    if (element.Visibility == ElementVisibility.Visible)
                    {
                        desiredSize = element.DesiredSize;
                    }
                    if (flag)
                    {
                        size.Width += desiredSize.Width;
                        size.Height = Math.Max(size.Height, desiredSize.Height);
                        height      = desiredSize.Width;
                    }
                    else
                    {
                        size.Width   = Math.Max(size.Width, desiredSize.Width);
                        size.Height += desiredSize.Height;
                        height       = desiredSize.Height;
                    }
                }
                num5++;
            }
            return(size);
        }
Example #10
0
        protected override SizeF MeasureOverride(SizeF constraint)
        {
            RadCommandBarOverflowPanel.UVSize uvSize1 = new RadCommandBarOverflowPanel.UVSize(this.Orientation);
            RadCommandBarOverflowPanel.UVSize uvSize2 = new RadCommandBarOverflowPanel.UVSize(this.Orientation);
            RadCommandBarOverflowPanel.UVSize uvSize3 = new RadCommandBarOverflowPanel.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)
            {
                RadCommandBarBaseItem commandBarBaseItem = children[index] as RadCommandBarBaseItem;
                if (commandBarBaseItem != null)
                {
                    if (!commandBarBaseItem.VisibleInStrip)
                    {
                        commandBarBaseItem.Measure(SizeF.Empty);
                    }
                    else
                    {
                        commandBarBaseItem.Measure(availableSize);
                    }
                    RadCommandBarOverflowPanel.UVSize uvSize4 = new RadCommandBarOverflowPanel.UVSize(this.Orientation, flag1 ? itemWidth : commandBarBaseItem.DesiredSize.Width, flag2 ? itemHeight : commandBarBaseItem.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 RadCommandBarOverflowPanel.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));
        }
Example #11
0
        protected override SizeF ArrangeOverride(SizeF finalSize)
        {
            int    start      = 0;
            float  itemWidth  = this.ItemWidth;
            float  itemHeight = this.ItemHeight;
            float  v          = 0;
            float  itemU      = (this.Orientation == Orientation.Horizontal) ? itemWidth : itemHeight;
            float  totalSize  = (this.Orientation == Orientation.Horizontal) ? finalSize.Width : finalSize.Height;
            UVSize size       = new UVSize(this.Orientation);
            UVSize size2      = new UVSize(this.Orientation, finalSize.Width, finalSize.Height);
            bool   flag       = !float.IsNaN(itemWidth);
            bool   flag2      = !float.IsNaN(itemHeight);
            bool   useItemU   = (this.Orientation == Orientation.Horizontal) ? flag : flag2;
            RadElementCollection internalChildren = base.Children;
            int end   = 0;
            int count = internalChildren.Count;

            while (end < count)
            {
                RadElement element = internalChildren[end];
                if (element != null)
                {
                    UVSize size3 = new UVSize(this.Orientation, flag ? itemWidth : element.DesiredSize.Width, flag2 ? itemHeight : element.DesiredSize.Height);
                    if (DoubleUtil.GreaterThan(size.U + size3.U, size2.U))
                    {
                        this.ArrangeLine(v, size.V, start, end, useItemU, itemU, totalSize);
                        v   += size.V;
                        size = size3;
                        if (DoubleUtil.GreaterThan(size3.U, size2.U))
                        {
                            this.ArrangeLine(v, size3.V, end, ++end, useItemU, itemU, totalSize);
                            v   += size3.V;
                            size = new UVSize(this.Orientation);
                        }
                        start = end;
                    }
                    else
                    {
                        size.U += size3.U;
                        size.V  = Math.Max(size3.V, size.V);
                    }
                }
                end++;
            }
            if (start < internalChildren.Count)
            {
                this.ArrangeLine(v, size.V, start, internalChildren.Count, useItemU, itemU, totalSize);
            }
            return(finalSize);
        }
Example #12
0
        protected override SizeF ArrangeOverride(SizeF arrangeSize)
        {
            RadElementCollection children = this.Children;
            int   count = children.Count;
            int   num1  = count - (this.LastChildFill ? 1 : 0);
            float x     = 0.0f;
            float y     = 0.0f;
            float num2  = 0.0f;
            float num3  = 0.0f;

            for (int index = 0; index < count; ++index)
            {
                RadElement element = children[index];
                if (element != null)
                {
                    SizeF      desiredSize = element.DesiredSize;
                    RectangleF finalRect   = new RectangleF(x, y, Math.Max(0.0f, arrangeSize.Width - (x + num2)), Math.Max(0.0f, arrangeSize.Height - (y + num3)));
                    if (index < num1)
                    {
                        switch (DockLayoutPanel.GetDock(element))
                        {
                        case Dock.Left:
                            x += desiredSize.Width;
                            finalRect.Width = desiredSize.Width;
                            break;

                        case Dock.Top:
                            y += desiredSize.Height;
                            finalRect.Height = desiredSize.Height;
                            break;

                        case Dock.Right:
                            num2           += desiredSize.Width;
                            finalRect.X     = Math.Max(0.0f, arrangeSize.Width - num2);
                            finalRect.Width = desiredSize.Width;
                            break;

                        case Dock.Bottom:
                            num3            += desiredSize.Height;
                            finalRect.Y      = Math.Max(0.0f, arrangeSize.Height - num3);
                            finalRect.Height = desiredSize.Height;
                            break;
                        }
                    }
                    element.Arrange(finalRect);
                }
            }
            return(arrangeSize);
        }
Example #13
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);
        }
Example #14
0
        protected virtual bool EnsureRowVisibleByTraverser(
            RadScrollBarElement vScrollBar,
            GridViewRowInfo rowInfo,
            float delta)
        {
            ScrollableRowsContainerElement scrollableRows = this.ViewElement.ScrollableRows;
            RadElementCollection           children       = scrollableRows.Children;
            int num1 = vScrollBar.Maximum - vScrollBar.LargeChange + 1;

            while (vScrollBar.Maximum != 0 && children.Count == 0)
            {
                this.ChangeScrollbarValue(vScrollBar, vScrollBar.Value + 1);
                this.UpdateLayout();
                if (scrollableRows.Children.Count > 0 || vScrollBar.Value == num1 || vScrollBar.Value == vScrollBar.Maximum)
                {
                    break;
                }
            }
            if (children.Count == 0)
            {
                return(false);
            }
            if (this.EnsureRowVisibleByTraverserDown(vScrollBar, rowInfo, scrollableRows, delta))
            {
                return(true);
            }
            GridRowElement child = (GridRowElement)scrollableRows.Children[0];

            if (((GridTraverser)((IEnumerable)this.RowScroller).GetEnumerator()).Current == rowInfo)
            {
                int num2 = vScrollBar.Value - (int)delta;
                if (num2 < vScrollBar.Minimum)
                {
                    num2 = vScrollBar.Minimum;
                }
                else if (num2 > vScrollBar.Maximum)
                {
                    num2 = vScrollBar.Maximum;
                }
                return(this.ChangeScrollbarValue(vScrollBar, num2));
            }
            GridViewGroupRowInfo parent = rowInfo.Parent as GridViewGroupRowInfo;

            if (parent != null && !parent.IsExpanded)
            {
                return(false);
            }
            return(this.RowScroller.ScrollToItem(rowInfo, false));
        }
Example #15
0
        protected List <TreeNodeElement> GetAssociatedNodes(RadTreeNode node)
        {
            List <TreeNodeElement> treeNodeElementList = new List <TreeNodeElement>();
            RadElementCollection   children            = this.TreeViewElement.ViewElement.Children;

            for (int index = 0; index < children.Count; ++index)
            {
                TreeNodeElement treeNodeElement = children[index] as TreeNodeElement;
                if (this.IsHierarchyChild(node, treeNodeElement.Data))
                {
                    treeNodeElementList.Add(treeNodeElement);
                }
            }
            return(treeNodeElementList);
        }
Example #16
0
        protected List <TreeNodeElement> GetAssociatedNodes(RadTreeNode node)
        {
            List <TreeNodeElement> list = new List <TreeNodeElement>();

            RadElementCollection nodes = this.TreeViewElement.ViewElement.Children;

            for (int i = 0; i < nodes.Count; i++)
            {
                TreeNodeElement child = nodes[i] as TreeNodeElement;
                if (this.IsHierarchyChild(node, child.Data))
                {
                    list.Add(child);
                }
            }

            return(list);
        }
Example #17
0
        protected override SizeF MeasureOverride(SizeF constraint)
        {
            RadElementCollection children = this.Children;
            SizeF sizeF1        = new SizeF();
            SizeF availableSize = constraint;
            bool  flag          = this.Orientation == Orientation.Horizontal;

            if (flag)
            {
                availableSize.Width = float.PositiveInfinity;
                double width = (double)constraint.Width;
            }
            else
            {
                availableSize.Height = float.PositiveInfinity;
                double height = (double)constraint.Height;
            }
            int index = 0;

            for (int count = children.Count; index < count; ++index)
            {
                RadElement radElement = children[index];
                if (radElement != null)
                {
                    radElement.Measure(availableSize);
                    SizeF sizeF2 = (SizeF)Size.Empty;
                    if (radElement.Visibility == ElementVisibility.Visible)
                    {
                        sizeF2 = radElement.DesiredSize;
                    }
                    if (flag)
                    {
                        sizeF1.Width += sizeF2.Width;
                        sizeF1.Height = Math.Max(sizeF1.Height, sizeF2.Height);
                        double width = (double)sizeF2.Width;
                    }
                    else
                    {
                        sizeF1.Width   = Math.Max(sizeF1.Width, sizeF2.Width);
                        sizeF1.Height += sizeF2.Height;
                        double height = (double)sizeF2.Height;
                    }
                }
            }
            return(sizeF1);
        }
Example #18
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));
        }
Example #19
0
        private void ArrangeLine(float VPosition, float lineV, int start, int end, bool useItemU, float itemU, float totalU)
        {
            float currentUPosition = 0;
            bool  isHorizontal     = this.Orientation == Orientation.Horizontal;
            RadElementCollection internalChildren = base.Children;
            float stretchedItemU = 0;

            if (this.stretchItems)
            {
                stretchedItemU = DetermineStretchedItemU(start, end, internalChildren, totalU);
            }

            for (int i = start; i < end; i++)
            {
                RadElement element = internalChildren[i];
                if (element != null)
                {
                    UVSize size        = new UVSize(this.Orientation, element.DesiredSize.Width, element.DesiredSize.Height);
                    float  actualItemU = useItemU ? itemU : size.U;

                    if (this.stretchItems && element.Visibility != ElementVisibility.Collapsed && actualItemU < stretchedItemU)
                    {
                        actualItemU = stretchedItemU;
                    }

                    RectangleF rect = new RectangleF(isHorizontal ? currentUPosition : VPosition,
                                                     isHorizontal ? VPosition : currentUPosition,
                                                     isHorizontal ? actualItemU : lineV,
                                                     isHorizontal ? lineV : actualItemU);
                    if (this.RightToLeft)
                    {
                        if (isHorizontal)
                        {
                            rect.X = totalU - rect.X - rect.Width;
                        }
                    }

                    element.Arrange(rect);
                    currentUPosition += actualItemU;
                }
            }
        }
Example #20
0
        protected override SizeF MeasureOverride(SizeF constraint)
        {
            RadElementCollection children = base.Children;
            float horizontalElementWidth  = 0;
            float verticalElementWidth    = 0;
            float usedWidth  = 0;
            float usedHeight = 0;
            int   childIndex = 0;
            int   childCount = children.Count;

            while (childIndex < childCount)
            {
                RadElement element = children[childIndex];
                if (element != null)
                {
                    SizeF availableSize = new SizeF(
                        Math.Max((float)0, (float)(constraint.Width - usedWidth)),
                        Math.Max((float)0, (float)(constraint.Height - usedHeight))
                        );

                    element.Measure(availableSize);
                    SizeF desiredSize = element.DesiredSize;
                    switch (GetDock(element))
                    {
                    case Dock.Left:
                    case Dock.Right:
                        verticalElementWidth = Math.Max(verticalElementWidth, usedHeight + desiredSize.Height);
                        usedWidth           += desiredSize.Width;
                        break;

                    case Dock.Top:
                    case Dock.Bottom:
                        horizontalElementWidth = Math.Max(horizontalElementWidth, usedWidth + desiredSize.Width);
                        usedHeight            += desiredSize.Height;
                        break;
                    }
                }
                childIndex++;
            }
            horizontalElementWidth = Math.Max(horizontalElementWidth, usedWidth);
            return(new SizeF(horizontalElementWidth, Math.Max(verticalElementWidth, usedHeight)));
        }
Example #21
0
        private RadListDataItem GetSelectedOrHoveredItem()
        {
            RadListDataItem      hoveredItem = null;
            RadElementCollection items       = this.ownerDropDownListElement.ListElement.ViewElement.Children;

            foreach (RadListVisualItem item in items)
            {
                if (item.Selected && item.Data.RowIndex != this.ownerDropDownListElement.selectedIndexOnPopupOpen)
                {
                    return(item.Data);
                }

                if (item.IsMouseOver)
                {
                    hoveredItem = item.Data;
                }
            }

            return(hoveredItem);
        }
        protected virtual RadListDataItem GetFullyVisibleItem(bool firstItem)
        {
            RadElementCollection children = this.ViewElement.Children;

            if (children.Count > 0)
            {
                int index = firstItem ? 0 : children.Count - 1;
                RadListVisualItem radListVisualItem;
                do
                {
                    radListVisualItem = children[index] as RadListVisualItem;
                    index             = firstItem ? index + 1 : index - 1;
                }while (this.IsItemPartiallyVisible(radListVisualItem) && index < children.Count && index >= 0);
                if (!this.IsItemPartiallyVisible(radListVisualItem))
                {
                    return(radListVisualItem.Data);
                }
            }
            return((RadListDataItem)null);
        }
Example #23
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;
                }
            }
        }
Example #24
0
        protected override SizeF MeasureOverride(SizeF constraint)
        {
            RadElementCollection children = this.Children;
            float val1_1 = 0.0f;
            float val1_2 = 0.0f;
            float val2_1 = 0.0f;
            float val2_2 = 0.0f;
            int   index  = 0;

            for (int count = children.Count; index < count; ++index)
            {
                RadElement element = children[index];
                if (element != null)
                {
                    SizeF availableSize = new SizeF(Math.Max(0.0f, constraint.Width - val2_1), Math.Max(0.0f, constraint.Height - val2_2));
                    element.Measure(availableSize);
                    SizeF desiredSize = element.DesiredSize;
                    switch (DockLayoutPanel.GetDock(element))
                    {
                    case Dock.Left:
                    case Dock.Right:
                        val1_2  = Math.Max(val1_2, val2_2 + desiredSize.Height);
                        val2_1 += desiredSize.Width;
                        continue;

                    case Dock.Top:
                    case Dock.Bottom:
                        val1_1  = Math.Max(val1_1, val2_1 + desiredSize.Width);
                        val2_2 += desiredSize.Height;
                        continue;

                    default:
                        continue;
                    }
                }
            }
            return(new SizeF(Math.Max(val1_1, val2_1), Math.Max(val1_2, val2_2)));
        }
Example #25
0
        public static IEnumerable <RadElement> TraverseElements(RadElement rootElement, bool includeRootElement)
        {
            if (includeRootElement)
            {
                yield return(rootElement);
            }

            if (rootElement.Children.Count > 0)
            {
                Stack parentIndexes = new Stack();

                RadElementCollection children = rootElement.Children;
                int  depth              = 1;
                int  currIndex          = 0;
                bool traversingChildren = true;
                do
                {
                    if (currIndex >= children.Count)
                    {
                        depth -= 1;
                        if (depth > 0)
                        {
                            RadElement parent = children.Owner.Parent;
                            if (parent != null)
                            {
                                currIndex          = (int)parentIndexes.Pop();
                                children           = parent.Children;
                                traversingChildren = false;
                            }
                        }
                    }
                    else
                    {
                        RadElement child      = children[currIndex];
                        StyleSheet childStyle = child.Style;

                        if (traversingChildren)
                        {
                            if (child.PropagateStyleToChildren &&
                                (childStyle == null || !child.ElementThemeAffectsChildren) &&
                                child.Children.Count > 0)
                            {
                                parentIndexes.Push(currIndex);
                                children  = child.Children;
                                currIndex = 0;
                                depth++;
                                continue;
                            }
                        }

                        if (childStyle == null)
                        {
                            yield return(child);
                        }

                        currIndex++;
                        traversingChildren = true;
                    }
                }while (depth > 0);
            }
        }
Example #26
0
        protected override SizeF MeasureOverride(SizeF constraint)
        {
            RadElementCollection internalChildren = this.Children;
            int  count        = internalChildren.Count;
            bool isHorizontal = this.Orientation == Orientation.Horizontal;

            // Get the available size that will be given to children's Measure()
            //
            SizeF availableSize = constraint;

            if (isHorizontal)
            {
                availableSize.Width = float.PositiveInfinity;
            }
            else
            {
                availableSize.Height = float.PositiveInfinity;
            }

            // Call Measure() for each child
            //
            for (int i = 0; i < count; i++)
            {
                RadElement element = internalChildren[i];
                element.Measure(availableSize);
            }

            // Get desired children size if EqualChildrenHeight or EqualChildrenWidth is used
            //
            SizeF maxDesiredChildrenSize = SizeF.Empty;
            bool  equalChildrenHeight    = this.EqualChildrenHeight;
            bool  equalChildrenWidth     = this.EqualChildrenWidth;

            if (equalChildrenHeight || equalChildrenWidth)
            {
                for (int i = 0; i < count; i++)
                {
                    RadElement element = internalChildren[i];
                    if (equalChildrenHeight)
                    {
                        maxDesiredChildrenSize.Height = Math.Max(element.DesiredSize.Height, maxDesiredChildrenSize.Height);
                    }
                    if (equalChildrenWidth)
                    {
                        maxDesiredChildrenSize.Width = Math.Max(element.DesiredSize.Width, maxDesiredChildrenSize.Width);
                    }
                }
            }

            // Calculate the own desired size based on children's DesiredSize
            //
            SizeF res = SizeF.Empty;

            for (int i = 0; i < count; i++)
            {
                RadElement element     = internalChildren[i];
                SizeF      desiredSize = element.DesiredSize;
                if (equalChildrenHeight)
                {
                    desiredSize.Height = maxDesiredChildrenSize.Height;
                }
                if (equalChildrenWidth)
                {
                    desiredSize.Width = maxDesiredChildrenSize.Width;
                }

                if (isHorizontal)
                {
                    res.Width += desiredSize.Width;
                    res.Height = Math.Max(res.Height, desiredSize.Height);
                }
                else
                {
                    res.Width   = Math.Max(res.Width, desiredSize.Width);
                    res.Height += desiredSize.Height;
                }
            }
            return(res);
        }
Example #27
0
        /// <summary>
        /// ArrangeOverride
        /// </summary>
        /// <param name="arrangeSize"></param>
        /// <returns></returns>
        protected override SizeF ArrangeOverride(SizeF arrangeSize)
        {
            RadElementCollection children = this.Children;
            int count = children.Count;

            // Get desired children size if EqualChildrenHeight or EqualChildrenWidth is used
            // ********************************************************* //
            SizeF maxDesiredChildrenSize = SizeF.Empty;
            bool  equalChildrenHeight    = this.EqualChildrenHeight;
            bool  equalChildrenWidth     = this.EqualChildrenWidth;

            if (equalChildrenHeight || equalChildrenWidth)
            {
                for (int i = 0; i < count; i++)
                {
                    RadElement element = children[i];
                    if (equalChildrenHeight)
                    {
                        maxDesiredChildrenSize.Height = Math.Max(element.DesiredSize.Height, maxDesiredChildrenSize.Height);
                    }
                    if (equalChildrenWidth)
                    {
                        maxDesiredChildrenSize.Width = Math.Max(element.DesiredSize.Width, maxDesiredChildrenSize.Width);
                    }
                }
            }

            // Parameters
            // ********************************************************* //
            bool isHorizontal  = this.Orientation == Orientation.Horizontal;
            bool isRightToLeft = this.RightToLeft;

            float      length    = 0;
            RectangleF finalRect = new RectangleF(PointF.Empty, arrangeSize);

            if (isHorizontal && isRightToLeft)
            {
                finalRect.X = arrangeSize.Width;
            }

            // Main loop that does the actual arrangement of the children
            // ********************************************************* //
            for (int i = 0; i < count; i++)
            {
                RadElement element = children[i];

                SizeF childArea = element.DesiredSize;
                if (element.Visibility == ElementVisibility.Collapsed)
                {
                    element.Arrange(new RectangleF(PointF.Empty, childArea));
                    continue;
                }

                // ** 1. Calculate the ChildArea
                if (equalChildrenHeight)
                {
                    if (isHorizontal)
                    {
                        childArea.Height = Math.Max(arrangeSize.Height, maxDesiredChildrenSize.Height);
                    }
                    else
                    {
                        childArea.Height = maxDesiredChildrenSize.Height;
                    }
                }
                if (equalChildrenWidth)
                {
                    if (isHorizontal)
                    {
                        childArea.Width = maxDesiredChildrenSize.Width;
                    }
                    else
                    {
                        childArea.Width = Math.Max(arrangeSize.Width, maxDesiredChildrenSize.Width);
                    }
                }

                // ** 2. Calculate the location and size (finalRect) that will be passed to the child's Arrange
                if (isHorizontal)
                {
                    if (isRightToLeft)
                    {
                        length       = childArea.Width;
                        finalRect.X -= length;
                    }
                    else
                    {
                        finalRect.X += length;
                        length       = childArea.Width;
                    }

                    finalRect.Width = length;
                    if (equalChildrenHeight)
                    {
                        SizeF arrangeArea = finalRect.Size;
                        finalRect.Height = childArea.Height;

                        // Compensate the alignment for EqualChildrenHeight because the basic logic will be bypassed
                        // by the size forcing
                        // Note that the vertical alignment is not affected by RightToLeft...
                        RectangleF alignedRect = LayoutUtils.Align(finalRect.Size, new RectangleF(PointF.Empty, arrangeArea), this.Alignment);
                        finalRect.Y += alignedRect.Y;
                    }
                    else
                    {
                        finalRect.Height = arrangeSize.Height;// Math.Max(arrangeSize.Height, childArea.Height);
                    }
                }
                else
                {
                    finalRect.Y     += length;
                    length           = childArea.Height;
                    finalRect.Height = length;
                    if (equalChildrenWidth)
                    {
                        SizeF arrangeArea = finalRect.Size;
                        finalRect.Width = childArea.Width;

                        // Compensate the alignment for EqualChildrenHeight because the basic logic will be bypassed
                        // by the size forcing
                        // Note that the horizontal alignment is translated if RightToLeft is true.
                        ContentAlignment alignment   = isRightToLeft ? TelerikAlignHelper.RtlTranslateContent(this.Alignment) : this.Alignment;
                        RectangleF       alignedRect = LayoutUtils.Align(finalRect.Size, new RectangleF(PointF.Empty, arrangeArea), alignment);
                        finalRect.X += alignedRect.X;
                    }
                    else
                    {
                        finalRect.Width = arrangeSize.Width;// Math.Max(arrangeSize.Width, childArea.Width);
                    }
                }

                // ** 3. Arrange the child
                element.Arrange(finalRect);
            }

            return(arrangeSize);
        }
Example #28
0
        public void BeginAutoSizeRowArrange(RadElementCollection cells)
        {
            List <float> floatList1 = new List <float>();
            int          val1_1     = 0;
            int          val1_2     = 0;
            Dictionary <GridViewColumn, ColumnGroupsCellArrangeInfo> columnsData = this.tree.GetColumnsData();

            foreach (RadElement cell in cells)
            {
                GridCellElement gridCellElement = cell as GridCellElement;
                if (gridCellElement != null && columnsData.ContainsKey(gridCellElement.ColumnInfo))
                {
                    ColumnGroupsCellArrangeInfo groupsCellArrangeInfo = columnsData[gridCellElement.ColumnInfo];
                    if (gridCellElement.ColumnInfo is GridViewGroupColumn)
                    {
                        if (this.HasVisibleColumn(((GridViewGroupColumn)gridCellElement.ColumnInfo).Group))
                        {
                            val1_1 = Math.Max(val1_1, groupsCellArrangeInfo.Depth);
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        val1_2 = Math.Max(val1_2, groupsCellArrangeInfo.Depth);
                    }
                    while (floatList1.Count <= groupsCellArrangeInfo.Depth)
                    {
                        floatList1.Add(0.0f);
                    }
                    floatList1[groupsCellArrangeInfo.Depth] = Math.Max(floatList1[groupsCellArrangeInfo.Depth], gridCellElement.DesiredSize.Height);
                }
            }
            if (floatList1.Count == 0)
            {
                return;
            }
            List <float> floatList2 = new List <float>();

            floatList2.Add(floatList1[0]);
            for (int index = 1; index < floatList1.Count; ++index)
            {
                floatList2.Add(floatList2[index - 1] + floatList1[index]);
            }
            foreach (RadElement cell in cells)
            {
                GridCellElement gridCellElement = cell as GridCellElement;
                if (gridCellElement != null && columnsData.ContainsKey(gridCellElement.ColumnInfo))
                {
                    ColumnGroupsCellArrangeInfo groupsCellArrangeInfo = columnsData[gridCellElement.ColumnInfo];
                    groupsCellArrangeInfo.Bounds.Height = floatList1[groupsCellArrangeInfo.Depth];
                    groupsCellArrangeInfo.Bounds.Y      = floatList2[groupsCellArrangeInfo.Depth - 1];
                    if (gridCellElement.ColumnInfo is GridViewGroupColumn)
                    {
                        if (((GridViewGroupColumn)gridCellElement.ColumnInfo).Group.Groups.Count == 0)
                        {
                            groupsCellArrangeInfo.Bounds.Height = floatList2[val1_1] - floatList2[groupsCellArrangeInfo.Depth - 1];
                        }
                    }
                    else if (groupsCellArrangeInfo.RowIndex == groupsCellArrangeInfo.Group.Rows.Count - 1)
                    {
                        groupsCellArrangeInfo.Bounds.Height = floatList2[val1_2] - floatList2[groupsCellArrangeInfo.Depth - 1];
                    }
                }
            }
            foreach (KeyValuePair <GridViewColumn, ColumnGroupsCellArrangeInfo> keyValuePair in this.tree.GetSystemColumnsData())
            {
                keyValuePair.Value.Bounds.Height = floatList2[floatList2.Count - 1];
                columnsData.Add(keyValuePair.Key, keyValuePair.Value);
            }
            this.currentAutoSizeArrangeInfo = columnsData;
        }
Example #29
0
        protected override SizeF ArrangeOverride(SizeF arrangeSize)
        {
            RadElementCollection children = this.Children;
            int   count = children.Count;
            SizeF empty = SizeF.Empty;
            bool  equalChildrenHeight = this.EqualChildrenHeight;
            bool  equalChildrenWidth  = this.EqualChildrenWidth;

            if (equalChildrenHeight || equalChildrenWidth)
            {
                for (int index = 0; index < count; ++index)
                {
                    RadElement radElement = children[index];
                    if (equalChildrenHeight)
                    {
                        empty.Height = Math.Max(radElement.DesiredSize.Height, empty.Height);
                    }
                    if (equalChildrenWidth)
                    {
                        empty.Width = Math.Max(radElement.DesiredSize.Width, empty.Width);
                    }
                }
            }
            bool       flag        = this.Orientation == Orientation.Horizontal;
            bool       rightToLeft = this.RightToLeft;
            float      num         = 0.0f;
            RectangleF finalRect   = new RectangleF(PointF.Empty, arrangeSize);

            if (flag && rightToLeft)
            {
                finalRect.X = arrangeSize.Width;
            }
            for (int index = 0; index < count; ++index)
            {
                RadElement radElement  = children[index];
                SizeF      desiredSize = radElement.DesiredSize;
                if (radElement.Visibility == ElementVisibility.Collapsed)
                {
                    radElement.Arrange(new RectangleF(PointF.Empty, desiredSize));
                }
                else
                {
                    if (equalChildrenHeight)
                    {
                        desiredSize.Height = !flag ? empty.Height : Math.Max(arrangeSize.Height, empty.Height);
                    }
                    if (equalChildrenWidth)
                    {
                        desiredSize.Width = !flag?Math.Max(arrangeSize.Width, empty.Width) : empty.Width;
                    }
                    if (flag)
                    {
                        if (rightToLeft)
                        {
                            num          = desiredSize.Width;
                            finalRect.X -= num;
                        }
                        else
                        {
                            finalRect.X += num;
                            num          = desiredSize.Width;
                        }
                        finalRect.Width = num;
                        if (equalChildrenHeight)
                        {
                            SizeF size = finalRect.Size;
                            finalRect.Height = desiredSize.Height;
                            RectangleF rectangleF = LayoutUtils.Align(finalRect.Size, new RectangleF(PointF.Empty, size), this.Alignment);
                            finalRect.Y += rectangleF.Y;
                        }
                        else
                        {
                            finalRect.Height = arrangeSize.Height;
                        }
                    }
                    else
                    {
                        finalRect.Y     += num;
                        num              = desiredSize.Height;
                        finalRect.Height = num;
                        if (equalChildrenWidth)
                        {
                            SizeF size = finalRect.Size;
                            finalRect.Width = desiredSize.Width;
                            ContentAlignment align      = rightToLeft ? TelerikAlignHelper.RtlTranslateContent(this.Alignment) : this.Alignment;
                            RectangleF       rectangleF = LayoutUtils.Align(finalRect.Size, new RectangleF(PointF.Empty, size), align);
                            finalRect.X += rectangleF.X;
                        }
                        else
                        {
                            finalRect.Width = arrangeSize.Width;
                        }
                    }
                    radElement.Arrange(finalRect);
                }
            }
            return(arrangeSize);
        }
Example #30
0
        protected override SizeF MeasureOverride(SizeF constraint)
        {
            RadElementCollection children = this.Children;
            int   count         = children.Count;
            bool  flag          = this.Orientation == Orientation.Horizontal;
            SizeF availableSize = constraint;

            if (flag)
            {
                availableSize.Width = float.PositiveInfinity;
            }
            else
            {
                availableSize.Height = float.PositiveInfinity;
            }
            for (int index = 0; index < count; ++index)
            {
                children[index].Measure(availableSize);
            }
            SizeF empty1 = SizeF.Empty;
            bool  equalChildrenHeight = this.EqualChildrenHeight;
            bool  equalChildrenWidth  = this.EqualChildrenWidth;

            if (equalChildrenHeight || equalChildrenWidth)
            {
                for (int index = 0; index < count; ++index)
                {
                    RadElement radElement = children[index];
                    if (equalChildrenHeight)
                    {
                        empty1.Height = Math.Max(radElement.DesiredSize.Height, empty1.Height);
                    }
                    if (equalChildrenWidth)
                    {
                        empty1.Width = Math.Max(radElement.DesiredSize.Width, empty1.Width);
                    }
                }
            }
            SizeF empty2 = SizeF.Empty;

            for (int index = 0; index < count; ++index)
            {
                SizeF desiredSize = children[index].DesiredSize;
                if (equalChildrenHeight)
                {
                    desiredSize.Height = empty1.Height;
                }
                if (equalChildrenWidth)
                {
                    desiredSize.Width = empty1.Width;
                }
                if (flag)
                {
                    empty2.Width += desiredSize.Width;
                    empty2.Height = Math.Max(empty2.Height, desiredSize.Height);
                }
                else
                {
                    empty2.Width   = Math.Max(empty2.Width, desiredSize.Width);
                    empty2.Height += desiredSize.Height;
                }
            }
            return(empty2);
        }