Ejemplo n.º 1
0
        public override int HitTest(PointF point, long currentTimestamp, DistortionHelper distorter, IImageToViewportTransformer transformer, bool zooming)
        {
            // Convention: miss = -1, object = 0, handle = n.
            double opacity = infosFading.GetOpacityFactor(currentTimestamp);

            if (opacity <= 0)
            {
                return(-1);
            }

            for (int i = 0; i < 4; i++)
            {
                if (HitTester.HitTest(quadImage[i], point, transformer))
                {
                    return(i + 1);
                }
            }

            for (int i = 0; i < 4; i++)
            {
                using (GraphicsPath path = new GraphicsPath())
                {
                    PointF p1 = quadImage[i];
                    PointF p2 = quadImage[(i + 1) % 4];
                    if (!p1.NearlyCoincideWith(p2))
                    {
                        path.AddLine(p1, p2);
                        if (HitTester.HitTest(path, point, styleHelper.LineSize, false, transformer))
                        {
                            return(i + 5);
                        }
                    }
                }
            }

            if (quadImage.Contains(point))
            {
                return(0);
            }

            return(-1);
        }
Ejemplo n.º 2
0
        public override int HitTest(PointF point, long currentTimestamp, DistortionHelper distorter, IImageToViewportTransformer transformer, bool zooming)
        {
            if (infosFading.GetOpacityFactor(currentTimestamp) <= 0)
            {
                return(-1);
            }

            for (int i = 0; i < 4; i++)
            {
                if (HitTester.HitTest(quadImage[i], point, transformer))
                {
                    return(i + 1);
                }
            }

            if (!zooming && !inPerspective && quadImage.Contains(point))
            {
                return(0);
            }

            return(-1);
        }