本文整理汇总了C#中System.Windows.Rect.Translate方法的典型用法代码示例。如果您正苦于以下问题:C# Rect.Translate方法的具体用法?C# Rect.Translate怎么用?C# Rect.Translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Rect
的用法示例。
在下文中一共展示了Rect.Translate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MeasureOverride
/// <summary>
/// When overridden in a derived class, measures the size in layout required for child elements and determines a size for the <see cref="T:System.Windows.FrameworkElement" />-derived class.
/// </summary>
/// <param name="availableSize">The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.</param>
/// <returns>
/// The size that this element determines it needs during layout, based on its calculations of child element sizes.
/// </returns>
protected override Size MeasureOverride(Size availableSize)
{
var worldLayer = World;
var viewportLayer = this;
if (worldLayer == null)
return new Size();
foreach (UIElement child in InternalChildren)
{
if (child == null)
continue;
var left = GetLeft(child);
var top = GetTop(child);
var right = GetRight(child);
var bottom = GetBottom(child);
var rect = new Rect(0, 0, Math.Abs(right - left), Math.Abs(bottom - top));
var constraint = rect.Translate(worldLayer, viewportLayer).Size;
if (double.IsNaN(constraint.Width))
constraint.Width = double.PositiveInfinity;
if (double.IsNaN(constraint.Height))
constraint.Height = double.PositiveInfinity;
child.Measure(constraint);
}
return new Size();
}