本文整理汇总了C#中Rectangle.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Clone方法的具体用法?C# Rectangle.Clone怎么用?C# Rectangle.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle.Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestClone
public void TestClone()
{
// ensure a deep copy
Rectangle r = new Rectangle(0,0,2,2);
Rectangle r2 = r.Clone();
r.Max.X = 4;
Assert.IsFalse(r == r2);
}
示例2: TestClone
public void TestClone()
{
Rectangle original = new Rectangle(GetRect());
Rectangle clone = original.Clone();
clone.Left += 1;
clone.Right += 1;
clone.Top += 1;
clone.Bottom += 1;
clone.Left.ShouldBe(original.Left + 1);
clone.Right.ShouldBe(original.Right + 1);
clone.Top.ShouldBe(original.Top + 1);
clone.Bottom.ShouldBe(original.Bottom + 1);
}
示例3: TestOverlaps
public void TestOverlaps()
{
Rectangle r1 = new Rectangle(-4,-4,-2,-2);
Rectangle r2 = new Rectangle(0,0,2,2);
// bottom-left
Assert.IsFalse(r1.Overlaps(r2));
//left
r1.Min.Y = 0;
r1.Max.Y = 2;
Assert.IsFalse(r1.Overlaps(r2));
// left overlapping
r1.Max.X = 1;
Assert.IsTrue(r1.Overlaps(r2));
//top-left
r1.Max.X = -2;
r1.Min.Y = 3;
r1.Max.Y = 5;
Assert.IsFalse(r1.Overlaps(r2));
//top
r1.Min.X = 0;
r1.Max.X = 2;
Assert.IsFalse(r1.Overlaps(r2));
// top-overlaps
r1.Min.Y = 1;
Assert.IsTrue(r1.Overlaps(r2));
// top right
r1.Min.Y = 3;
r1.Min.X = 3;
r1.Max.X = 5;
Assert.IsFalse(r1.Overlaps(r2));
// right
r1.Min.Y = 0;
r1.Max.Y = 2;
Assert.IsFalse(r1.Overlaps(r2));
// right-overlaps
r1.Min.X = 1;
Assert.IsTrue(r1.Overlaps(r2));
//bottom-right
r1.Min.X = 3;
r1.Min.Y = -5;
r1.Max.Y = -1;
Assert.IsFalse(r1.Overlaps(r2));
// bottom
r1.Min.X = 0;
r1.Max.X = 2;
Assert.IsFalse(r1.Overlaps(r2));
// bottom overlaps
r1.Max.Y = 1;
Assert.IsTrue(r1.Overlaps(r2));
// equal
Assert.IsTrue(r2.Overlaps(r2.Clone()));
// within
r1 = new Rectangle(.5, .5, 1.5, 1.5);
Assert.IsTrue(r1.Overlaps(r2));
// overlaps empty
Assert.IsFalse(r1.Overlaps(new Rectangle()));
}