本文整理汇总了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);
}