Exemple #1
0
        public void RefreshZoom()
        {
            magnifier.Stop();

            zoomer    = new ZoomLens();
            magnifier = CreateMagnifier();
            zoomer.ResetZoomLens();
            magnifier.ResetZoomValue();
            EnterWaitState();
        }
Exemple #2
0
        //The action state is responsible for completing each action that must take place during each state
        public void Action()
        {
            switch (SystemFlags.currentState)
            {
            case SystemState.Wait:
                scrollWorker.stopScroll();
                if (SystemFlags.hasSelectedButtonColourBeenReset == false)
                {
                    toolbar.resetButtonsColor();
                    SystemFlags.hasSelectedButtonColourBeenReset = true;
                }
                break;

            case SystemState.ActionButtonSelected:
                scrollWorker.stopScroll();
                if (!SystemFlags.fixationRunning)
                {
                    fixationWorker.StartDetectingFixation();
                    SystemFlags.fixationRunning = true;
                }
                if (Program.readSettings.selectionFeedback)     //don't show the crosshair if selection feedback is off
                {
                    zoomer.Start();
                    zoomer.Show();
                    zoomer.CrossHairPos = fixationWorker.getXY();
                }
                break;

            case SystemState.Zooming:
                scrollWorker.stopScroll();
                fixationWorker.IsZoomerFixation(true);
                if (SystemFlags.shortCutKeyPressed)    //if a user defined click key is pressed
                {
                    fixationPoint = shortCutKeyWorker.GetXY();
                    SystemFlags.shortCutKeyPressed = false;
                }
                else
                {
                    fixationPoint = fixationWorker.getXY();    //get the location the user looked
                }
                magnifier.Timer.Enabled = true;
                // magnifier.UpdatePosition(fixationPoint);
                // Give the magnifier the point on screen to magnify
                magnifier.FixationPoint = fixationPoint;
                Point p1 = Utils.DividePoint(magnifier.Offset, magnifier.MagnifierDivAmount());
                Point p2 = Utils.DividePoint(magnifier.SecondaryOffset, magnifier.MagnifierDivAmount());

                Point o = Utils.SubtractPoints(p1, p2);

                zoomer.Offset = o;                        // This initiate's the timer for drawing of the user feedback image
                zoomer.Start();
                zoomer.Show();
                zoomer.CrossHairPos = magnifier.GetLookPosition();

                //disable neccesary flags
                SystemFlags.hasGaze         = false;
                SystemFlags.fixationRunning = false;
                break;

            case SystemState.ZoomWait:    //waiting for user to fixate
                if (!SystemFlags.fixationRunning)
                {
                    fixationWorker.StartDetectingFixation();
                    SystemFlags.fixationRunning = true;
                }
                zoomer.CrossHairPos = magnifier.GetLookPosition();
                //SetZoomerOffset();
                break;

            case SystemState.ApplyAction:     //the fixation on the zoom lens has been detected
                fixationPoint = fixationWorker.getXY();

                //SetZoomerOffset();

                fixationPoint.X += zoomer.Offset.X;
                fixationPoint.Y += zoomer.Offset.Y;

                fixationPoint = magnifier.GetLookPosition();
                zoomer.ResetZoomLens();    //hide the lens
                                           //  MessageBox.Show(magnifier.SecondaryOffset.X + " " + magnifier.SecondaryOffset.Y);
                                           //Set the magnification factor back to initial value
                                           // This is done so that a "dynamic zoom in" feature can be
                                           // implemented in the future
                magnifier.ResetZoomValue();
                magnifier.Stop();


                //execute the appropriate action
                if (SystemFlags.actionToBePerformed == ActionToBePerformed.LeftClick)
                {
                    VirtualMouse.LeftMouseClick(fixationPoint.X, fixationPoint.Y);
                }
                else if (SystemFlags.actionToBePerformed == ActionToBePerformed.RightClick)
                {
                    VirtualMouse.RightMouseClick(fixationPoint.X, fixationPoint.Y);
                }
                else if (SystemFlags.actionToBePerformed == ActionToBePerformed.DoubleClick)
                {
                    VirtualMouse.LeftDoubleClick(fixationPoint.X, fixationPoint.Y);
                }
                else if (SystemFlags.actionToBePerformed == ActionToBePerformed.Scroll)
                {
                    SystemFlags.currentState = SystemState.ScrollWait;
                    SystemFlags.scrolling    = true;
                    VirtualMouse.SetCursorPos(fixationPoint.X, fixationPoint.Y);
                    scrollWorker.StartScroll();
                }
                else if (SystemFlags.actionToBePerformed == ActionToBePerformed.MicInput)
                {
                    if (Program.readSettings.micInput != Constants.KEY_FUNCTION_UNASSIGNED_MESSAGE)
                    {
                        if (!micIsOn)
                        {
                            VirtualMouse.LeftMouseClick(fixationPoint.X, fixationPoint.Y);
                            SendKeys.Send(Program.readSettings.micInput);
                            SystemFlags.hasSelectedButtonColourBeenReset = true;
                            micIsOn = true;
                        }
                        else
                        {
                            SendKeys.Send(Program.readSettings.micInputOff);
                            SystemFlags.hasSelectedButtonColourBeenReset = false;
                            micIsOn = false;
                        }
                    }
                }
                fixationWorker = new FixationDetection();
                break;
            }
        }