本文整理汇总了C#中System.Windows.Size.ToRect方法的典型用法代码示例。如果您正苦于以下问题:C# Size.ToRect方法的具体用法?C# Size.ToRect怎么用?C# Size.ToRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Size
的用法示例。
在下文中一共展示了Size.ToRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArrangeOverride
protected override Size ArrangeOverride(Size finalSize)
{
var animationClock = GetAnimationClock (this);
StopClock();
var count = Children.Count;
if (count == 0)
{
return finalSize;
}
var previewWidth = PreviewWidth;
var adjustedSize = new Size (
Math.Max (finalSize.Width - (count - 1) * previewWidth, previewWidth),
finalSize.Height
);
var adjustedRect = adjustedSize.ToRect();
var activeElement = ActiveElement;
var desiredX = 0.0;
var doAnimate = false;
for (int index = 0; index < count; index++)
{
var child = Children[index];
var state = GetChildState(child);
if (state == null)
{
state = new State
{
Transform = new TranslateTransform(),
From = finalSize.Width,
To = finalSize.Width,
};
SetChildState (child, state);
}
child.Arrange(adjustedRect);
child.RenderTransform = state.Transform;
var current = state.GetCurrentX (animationClock);
state.From = current;
state.To = desiredX;
state.UpdateTransform (current);
doAnimate |= !state.From.IsNear (state.To);
if (ReferenceEquals (child, activeElement))
{
desiredX += adjustedSize.Width;
}
else
{
desiredX += previewWidth;
}
}
if (doAnimate)
{
StartClock();
}
return finalSize;
}