本文整理汇总了C#中AbsoluteLayout.Layout方法的典型用法代码示例。如果您正苦于以下问题:C# AbsoluteLayout.Layout方法的具体用法?C# AbsoluteLayout.Layout怎么用?C# AbsoluteLayout.Layout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AbsoluteLayout
的用法示例。
在下文中一共展示了AbsoluteLayout.Layout方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AbsolutePositionAndSize
public void AbsolutePositionAndSize ()
{
var abs = new AbsoluteLayout {
Platform = new UnitPlatform (),
IsPlatformEnabled = true
};
var child = new View {IsPlatformEnabled = true};
abs.Children.Add (child, new Rectangle (10, 20, 30, 40));
abs.Layout (new Rectangle (0, 0, 100, 100));
Assert.AreEqual (new Rectangle (10, 20, 30, 40), child.Bounds);
}
示例2: AbsolutePositionRelativeSize
public void AbsolutePositionRelativeSize ()
{
var abs = new AbsoluteLayout {
Platform = new UnitPlatform (),
IsPlatformEnabled = true
};
var child = new View {IsPlatformEnabled = true};
abs.Children.Add (child, new Rectangle (10, 20, 0.4, 0.5), AbsoluteLayoutFlags.SizeProportional);
abs.Layout (new Rectangle (0, 0, 100, 100));
Assert.That (child.X, Is.EqualTo (10));
Assert.That (child.Y, Is.EqualTo (20));
Assert.That (child.Width, Is.EqualTo (40).Within (0.0001));
Assert.That (child.Height, Is.EqualTo (50).Within (0.0001));
}
示例3: RelativePositionAbsoluteSize
public void RelativePositionAbsoluteSize (double width, double height, double relX, double relY)
{
var abs = new AbsoluteLayout {
Platform = new UnitPlatform (),
IsPlatformEnabled = true
};
var child = new View {IsPlatformEnabled = true};
abs.Children.Add (child, new Rectangle (relX, relY, width, height), AbsoluteLayoutFlags.PositionProportional);
abs.Layout (new Rectangle (0, 0, 100, 100));
double expectedX = Math.Round ((100 - width) * relX);
double expectedY = Math.Round ((100 - height) * relY);
Assert.That (child.X, Is.EqualTo (expectedX).Within (0.0001));
Assert.That (child.Y, Is.EqualTo (expectedY).Within (0.0001));
Assert.That (child.Width, Is.EqualTo (width));
Assert.That (child.Height, Is.EqualTo (height));
}
示例4: RelativePositionRelativeSize
public void RelativePositionRelativeSize ([Values (0.0, 0.2, 0.5, 1.0)] double relX, [Values (0.0, 0.2, 0.5, 1.0)] double relY, [Values (0.0, 0.2, 0.5, 1.0)] double relHeight, [Values (0.0, 0.2, 0.5, 1.0)] double relWidth)
{
var abs = new AbsoluteLayout {
Platform = new UnitPlatform (),
IsPlatformEnabled = true
};
var child = new View {
IsPlatformEnabled = true
};
abs.Children.Add (child, new Rectangle(relX, relY, relWidth, relHeight), AbsoluteLayoutFlags.All);
abs.Layout (new Rectangle(0, 0, 100, 100));
double expectedWidth = Math.Round (100 * relWidth);
double expectedHeight = Math.Round (100 * relHeight);
double expectedX = Math.Round ((100 - expectedWidth) * relX);
double expectedY = Math.Round ((100 - expectedHeight) * relY);
Assert.That (child.X, Is.EqualTo (expectedX).Within (0.0001));
Assert.That (child.Y, Is.EqualTo (expectedY).Within (0.0001));
Assert.That (child.Width, Is.EqualTo (expectedWidth).Within (0.0001));
Assert.That (child.Height, Is.EqualTo (expectedHeight).Within (0.0001));
}