本文整理汇总了C#中System.Windows.Rect.Deflate方法的典型用法代码示例。如果您正苦于以下问题:C# Rect.Deflate方法的具体用法?C# Rect.Deflate怎么用?C# Rect.Deflate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Rect
的用法示例。
在下文中一共展示了Rect.Deflate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArrangeOverride
/// <summary>
/// ClipBorder computes the position of its single child and applies its child's alignments to the child.
///
/// </summary>
/// <param name="finalSize">The size reserved for this element by the parent</param>
/// <returns>The actual ink area of the element, typically the same as finalSize</returns>
protected override Size ArrangeOverride(Size finalSize)
{
var borders = BorderThickness;
var boundRect = new Rect(finalSize);
var innerRect = boundRect.Deflate(borders);
var corners = CornerRadius;
var padding = Padding;
var childRect = innerRect.Deflate(padding);
// calculate border rendering geometry
if (!boundRect.Width.IsZero() && !boundRect.Height.IsZero())
{
var outerBorderInfo = new BorderInfo(corners, borders, new Thickness(), true);
var borderGeometry = new StreamGeometry();
using (var ctx = borderGeometry.Open())
{
GenerateGeometry(ctx, boundRect, outerBorderInfo);
}
// Freeze the geometry for better perfomance
borderGeometry.Freeze();
_borderGeometryCache = borderGeometry;
}
else
{
_borderGeometryCache = null;
}
// calculate background rendering geometry
if (!innerRect.Width.IsZero() && !innerRect.Height.IsZero())
{
var innerBorderInfo = new BorderInfo(corners, borders, new Thickness(), false);
var backgroundGeometry = new StreamGeometry();
using (var ctx = backgroundGeometry.Open())
{
GenerateGeometry(ctx, innerRect, innerBorderInfo);
}
// Freeze the geometry for better perfomance
backgroundGeometry.Freeze();
_backgroundGeometryCache = backgroundGeometry;
}
else
{
_backgroundGeometryCache = null;
}
// Arrange the Child and set its clip
var child = Child;
if (child != null)
{
child.Arrange(childRect);
// Calculate the Clipping Geometry
var clipGeometry = new StreamGeometry();
var childBorderInfo = new BorderInfo(corners, borders, padding, false);
using (var ctx = clipGeometry.Open())
{
GenerateGeometry(ctx, new Rect(0, 0, childRect.Width, childRect.Height), childBorderInfo);
}
// Freeze the geometry for better perfomance
clipGeometry.Freeze();
// Apply the clip to the Child
child.Clip = clipGeometry;
}
return finalSize;
}