private Point getGazePoint()
        {
            //return combineEyeGaze.GetGazePoint();

            if (mCalibrationMode == "BothEyes")
            {
                return(combineEyeGaze.GetGazePoint());
            }

            else if (mCalibrationMode == "RightEye")
            {
                return(oneEyeRight.GetGazePoint());
            }

            else if (mCalibrationMode == "LeftEye")
            {
                return(oneEyeLeft.GetGazePoint());
            }

            return(combineEyeGaze.GetGazePoint());
        }
Пример #2
0
        //chose betweeen 3 test mode
        private Point getGazePoint()
        {
            if (mtestingMode == "BothEye")
            {
                gazePoint = combineEyeGaze.GetGazePoint();
            }

            else if (mtestingMode == "RightEye")
            {
                gazePoint = oneEyeRight.GetGazePoint();
            }

            else if (mtestingMode == "LeftEye")
            {
                gazePoint = oneEyeLeft.GetGazePoint();
            }

            return(gazePoint);
        }
Пример #3
0
        public void UpdateMaginifier(IntPtr myhWnd)
        {
            if ((!initialized) || (hwndMag == IntPtr.Zero))
            {
                return;
            }

            //*************************Take Eye Gaze From Both Eye**********************************************//

            Point gazePoint = combineEyeGaze.GetGazePoint();

            Point warpPoint = combineEyeGaze.GetNextPoint(gazePoint);

            //overlayEyeNewForm.mTargetPoint = warpPoint;

            //show where am I Point
            //overlayEyeNewForm.wWhereAmIPoint = warpPoint;
            Point target = calculateTargetPoint(warpPoint);

            // Point target2 = calculateTargetPoint(warpPoint);

            overlayEyeNewForm.mTargetPoint = target;


            //***********************************************************************************************//
            RECT hostWindowRect = new RECT();

            NativeMethods.GetWindowRect(hwndMag, out hostWindowRect);

            int width  = (int)((magWindowRect.right - magWindowRect.left) / m_MAGFACTOR);
            int height = (int)((magWindowRect.bottom - magWindowRect.top) / m_MAGFACTOR);

            RECT sourceRect = getInScreenRectFromTargetPoint(target, width, height);

            setColor();
            // Set the source rectangle for the magnifier control.
            bool ret = NativeMethods.MagSetWindowSource(hwndMag, sourceRect);

            POINT cursor = new POINT();

            NativeMethods.GetCursorPos(ref cursor);

            // The reason why "right" and "bottom" minus the 10 is, normally the image
            // of the cursor is shown at the bottom right of the cursor position,
            // if they don't minus some pixel, the cursor will stay outside of the magnifier.

            if (cursor.x <= sourceRect.left)
            {
                cursor.x = sourceRect.left;
            }
            if (cursor.x >= sourceRect.right)
            {
                cursor.x = sourceRect.right - 10;
            }
            if (cursor.y <= sourceRect.top)
            {
                cursor.y = sourceRect.top;
            }
            if (cursor.y >= sourceRect.bottom)
            {
                cursor.y = sourceRect.bottom - 10;
            }

            NativeMethods.SetCursorPos(cursor.x, cursor.y);

            // NativeMethods.ShowCursor(true);

            /*if (!mConfiguration.HideMouseCursor)
             *   NativeMethods.ShowCursor(true);
             * else
             *   NativeMethods.ShowCursor(false);
             */
            //NativeMethods.MagShowSystemCursor(FALSE);



            if (this.form == null)
            {
                timer.Enabled = false;
                return;
            }

            if (this.form.IsDisposed)
            {
                timer.Enabled = false;
                return;
            }

            // Set the source rectangle for the magnifier control.
            //NativeMethods.MagSetWindowSource(hwndMag, sourceRect);

            // setWindowsPosition();



            //Reclaim topmost status, to prevent unmagnified menus from remaining in view.
            NativeMethods.SetWindowPos(hwndMag, NativeMethods.HWND_TOPMOST, 0, 0, 0, 0, (int)SetWindowPosFlags.SWP_NOACTIVATE | (int)SetWindowPosFlags.SWP_NOMOVE | (int)SetWindowPosFlags.SWP_NOSIZE);

            //setWindowsPosition();



            // Force redraw.
            NativeMethods.InvalidateRect(hwndMag, IntPtr.Zero, true);
        }
