本文整理汇总了C#中Size.Deflate方法的典型用法代码示例。如果您正苦于以下问题:C# Size.Deflate方法的具体用法?C# Size.Deflate怎么用?C# Size.Deflate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Size
的用法示例。
在下文中一共展示了Size.Deflate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MeasureOverride
/// <inheritdoc/>
protected override Size MeasureOverride(Size availableSize)
{
var content = Child;
var padding = Padding;
if (content != null)
{
content.Measure(availableSize.Deflate(padding));
return content.DesiredSize.Inflate(padding);
}
else
{
return new Size(padding.Left + padding.Right, padding.Bottom + padding.Top);
}
}
示例2: MeasureOverride
/// <summary>
/// Measures the control.
/// </summary>
/// <param name="availableSize">The available size.</param>
/// <returns>The desired size of the control.</returns>
protected override Size MeasureOverride(Size availableSize)
{
var child = Child;
var padding = Padding + new Thickness(BorderThickness);
if (child != null)
{
child.Measure(availableSize.Deflate(padding));
return child.DesiredSize.Inflate(padding);
}
else
{
return new Size(padding.Left + padding.Right, padding.Bottom + padding.Top);
}
}
示例3: ArrangeOverride
/// <inheritdoc/>
protected override Size ArrangeOverride(Size finalSize)
{
var child = Child;
if (child != null)
{
var padding = Padding + new Thickness(BorderThickness);
var sizeMinusPadding = finalSize.Deflate(padding);
var size = sizeMinusPadding;
var horizontalAlignment = HorizontalContentAlignment;
var verticalAlignment = VerticalContentAlignment;
var originX = padding.Left;
var originY = padding.Top;
if (horizontalAlignment != HorizontalAlignment.Stretch)
{
size = size.WithWidth(child.DesiredSize.Width);
}
if (verticalAlignment != VerticalAlignment.Stretch)
{
size = size.WithHeight(child.DesiredSize.Height);
}
switch (horizontalAlignment)
{
case HorizontalAlignment.Stretch:
case HorizontalAlignment.Center:
originX += (sizeMinusPadding.Width - size.Width) / 2;
break;
case HorizontalAlignment.Right:
originX = size.Width - child.DesiredSize.Width;
break;
}
switch (verticalAlignment)
{
case VerticalAlignment.Stretch:
case VerticalAlignment.Center:
originY += (sizeMinusPadding.Height - size.Height) / 2;
break;
case VerticalAlignment.Bottom:
originY = size.Height - child.DesiredSize.Height;
break;
}
child.Arrange(new Rect(originX, originY, size.Width, size.Height));
}
return finalSize;
}
示例4: 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;
}
示例5: MeasureOverride
protected override Size MeasureOverride(Size availableSize)
{
Thickness borderThicknessAndPadding = this.BorderThickness + this.Padding;
IElement child = this.Child;
if (child != null)
{
child.Measure(availableSize.Deflate(borderThicknessAndPadding));
return child.DesiredSize.Inflate(borderThicknessAndPadding);
}
return borderThicknessAndPadding.Collapse();
}
示例6: MeasureOverride
protected override Size MeasureOverride(Size availableSize)
{
var content = this.Content;
var padding = this.Padding + new Thickness(this.BorderThickness);
if (content != null)
{
content.Measure(availableSize.Deflate(padding));
return content.DesiredSize.Inflate(padding);
}
else
{
return new Size(padding.Left + padding.Right, padding.Bottom + padding.Top);
}
}