本文整理汇总了C#中Size.Inflate方法的典型用法代码示例。如果您正苦于以下问题:C# Size.Inflate方法的具体用法?C# Size.Inflate怎么用?C# Size.Inflate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Size
的用法示例。
在下文中一共展示了Size.Inflate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MeasureCore
/// <summary>
/// Implements basic measure-pass layout system behavior.
/// </summary>
/// <remarks>
/// In WPF this method is definded on UIElement as protected virtual and returns an empty Size.
/// FrameworkElement (which derrives from UIElement) then creates a sealed implementation similar to the below.
/// In XPF UIElement and FrameworkElement have been collapsed into a single class.
/// </remarks>
/// <param name = "availableSize">The available size that the parent element can give to the child elements.</param>
/// <returns>The desired size of this element in layout.</returns>
private Size MeasureCore(Size availableSize)
{
this.ResolveDeferredBindings(this.GetNearestDataContext());
this.OnApplyTemplate();
Thickness margin = this.Margin;
Size availableSizeWithoutMargins = availableSize.Deflate(margin);
var minMax = new MinMax(this);
availableSizeWithoutMargins.Width = availableSizeWithoutMargins.Width.Coerce(
minMax.MinWidth, minMax.MaxWidth);
availableSizeWithoutMargins.Height = availableSizeWithoutMargins.Height.Coerce(
minMax.MinHeight, minMax.MaxHeight);
Size size = this.MeasureOverride(availableSizeWithoutMargins);
size = new Size(Math.Max(size.Width, minMax.MinWidth), Math.Max(size.Height, minMax.MinHeight));
Size unclippedSize = size;
bool isClippingRequired = false;
if (size.Width > minMax.MaxWidth)
{
size.Width = minMax.MaxWidth;
isClippingRequired = true;
}
if (size.Height > minMax.MaxHeight)
{
size.Height = minMax.MaxHeight;
isClippingRequired = true;
}
Size desiredSizeWithMargins = size.Inflate(margin);
if (desiredSizeWithMargins.Width > availableSize.Width)
{
desiredSizeWithMargins.Width = availableSize.Width;
isClippingRequired = true;
}
if (desiredSizeWithMargins.Height > availableSize.Height)
{
desiredSizeWithMargins.Height = availableSize.Height;
isClippingRequired = true;
}
this.unclippedSize = isClippingRequired ? unclippedSize : Size.Empty;
return desiredSizeWithMargins;
}