Пример #4
0
        public void UpdateMaginifier()
        {
            if ((!initialized) || (hwndMag == IntPtr.Zero))
            {
                return;
            }


            PointF target = Cursor.Position;

            if (overlayEyeNewForm.getFreezeMode() == false && !overlayEyeNewForm.getLastMousePosition)
            {
                Point gazePoint = combineEyeGaze.GetGazePoint();
                Point warpPoint = combineEyeGaze.GetNextPoint(gazePoint);

                target = calculateTargetPoint(warpPoint);
                overlayEyeNewForm.setTargetPoint(target);
            }

            if (overlayEyeNewForm.getLastMousePosition)
            {
                POINT mousePoint = new POINT();
                NativeMethods.GetCursorPos(ref mousePoint);
                target = new Point(mousePoint.x, mousePoint.y);
                overlayEyeNewForm.setTargetPoint(target);
                lastTarget = new Point(mousePoint.x, mousePoint.y);
            }



            //***********************************************************************************************//
            RECT hostWindowRect = new RECT();

            NativeMethods.GetWindowRect(hwndMag, out hostWindowRect);


            int width  = (int)((magWindowRect.right - magWindowRect.left) / m_MAGFACTOR);
            int height = (int)((magWindowRect.bottom - magWindowRect.top) / m_MAGFACTOR);

            RECT sourceRect = getInScreenRectFromTargetPoint(target, width, height);

            // Set the magnification factor.
            NativeMethods.MagTransform matrix = new NativeMethods.MagTransform(m_MAGFACTOR);

            NativeMethods.MagSetWindowTransform(hwndMag, ref matrix);

            if (mConfiguration.HideMouseCursor == true)
            {
                NativeMethods.MagShowSystemCursor(false);
            }
            else if (mConfiguration.HideMouseCursor == false)
            {
                NativeMethods.MagShowSystemCursor(true);
            }

            setColor();

            //freeze window if user presss the f4
            if (overlayEyeNewForm.getFreezeMode() == false)
            {
                bool ret = NativeMethods.MagSetWindowSource(hwndMag, sourceRect);

                // Set the source rectangle for the magnifier control.


                POINT cursor = new POINT();
                NativeMethods.GetCursorPos(ref cursor);

                // The reason why "right" and "bottom" minus the 10 is, normally the image
                // of the cursor is shown at the bottom right of the cursor position,
                // if they don't minus some pixel, the cursor will stay outside of the magnifier.

                if (cursor.x <= sourceRect.left)
                {
                    cursor.x = sourceRect.left;
                }
                if (cursor.x >= sourceRect.right)
                {
                    cursor.x = sourceRect.right - 10;
                }
                if (cursor.y <= sourceRect.top)
                {
                    cursor.y = sourceRect.top;
                }
                if (cursor.y >= sourceRect.bottom)
                {
                    cursor.y = sourceRect.bottom - 10;
                }

                NativeMethods.SetCursorPos(cursor.x, cursor.y);
                NativeMethods.ShowCursor(true);
            }


            if (this.form == null)
            {
                timer.Enabled = false;
                return;
            }

            if (this.form.IsDisposed)
            {
                timer.Enabled = false;
                return;
            }

            // Set the source rectangle for the magnifier control.
            // NativeMethods.MagSetWindowSource(hwndMag, sourceRect);

            // setWindowsPosition();



            //Reclaim topmost status, to prevent unmagnified menus from remaining in view.
            NativeMethods.SetWindowPos(hwndMag, NativeMethods.HWND_TOPMOST, 0, 0, 0, 0, (int)SetWindowPosFlags.SWP_NOACTIVATE | (int)SetWindowPosFlags.SWP_NOMOVE | (int)SetWindowPosFlags.SWP_NOSIZE);

            //setWindowsPosition();



            // Force redraw.
            NativeMethods.InvalidateRect(hwndMag, IntPtr.Zero, true);
        }