System.Drawing.Region.IsVisible C# (CSharp) Метод

IsVisible() публичный Метод

public IsVisible ( Point point ) : bool
point Point
Результат bool
        public bool IsVisible(Point point)
        {
            return IsVisible ((PointF)point);
        }

Same methods

Region::IsVisible ( PointF point ) : bool
Region::IsVisible ( Rectangle rectangle ) : bool
Region::IsVisible ( RectangleF rectangle ) : bool
Region::IsVisible ( float x, float y ) : bool
Region::IsVisible ( int x, int y ) : bool

Usage Example

Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rgn"></param>
        /// <param name="pt1"></param>
        /// <param name="pt2"></param>
        /// <param name="ptIntercept"></param>
        /// <returns></returns>
        public static bool GetBoundaryIntercept(System.Drawing.Region rgn, PointF pt1, PointF pt2, out PointF ptIntercept)
        {
            bool hasIntercept = false;

            ptIntercept = new PointF(0, 0);

            bool pt1InRegion = rgn.IsVisible(pt1);
            bool pt2InRegion = rgn.IsVisible(pt2);

            if ((pt1InRegion && !pt2InRegion) || (pt2InRegion && !pt1InRegion))
            {
                PointF ptInside;
                PointF ptOutside;

                if (pt1InRegion)
                {
                    ptInside  = pt1;
                    ptOutside = pt2;
                }
                else
                {
                    ptInside  = pt2;
                    ptOutside = pt1;
                }

                RectangleF[] rcScans = rgn.GetRegionScans(new Matrix());
                RectangleF   rcCur;
                PointF[]     ptsIntersect;
                int          numIntersects;
                double       minDist = double.MaxValue;
                double       curDist;
                PointF       curPt;
                int          rcIdx;
                int          ptIdx;

                for (rcIdx = 0; rcIdx < rcScans.Length; rcIdx++)
                {
                    rcCur         = rcScans[rcIdx];
                    numIntersects = Geometry.GetLineIntersect(ptOutside, ptInside, rcCur, out ptsIntersect);

                    for (ptIdx = 0; ptIdx < numIntersects; ptIdx++)
                    {
                        curPt   = ptsIntersect[ptIdx];
                        curDist = Geometry.PointDistance(ptOutside, curPt);
                        if (curDist < minDist)
                        {
                            ptIntercept  = curPt;
                            minDist      = curDist;
                            hasIntercept = true;
                        }
                    }
                }
            }

            return(hasIntercept);
        }
All Usage Examples Of System.Drawing.Region::IsVisible