当前位置: 首页>>代码示例>>C#>>正文


C# AbsoluteLayout.Layout方法代码示例

本文整理汇总了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);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:15,代码来源:AbsoluteLayoutTests.cs

示例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));
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:19,代码来源:AbsoluteLayoutTests.cs

示例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));
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:20,代码来源:AbsoluteLayoutTests.cs

示例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));
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:22,代码来源:AbsoluteLayoutTests.cs


注:本文中的AbsoluteLayout.Layout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。