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


C# Rectangle.Clone方法代码示例

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

示例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);
 }
开发者ID:TomPeters,项目名称:paneless,代码行数:13,代码来源:WindowLocationTests.cs

示例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()));
        }
开发者ID:agrath,项目名称:cumberland,代码行数:72,代码来源:RectangleTests.cs


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