本文整理汇总了C#中Rectangle.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Equals方法的具体用法?C# Rectangle.Equals怎么用?C# Rectangle.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle.Equals方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Rectangle_EqualsObject
public void Rectangle_EqualsObject()
{
var rectangle1 = new Rectangle(123, 456, 789, 999);
var rectangle2 = new Rectangle(123, 456, 789, 999);
TheResultingValue(rectangle1.Equals((Object)rectangle2)).ShouldBe(true);
TheResultingValue(rectangle1.Equals("This is a test")).ShouldBe(false);
}
示例2: Main
static void Main(string[] args)
{
Point A = new Point(3.0, 4.0);
Point B = new Point(A);
Point C = new Point(3.0, 5.0);
Point D = new Point();
Console.WriteLine(A.ToString());
Console.WriteLine(B.ToString());
Console.WriteLine(C.ToString());
Console.WriteLine(D.ToString());
Console.WriteLine(A.Equals(B));
Console.WriteLine(B.Equals(C));
Console.WriteLine(A == B);
Console.WriteLine(A == C);
LineSegment line1 = new LineSegment(A, C);
LineSegment line2 = new LineSegment(D, A);
Console.WriteLine(line1.Equals(line2));
Console.WriteLine(line1 == line2);
Console.WriteLine(line1.ToString());
Console.WriteLine(line1 > line2);
Console.WriteLine(line2 >= 3.0);
Point left = new Point(1, 1);
Point right = new Point(7, 5);
Point c = new Point(4, 3);
Rectangle rect1 = new Rectangle(left, right);
Rectangle rect2 = new Rectangle(c, right);
Rectangle rect3 = new Rectangle(rect1);
Console.WriteLine(rect3.ToString());
Console.WriteLine(rect1.GetPerimeter());
Console.WriteLine(rect1.GetArea());
Console.WriteLine(rect1.Equals(rect2));
Console.WriteLine(rect1.Equals(rect3));
Console.WriteLine(rect1.Center.ToString());
Console.WriteLine(rect1 == rect2);
Console.WriteLine(rect2 != rect3);
Vector v1 = new Vector(1, 3, 5);
Vector v2 = new Vector(2, 4, 6);
Vector v3 = new Vector(v1);
double num = 5;
Console.WriteLine(v1.ToString());
Console.WriteLine(v1.Equals(v2));
Console.WriteLine(v1.Equals(v3));
Console.WriteLine((v1 + v2).ToString());
Console.WriteLine((v2 - v1).ToString());
Console.WriteLine((v1 * v2).ToString());
Console.WriteLine((v1 / v2).ToString());
Console.WriteLine((v1 + num).ToString());
}
示例3: Rectangle_EqualsRectangle
public void Rectangle_EqualsRectangle()
{
var rectangle1 = new Rectangle(123, 456, 789, 999);
var rectangle2 = new Rectangle(123, 456, 789, 999);
var rectangle3 = new Rectangle(222, 456, 789, 999);
var rectangle4 = new Rectangle(123, 333, 789, 999);
var rectangle5 = new Rectangle(123, 456, 444, 999);
var rectangle6 = new Rectangle(123, 456, 789, 555);
TheResultingValue(rectangle1.Equals(rectangle2)).ShouldBe(true);
TheResultingValue(rectangle1.Equals(rectangle3)).ShouldBe(false);
TheResultingValue(rectangle1.Equals(rectangle4)).ShouldBe(false);
TheResultingValue(rectangle1.Equals(rectangle5)).ShouldBe(false);
TheResultingValue(rectangle1.Equals(rectangle6)).ShouldBe(false);
}
示例4: GetSize
public override void GetSize (Widget widget, ref Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
{
int calc_width = (int) this.Xpad * 2 + 100;
int calc_height = (int) this.Ypad * 2 + 10;
width = calc_width;
height = calc_height;
x_offset = 0;
y_offset = 0;
if (!cell_area.Equals (Rectangle.Zero)) {
x_offset = (int) (this.Xalign * (cell_area.Width - calc_width));
x_offset = Math.Max (x_offset, 0);
y_offset = (int) (this.Yalign * (cell_area.Height - calc_height));
y_offset = Math.Max (y_offset, 0);
}
}
示例5: Main
static void Main(string[] args)
{
Rectangle r1 = new Rectangle(3, 4);
Console.WriteLine("R1 {0}"+ r1);
Rectangle r2 = new Rectangle(4, 3);
Console.WriteLine("R2 {0}"+ r2);
Rectangle r3 = new Rectangle(1, 4);
Console.WriteLine("R3 {0}"+ r3);
Console.WriteLine();
Rectangle [] rlist = new [] { r1, r2, r3 };
foreach (var x in rlist)
{
Console.WriteLine("List Item: "+ x);
}
Console.WriteLine();
Console.WriteLine("r1 == r3: " + (r1==r3));
Console.WriteLine("r1.Equals(r3): " + r1.Equals(r3));
Console.WriteLine("r1.compareTo(r2): " + r1.CompareTo(r3));
}
示例6: Equals
public void Equals()
{
var rect1 = new Rectangle(3, 4, 1, 2);
var rect2 = new Rectangle(5, 6, 1, 2);
Assert.AreNotEqual(rect1, rect2);
Assert.AreEqual(rect1, new Rectangle(3, 4, 1, 2));
Assert.IsTrue(rect1 == new Rectangle(3, 4, 1, 2));
Assert.IsTrue(rect1 != rect2);
Assert.IsFalse(rect1.Equals(rect2));
Assert.IsTrue(rect1.Equals(rect1));
}
示例7: RectangleEquals
public void RectangleEquals()
{
var rect = new Rectangle(X, Y, Width, Height);
Assert.IsTrue(rect.Equals(Reference));
}
示例8: EqualityTest
public void EqualityTest(int x, int y, int width, int height)
{
Rectangle rect1 = new Rectangle(x, y, width, height);
Rectangle rect2 = new Rectangle(width/2, height/2, x, y);
Assert.True(rect1 != rect2);
Assert.False(rect1 == rect2);
Assert.False(rect1.Equals(rect2));
}
示例9: TestEquals
public void TestEquals()
{
Rectangle r1 = new Rectangle(0,0,1,1);
Rectangle r2 = new Rectangle(0,0,1,1);
Assert.IsTrue(r1.Equals(r2));
Assert.IsTrue(r1.Equals((object)r2));
}
示例10: EqualityTest_NotRectangle
public static void EqualityTest_NotRectangle()
{
var rectangle = new Rectangle(0, 0, 0, 0);
Assert.False(rectangle.Equals(null));
Assert.False(rectangle.Equals(0));
Assert.False(rectangle.Equals(new RectangleF(0, 0, 0, 0)));
}