public bool intersectsInt(PdfTargetRect otherRect)
        {
            bool horizontalContained = otherRect._iX <iRight && otherRect.iRight> _iX;
            bool verticalContained = otherRect._iY <iBottom && otherRect.iBottom> _iY;

            return(horizontalContained && verticalContained);
        }
        public PdfTargetRect unionInt(PdfTargetRect otherRect)
        {
            int x      = Math.Min(otherRect._iX, _iX);
            int y      = Math.Min(otherRect._iY, _iY);
            int width  = Math.Max(otherRect.iRight, iRight) - x;
            int height = Math.Max(otherRect.iBottom, iBottom) - y;

            return(new PdfTargetRect(x, y, width, height));
        }
        public System.Windows.Rect GetWinRect(PdfTargetRect viewport)
        {
            PdfTargetRect intersected = this.intersectInt(viewport);

            if (intersected.IsEmpty)
            {
                return(new System.Windows.Rect(0, 0, 0, 0));
            }
            return(new System.Windows.Rect(intersected._iX - viewport.iX, intersected._iY - viewport.iY, intersected._iWidth, intersected._iHeight));
        }
        public System.Drawing.Rectangle GetDrawingRect(PdfTargetRect viewport)
        {
            PdfTargetRect intersected = this.intersectInt(viewport);

            if (intersected.IsEmpty)
            {
                return(new System.Drawing.Rectangle(0, 0, 0, 0));
            }
            return(new System.Drawing.Rectangle(intersected._iX - viewport.iX, intersected._iY - viewport.iY, intersected._iWidth, intersected._iHeight));
        }
        /// <summary>
        ///    |---------------------------------|
        ///    |               r1                |
        ///    |---------------------------------|
        ///    |   r2   |  subtrahend   |   r4   |
        ///    |---------------------------------|
        ///    |               r3                |
        ///    |---------------------------------|
        /// </summary>
        /// <param name="subtrahend"></param>
        /// <returns>r1-r4</returns>
        public IList <PdfTargetRect> subtractRect(PdfTargetRect subtrahend)
        {
            //crop the subtrahend to be contained within minuend(this)
            subtrahend = subtrahend.intersectInt(this);

            IList <PdfTargetRect> differences = new List <PdfTargetRect>();

            differences.Add(new PdfTargetRect(this._iX, this._iY, this._iWidth, subtrahend._iY - this._iY));
            differences.Add(new PdfTargetRect(this._iX, subtrahend._iY, subtrahend._iX - this._iX, subtrahend._iHeight));
            differences.Add(new PdfTargetRect(this._iX, subtrahend.iBottom, this._iWidth, this.iBottom - subtrahend.iBottom));
            differences.Add(new PdfTargetRect(subtrahend.iRight, subtrahend._iY, this.iRight - subtrahend.iRight, subtrahend._iHeight));
            return(differences);
        }
        public override bool Equals(object other)
        {
            PdfTargetRect ot = other as PdfTargetRect;

            return(this == ot);
        }
 public static PdfTargetRect CreateFromRectOnViewport(PdfTargetRect rectOnViewport, PdfTargetRect viewportRect)
 {
     return(new PdfTargetRect((int)rectOnViewport._iX + viewportRect._iX, (int)rectOnViewport._iY + viewportRect._iY, (int)rectOnViewport._iWidth, (int)rectOnViewport._iHeight));
 }
 public bool containsInt(PdfTargetRect other)
 {
     return(other._iX >= _iX && other._iY >= _iY && other.iRight <= iRight && other.iBottom <= iBottom);
 }