public void TestRectangleDimensionsFromWidthHeight() { TemplateRectangle rect = new TemplateRectangle(10, 10, 20, 30); Assert.AreEqual(rect.Right, 29); Assert.AreEqual(rect.Bottom, 39); }
public void TestRectangleOverlapTL() { TemplateRectangle rectBase = new TemplateRectangle(10, 10, 20, 30); TemplateRectangle rectTop = new TemplateRectangle(0, 0, 15, 15); TemplateRectangle rectOverlap = rectBase.GetOverlapRectangle(rectTop); Assert.AreEqual(new TemplateRectangle(10, 10, 5, 5), rectOverlap); }
public void TestRectangleEntirelyInOtherRectangle() { TemplateRectangle rectBase = new TemplateRectangle(-10, -10, 5, 5); TemplateRectangle rectTop = new TemplateRectangle(-8, -8, 2, 2); TemplateRectangle rectOverlap = rectBase.GetOverlapRectangle(rectTop); Assert.AreEqual(new TemplateRectangle(-8, -8, 2, 2), rectOverlap); }
public void TestRectangleCrossed() { TemplateRectangle rectBase = new TemplateRectangle(-10, -10, 20, 20); TemplateRectangle rectTop = new TemplateRectangle(-20, 0, 40, 10); TemplateRectangle rectOverlap = rectBase.GetOverlapRectangle(rectTop); Assert.AreEqual(new TemplateRectangle(-10, 0, 20, 10), rectOverlap); }
public bool Equals(TemplateRectangle p) { // If parameter is null return false: if ((object)p == null) { return false; } // Return true if the fields match: return (Left == p.Left) && (Top == p.Top) && (Width == p.Width) && (Height == p.Height); }
public bool Equals(TemplateRectangle p) { // If parameter is null return false: if ((object)p == null) { return(false); } // Return true if the fields match: return((Left == p.Left) && (Top == p.Top) && (Width == p.Width) && (Height == p.Height)); }
public TemplateRectangle GetOverlapRectangle(TemplateRectangle other) { //Wrap rectangle calls Rectangle thisRect = new Rectangle(this.Left, this.Top, this.Right - this.Left, this.Bottom - this.Top); Rectangle otherRect = new Rectangle(other.Left, other.Top, other.Right - other.Left, other.Bottom - other.Top); if (!thisRect.IntersectsWith(otherRect)) { return(null); } Rectangle intersectRect = Rectangle.Intersect(thisRect, otherRect); return(new TemplateRectangle(intersectRect.Left, intersectRect.Top, intersectRect.Width + 1, intersectRect.Height + 1)); }
public override bool Equals(System.Object obj) { // If parameter is null return false. if (obj == null) { return(false); } // If parameter cannot be cast to Point return false. TemplateRectangle p = obj as TemplateRectangle; if ((System.Object)p == null) { return(false); } // Return true if the fields match: return((Left == p.Left) && (Top == p.Top) && (Width == p.Width) && (Height == p.Height)); }
public TemplateRectangle GetOverlapRectangle(TemplateRectangle other) { //Wrap rectangle calls Rectangle thisRect = new Rectangle(this.Left, this.Top, this.Right - this.Left, this.Bottom - this.Top); Rectangle otherRect = new Rectangle(other.Left, other.Top, other.Right - other.Left, other.Bottom - other.Top); if (!thisRect.IntersectsWith(otherRect)) return null; Rectangle intersectRect = Rectangle.Intersect(thisRect, otherRect); return new TemplateRectangle(intersectRect.Left, intersectRect.Top, intersectRect.Width + 1, intersectRect.Height + 1); }
public MyEnumerator(TemplateRectangle parent) { this.parent = parent; }
public void TestCannotCreateZeroWidthRectangles() { TemplateRectangle rectZeroWidth = new TemplateRectangle(10, 10, 0, 10); }
public void TestCannotCreateNegativeDimensionRectangles() { TemplateRectangle rectZeroWidth = new TemplateRectangle(10, 10, -10, -10); }