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);

            PointF target = 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);



            // 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();
            // 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);
        }
Exemplo n.º 2
0
        //private WarpPointer warp;

        public virtual void UpdateMaginifier()
        {
            if ((!initialized) || (hwndMag == IntPtr.Zero))
            {
                return;
            }

            //*************************Take poit From head**********************************************//

            PointF target = Cursor.Position;

            if (overlayEyeNewForm.getFreezeMode() == false && !overlayEyeNewForm.getLastMousePosition)
            {
                Vector3 headPoint = headPoints.GetHeadPoint();

                Point warpPoint = headPoints.GetNextPoint(new Point(this.overlayEyeNewForm.Width / 2, this.overlayEyeNewForm.Height / 2));

                target = calculateTargetPoint(warpPoint);

                overlayEyeNewForm.setTargetPoint(target);
                overlayEyeNewForm.setWhereAmIPoint(Cursor.Position);
            }

            else 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(mConfiguration.ZoomFactor);
            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;
            }


            //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);
        }
Exemplo n.º 3
0
        public virtual void UpdateMaginifier()
        {
            if ((!initialized) || (hwndMag == IntPtr.Zero))
            {
                return;
            }

            //*************************Take Mouse Point**********************************************//

            POINT mousePoint = new POINT();
            RECT  sourceRect = new RECT();

            NativeMethods.GetCursorPos(ref mousePoint);
            mouseMoveMagnifierForm.mTargetPoint = new Point(mousePoint.x, mousePoint.y);



            //***************************************************************************************//



            //NativeMethods.GetCursorPos(ref mousePoint);

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

            sourceRect.left = mousePoint.x - width / 2;
            sourceRect.top  = mousePoint.y - height / 2;

            // Set the magnification factor.
            NativeMethods.MagTransform matrix = new NativeMethods.MagTransform(mConfiguration.ZoomFactor);
            NativeMethods.MagSetWindowTransform(hwndMag, ref matrix);

            // Don't scroll outside desktop area.
            if (sourceRect.left < 0)
            {
                sourceRect.left = 0;
            }
            if (sourceRect.left > NativeMethods.GetSystemMetrics(NativeMethods.SM_CXSCREEN) - width)
            {
                sourceRect.left = NativeMethods.GetSystemMetrics(NativeMethods.SM_CXSCREEN) - width;
            }
            sourceRect.right = sourceRect.left + width;

            if (sourceRect.top < 0)
            {
                sourceRect.top = 0;
            }
            if (sourceRect.top > NativeMethods.GetSystemMetrics(NativeMethods.SM_CYSCREEN) - height)
            {
                sourceRect.top = NativeMethods.GetSystemMetrics(NativeMethods.SM_CYSCREEN) - height;
            }
            sourceRect.bottom = sourceRect.top + height;

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

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


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

            setColor();


            // 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(form.Handle, NativeMethods.HWND_TOPMOST, 0, 0, 0, 0,
                                       (int)SetWindowPosFlags.SWP_NOACTIVATE | (int)SetWindowPosFlags.SWP_NOMOVE | (int)SetWindowPosFlags.SWP_NOSIZE);


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