예제 #1
0
        protected virtual HCShapeLineObj GetObjAt(int x, int y)
        {
            HCShapeLineObj vResult = HCShapeLineObj.sloNone;

            if (HC.PtInRect(new RECT(FStartPt.X - PointSize, FStartPt.Y - PointSize,
                                     FStartPt.X + PointSize, FStartPt.Y + PointSize), new POINT(x, y)))
            {
                vResult = HCShapeLineObj.sloStart;
            }
            else
            if (HC.PtInRect(new RECT(FEndPt.X - PointSize, FEndPt.Y - PointSize,
                                     FEndPt.X + PointSize, FEndPt.Y + PointSize), new POINT(x, y)))
            {
                vResult = HCShapeLineObj.sloEnd;
            }
            else
            {
                POINT[] vPointArr = new POINT[4];
                vPointArr[0] = new POINT(FStartPt.X - PointSize, FStartPt.Y);
                vPointArr[1] = new POINT(FStartPt.X + PointSize, FStartPt.Y);
                vPointArr[2] = new POINT(FEndPt.X + PointSize, FEndPt.Y);
                vPointArr[3] = new POINT(FEndPt.X - PointSize, FEndPt.Y);

                IntPtr vRgn = GDI.CreatePolygonRgn(vPointArr, 4, GDI.WINDING);
                try
                {
                    if (GDI.PtInRegion(vRgn, x, y))
                    {
                        vResult = HCShapeLineObj.sloLine;
                    }
                }
                finally
                {
                    GDI.DeleteObject(vRgn);
                }
            }

            return(vResult);
        }
예제 #2
0
        protected int GetLineAt(int x, int y)
        {
            POINT[] vPointArr = new POINT[4];
            IntPtr  vRgn      = IntPtr.Zero;

            for (int i = 0; i < FPoints.Count; i++)
            {
                vPointArr[0] = new POINT(FPoints[i].X - PointSize, FPoints[i].Y);
                vPointArr[1] = new POINT(FPoints[i].X + PointSize, FPoints[i].Y);

                if (i == FPoints.Count - 1)
                {
                    vPointArr[2] = new POINT(FPoints[0].X + PointSize, FPoints[0].Y);
                    vPointArr[3] = new POINT(FPoints[0].X - PointSize, FPoints[0].Y);
                }
                else
                {
                    vPointArr[2] = new POINT(FPoints[i + 1].X + PointSize, FPoints[i + 1].Y);
                    vPointArr[3] = new POINT(FPoints[i + 1].X - PointSize, FPoints[i + 1].Y);
                }

                vRgn = GDI.CreatePolygonRgn(vPointArr, 4, GDI.WINDING);
                try
                {
                    if (GDI.PtInRegion(vRgn, x, y))
                    {
                        return(i);
                    }
                }
                finally
                {
                    GDI.DeleteObject(vRgn);
                }
            }

            return(-1);
        }
예제 #3
0
        private HCLineObj GetLineObjAt(int X, int Y)
        {
            HCLineObj Result = HCLineObj.cloNone;

            if (HC.PtInRect(new RECT(FStartPt.X - PointSize, FStartPt.Y - PointSize, FStartPt.X + PointSize, FStartPt.Y + PointSize), new POINT(X, Y)))
            {
                Result = HCLineObj.cloLeftOrTop;
            }
            else
            if (HC.PtInRect(new RECT(FEndPt.X - PointSize, FEndPt.Y - PointSize, FEndPt.X + PointSize, FEndPt.Y + PointSize), new POINT(X, Y)))
            {
                Result = HCLineObj.cloRightOrBottom;
            }
            else
            {
                POINT[] vPointArr = new POINT[4];
                vPointArr[0] = new POINT(FStartPt.X - PointSize, FStartPt.Y);
                vPointArr[1] = new POINT(FStartPt.X + PointSize, FStartPt.Y);
                vPointArr[2] = new POINT(FEndPt.X + PointSize, FEndPt.Y);
                vPointArr[3] = new POINT(FEndPt.X - PointSize, FEndPt.Y);
                IntPtr vRgn = (IntPtr)GDI.CreatePolygonRgn(ref vPointArr[0], 4, GDI.WINDING);
                try
                {
                    if (GDI.PtInRegion(vRgn, X, Y) > 0)
                    {
                        Result = HCLineObj.cloLine;
                    }
                }
                finally
                {
                    GDI.DeleteObject(vRgn);
                }
            }

            return(Result);
        }