Ejemplo n.º 1
0
        public void TestRectangleDimensionsFromWidthHeight()
        {
            TemplateRectangle rect = new TemplateRectangle(10, 10, 20, 30);

            Assert.AreEqual(rect.Right, 29);
            Assert.AreEqual(rect.Bottom, 39);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
        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));
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
 public MyEnumerator(TemplateRectangle parent)
 {
     this.parent = parent;
 }
Ejemplo n.º 11
0
 public void TestCannotCreateZeroWidthRectangles()
 {
     TemplateRectangle rectZeroWidth = new TemplateRectangle(10, 10, 0, 10);
 }
Ejemplo n.º 12
0
 public void TestCannotCreateNegativeDimensionRectangles()
 {
     TemplateRectangle rectZeroWidth = new TemplateRectangle(10, 10, -10, -10);
 }
Ejemplo n.º 13
0
 public MyEnumerator(TemplateRectangle parent)
 {
     this.parent = parent;
 }