当前位置: 首页>>代码示例>>C#>>正文


C# ILayoutElement.SetLayoutBoundsPosition方法代码示例

本文整理汇总了C#中ILayoutElement.SetLayoutBoundsPosition方法的典型用法代码示例。如果您正苦于以下问题:C# ILayoutElement.SetLayoutBoundsPosition方法的具体用法?C# ILayoutElement.SetLayoutBoundsPosition怎么用?C# ILayoutElement.SetLayoutBoundsPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILayoutElement的用法示例。


在下文中一共展示了ILayoutElement.SetLayoutBoundsPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: calculateDisplayParameters


//.........这里部分代码省略.........
         *  increase, the new visibleStart,EndIndex values will be greater than or
         *  equal to the old ones. 
         */
         /*private void updateVirtualLayout(int unscaledWidth, int unscaledHeight)
         {
            int oldVisibleStartIndex = _visibleStartIndex;
            int oldVisibleEndIndex = _visibleEndIndex;
            calculateDisplayParameters(unscaledWidth, unscaledHeight);  // compute new visibleStart,EndIndex values
            
            // We're responsible for laying out *all* of the elements requested
            // with getVirtualElementAt(), even if they don't fall within the final
            // visible range.  Hide any extra ones.  On the next layout pass, they'll
            // be added to DataGroup::freeRenderers
            
            GroupBase layoutTarget = Target;
            for (int i = oldVisibleStartIndex; i <= oldVisibleEndIndex; i++)
            {
                if ((i >= _visibleStartIndex) && (i <= _visibleEndIndex)) // skip past the visible range
                {
                    i = _visibleEndIndex;
                    continue;
                } 
                //ILayoutElement el = layoutTarget.getVirtualElementAt(i);
                //if (null == el)
                //    continue;
                //el.setLayoutBoundsSize(0, 0);
                //if (el is IVisualElement)
                //    IVisualElement(el).visible = false; 
            }
        } */

        /**
         *  Sets the size and the position of the specified layout element and cell bounds.
         *  Param: element - the element to resize and position.
         *  Param: cellX - the x coordinate of the cell.
         *  Param: cellY - the y coordinate of the cell.
         *  Param: cellWidth - the width of the cell.
         *  Param: cellHeight - the height of the cell.
         */
        private void sizeAndPositionElement(ILayoutElement element,
                                                  int cellX,
                                                  int cellY,
                                                  int cellWidth,
                                                  int cellHeight)
        {
            float childWidth;
            float childHeight;

            // Determine size of the element
            if (_horizontalAlign == HorizontalAlign.Justify)
                childWidth = cellWidth;
            else if (null != element.PercentWidth)
                childWidth = Mathf.Round((float) (cellWidth * element.PercentWidth * 0.01f));
            else
                childWidth = LayoutUtil.GetPreferredBoundsWidth((InvalidationManagerClient) element);

            if (_verticalAlign == global::eDriven.Gui.Layout.VerticalAlign.Justify)
                childHeight = cellHeight;
            else if (null != element.PercentHeight)
                childHeight = Mathf.Round((float) (cellHeight * element.PercentHeight * 0.01f));
            else
                childHeight = LayoutUtil.GetPreferredBoundsHeight((InvalidationManagerClient) element);

            // Enforce min and max limits
            float maxChildWidth = Math.Min(LayoutUtil.GetMaxBoundsWidth((InvalidationManagerClient) element), cellWidth);
            float maxChildHeight = Math.Min(LayoutUtil.GetMaxBoundsHeight((InvalidationManagerClient) element), cellHeight);
            // Make sure we enforce element's minimum last, since it has the highest priority
            childWidth = Math.Max(LayoutUtil.GetMinBoundsWidth((InvalidationManagerClient) element), Math.Min(maxChildWidth, childWidth));
            childHeight = Math.Max(LayoutUtil.GetMinBoundsHeight((InvalidationManagerClient) element), Math.Min(maxChildHeight, childHeight));

            // Size the element
            element.SetLayoutBoundsSize(childWidth, childHeight);

            float x = cellX;
            switch (_horizontalAlign)
            {
                case HorizontalAlign.Right:
                    x += cellWidth - LayoutUtil.GetLayoutBoundsWidth((InvalidationManagerClient) element);
                break;
                case HorizontalAlign.Center:
                    // Make sure division result is integer - Math.floor() the result.
                    x = cellX + Mathf.Floor((cellWidth - LayoutUtil.GetLayoutBoundsWidth((InvalidationManagerClient) element)) / 2);
                break;
            }

            float y = cellY;
            switch (_verticalAlign)
            {
                case VerticalAlign.Bottom:
                    y += cellHeight - LayoutUtil.GetLayoutBoundsHeight((InvalidationManagerClient)element);
                break;
                case VerticalAlign.Middle:
                    // Make sure division result is integer - Math.floor() the result.
                y += Mathf.Floor((cellHeight - LayoutUtil.GetLayoutBoundsHeight((InvalidationManagerClient) element)) / 2);
                break;
            }

            // Position the element
            element.SetLayoutBoundsPosition(x, y);
        }
开发者ID:groov0v,项目名称:edriven-gui,代码行数:101,代码来源:TileLayout.cs


注:本文中的ILayoutElement.SetLayoutBoundsPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。