System.Drawing.RectangleF.Contains C# (CSharp) Method

Contains() private method

private Contains ( PointF pt ) : bool
pt PointF
return bool
        public bool Contains(PointF pt) => Contains(pt.X, pt.Y);

Same methods

RectangleF::Contains ( RectangleF rect ) : bool
RectangleF::Contains ( System pt ) : bool
RectangleF::Contains ( float x, float y ) : bool

Usage Example

        public static bool DoesLineIntersectRectangle(RectangleF pobjRectangle, Line pobjLine, ref Line pobjIntersectingPortionOfLine)
        {
            RectangleF objLineAsRectangle = default(RectangleF);
            objLineAsRectangle = pobjLine.ToRectangle();

            if (!pobjRectangle.IntersectsWith(objLineAsRectangle))
            {
                return false;
            }
            else
            {
                bool blnIsPointAIn = false;
                bool blnIsPointBIn = false;

                blnIsPointAIn = pobjRectangle.Contains(pobjLine.PointA);
                blnIsPointBIn = pobjRectangle.Contains(pobjLine.PointB);

                if (blnIsPointAIn && blnIsPointBIn)
                {
                    pobjIntersectingPortionOfLine = pobjLine;
                }
                else
                {
                    PointF[] colIntersections = new PointF[2];
                    // Either one or two intersections.
                    List<Line> colLines = null;
                    colLines = GeometryHelper.RectangleTo4Lines(pobjRectangle);

                    foreach (Line objLine in colLines)
                    {
                        if (colIntersections[0].IsEmpty)
                        {
                            DoLinesIntersect(objLine, pobjLine, ref colIntersections[0]);
                        }
                        else if (colIntersections[1].IsEmpty)
                        {
                            DoLinesIntersect(objLine, pobjLine, ref colIntersections[1]);
                        }
                    }

                    if (!blnIsPointAIn && !blnIsPointBIn)
                    {
                        pobjIntersectingPortionOfLine = new Line(colIntersections[0], colIntersections[1]);
                    }
                    else
                    {
                        if (blnIsPointAIn)
                        {
                            pobjIntersectingPortionOfLine = new Line(colIntersections[0], pobjLine.PointA);
                        }
                        else
                        {
                            pobjIntersectingPortionOfLine = new Line(colIntersections[0], pobjLine.PointB);
                        }
                    }
                }

                return true;
            }
        }
All Usage Examples Of System.Drawing.RectangleF::Contains