예제 #1
0
        public Point StayOrExitBox(Point gp)
        {
            //iterate through all the most recent raw gaze points and check that they all are at least thresholdPixels away
            int threshold = ScreenPixelHelper.ConvertMmToPixels(ConfigManager.cursorMagnetClippingExitThresholdMm);

            List <Point> rawGazePoints = mc.WarpPointer.GetGazeHistory();

            if (rawGazePoints == null || rawGazePoints.Count == 0 || ClippedBox == null)
            {
                winzoomAvailable = true;
                return(gp); //todo: out of bound?
            }

            int sampleRate = mc.WarpPointer.GetSampleRate();

            int recentDurationMs    = ConfigManager.cursorMagnetClippingExitDurationMs; //todo: config
            int lookbackSampleCount = sampleRate * recentDurationMs / 1000;
            int startIndex          = Math.Max(0, rawGazePoints.Count - lookbackSampleCount);

            //all points have to leave the box by at least exitThreshold amount in order to consider exit
            //equivalent to having 1 point not leave the box by exitThreshold to continue staying

            for (int i = startIndex; i < rawGazePoints.Count; i++)
            {
                //use the calibration adjusted value for the raw data
                Point adjustedGp = new Point(rawGazePoints[i].X, rawGazePoints[i].Y);
                adjustedGp.Offset(calibrationAdjuster.GetCalibrationAdjustment(adjustedGp));
                if (isNearBox(adjustedGp, ClippedBox, ScreenPixelHelper.ConvertMmToPixels(ConfigManager.cursorMagnetClippingExitThresholdMm)))
                {
                    //stay in box, since 1 point is still threshold/2 near the perimeter of the currently clipped box
                    return(ClippedBox.center());
                }
            }

            //We went through the most recent gaze points and all of them are more than threshold away
            //Exit this box
            ClippedBox       = null;
            winzoomAvailable = true;
            return(gp); //todo: out of bound
        }
예제 #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            User32.SetFormTransparent(this.Handle);

            //Convert the current warp point a point on the screen
            Point wp = warpPointer.GetWarpPoint();

            wp.Offset(calibrationAdjuster.GetCalibrationAdjustment(wp));
            Point     screenPoint = wz.ConvertToScreenPoint(wp);
            Rectangle screenSize  = ScreenPixelHelper.GetScreenSize();

            if (ConfigManager.zoomboxGrid)
            {
                //Draw a vertical line
                e.Graphics.DrawLine(Pens.Black, new Point(screenPoint.X, screenSize.Top), new Point(screenPoint.X, screenSize.Bottom));

                //Draw a horizontal line
                e.Graphics.DrawLine(Pens.Black, new Point(screenSize.Left, screenPoint.Y), new Point(screenSize.Right, screenPoint.Y));
            }
            else
            {
                DrawApplicableCursorSymbol(e, screenPoint);
            }
        }