public bool IsInside(Rectangle secondRectangle)
 {
     bool isTopInside = this.TopX >= secondRectangle.TopX && this.TopY <= secondRectangle.TopY;
     bool isRectangleInside = this.TopX + this.Width <= secondRectangle.TopX + secondRectangle.Width
                              && this.TopY + this.Height <= secondRectangle.TopY + secondRectangle.Height;
     return isTopInside && isRectangleInside;
 }
예제 #2
0
        static bool IsInside(Rectangle r1, Rectangle r2)
        {
            if(r1.Top <= r2.Top && r1.Right <= r2.Right && r1.Bottom <= r2.Bottom && r1.Left >= r2.Left)
            {
                return true;
            }

            return false;
        }