Exemplo n.º 1
0
 public Rect(Rect r)
 {
     Location = new Point(r.Location);
     Size = new Point(r.Size);
 }
Exemplo n.º 2
0
 public void Set(Rect R)
 {
     this.Location.Set(R.Location);
     this.Size.Set(R.Size);
 }
Exemplo n.º 3
0
        public void Unite(Rect ToContain)
        {
            int x1 = ToContain.mLocation.X;
            int y1 = ToContain.mLocation.Y;
            int x2 = ToContain.Right;
            int y2 = ToContain.Bottom;

            if (x1 < this.Location.X)
            {
                this.Size.X += this.Location.X - x1;
                this.Location.X = x1;
            }

            if (y1 < this.Location.Y)
            {
                this.Size.Y += this.Location.Y - y1;
                this.Location.Y = y1;
            }

            if (x2 > this.Right)
            {
                this.Size.X = x2 - this.Location.X;
            }

            if (y2 > this.Bottom)
            {
                this.Size.Y = y2 - this.Location.Y;
            }
        }
Exemplo n.º 4
0
        public bool IntersectsRectY(Rect Reference)
        {
            int y1 = Reference.Location.Y;
            int y2 = Reference.Bottom;
            int top = this.Location.Y;
            int bottom = this.Bottom;

            return (bottom > y1 && top < y2);
        }
Exemplo n.º 5
0
        public int RelativeToRectY(Rect Reference)
        {
            int y1 = Reference.Location.Y;
            int y2 = Reference.Bottom;
            int top = this.Location.Y;
            int bottom = this.Bottom;

            if (top >= y2) return 5;

            if (bottom <= y1) return 1;

            if (top < y1)
            {
                if (bottom <= y2) return 2;
                return 0;
            }

            if (bottom > y2) return 4;

            return 3;
        }
Exemplo n.º 6
0
        public bool IntersectsRectX(Rect Reference)
        {
            int x1 = Reference.Location.X;
            int x2 = Reference.Right;
            int left = this.Location.X;
            int right = this.Right;

            return (right > x1 && left < x2);
        }
Exemplo n.º 7
0
 public bool IntersectsRect(Rect Reference)
 {
     return IntersectsRectX(Reference) && IntersectsRectY(Reference);
 }
Exemplo n.º 8
0
 public bool Contains(Rect inner)
 {
     return
         inner.Location.X >= this.Location.X
         && inner.Location.Y >= this.Location.Y
         && inner.Right <= this.Right
         && inner.Bottom <= this.Bottom;
 }
Exemplo n.º 9
0
 public PointClassification ClassifyVertically(Rect r)
 {
     if (Y < r.Top)
     {
         return PointClassification.Before;
     }
     else if (Y <= r.Bottom)
     {
         return PointClassification.Inside;
     }
     else
     {
         return PointClassification.After;
     }
 }
Exemplo n.º 10
0
 public PointClassification ClassifyHorizontally(Rect r)
 {
     if (X < r.Left)
     {
         return PointClassification.Before;
     }
     else if (X <= r.Right)
     {
         return PointClassification.Inside;
     }
     else
     {
         return PointClassification.After;
     }
 }