Пример #1
0
        public StateManager(Form1 Toolbar, ShortcutKeyWorker shortCutKeyWorker, FormsEyeXHost EyeXHost)
        {
            eyeXHost = EyeXHost;
            toolbar  = Toolbar;

            SystemFlags.currentState = SystemState.Wait;

            fixationWorker = new FixationDetection(eyeXHost, 25);

            scrollWorker = new ScrollControl(200, 5, 50, 20, eyeXHost);

            SystemFlags.currentState = SystemState.Wait;

            SystemFlags.hasSelectedButtonColourBeenReset = true;

            // Instantiate the ZoomLens, this is the form that is given to magnifier
            zoomer = new ZoomLens();
            // Instantiate the magnifier, this is Sam Medlocks refactored magnifier
            // This calls the low-level API
            magnifier = CreateMagnifier();

            //Console.WriteLine(scrollWorker.deadZoneRect.LeftBound + "," + scrollWorker.deadZoneRect.RightBound + "," + scrollWorker.deadZoneRect.TopBound + "," + scrollWorker.deadZoneRect.BottomBound);

            this.shortCutKeyWorker = shortCutKeyWorker;

            Run();
        }
Пример #2
0
        public ZoomLens(FixationDetection FixDet, FormsEyeXHost EyeXHost)
        {
            InitializeComponent();
            lensPoint            = new Point();
            this.Width           = ZOOMLENS_SIZE;
            this.Height          = ZOOMLENS_SIZE;
            offScreenBitmap      = new Bitmap(this.Width, this.Height);
            zoomedScreenshot     = new Bitmap(this.Width / ZOOMLEVEL, this.Height / ZOOMLEVEL);
            mainCanvas           = this.CreateGraphics();
            offScreenGraphics    = Graphics.FromImage(offScreenBitmap);
            graphics             = Graphics.FromImage(zoomedScreenshot);
            this.FormBorderStyle = FormBorderStyle.None;//removes window borders from form
            fixdet = FixDet;

            gazeHighlight = new GazeHighlight(FixDet, offScreenGraphics, EHighlightShaderType.RedToGreen, this);
        }
Пример #3
0
        //Constructor
        public GazeHighlight(FixationDetection fixationWorker, Graphics zoomerCanvas, EHighlightShaderType shaderType, ZoomLens LensForm)
        {
            lensForm = LensForm;

            fixationWorker.currentProgress += setPercent;

            canvas = zoomerCanvas;

            shaderMachine = new GazeHighlightShaderFactory();

            gazeShader = shaderMachine.CreateShader(shaderType);

            fixationPercent = 0;

            currentGaze = new Point();
        }
Пример #4
0
        public StateManager_new()
        {
            /*
             * Set up the timer.
             *      - The timer will run every milisecond it can
             *      - The timer will call the RunCycle method every time it ticks
             */
            ControlTimer          = new Timer();
            ControlTimer.Interval = 1;
            ControlTimer.Enabled  = true;
            ControlTimer.Tick    += RunCycle;

            //Setup the zoom form
            zoomForm       = new ZoomLens();
            magnifier      = CreateMagnifier();
            fixationWorker = new FixationDetection();
        }
Пример #5
0
        public void EnterWaitState()
        {
            //these flags are here so that they get reset before anything else happens in the SM
            //these were previously in the action method but that causes issues because the update state is run again before all of the flags are reset.
            zoomer.ResetZoomLens();
            magnifier.Stop();
            SystemFlags.fixationRunning      = false;
            SystemFlags.actionButtonSelected = false;
            SystemFlags.fixationRunning      = false;
            SystemFlags.hasGaze = false;
            SystemFlags.timeOut = false;
            fixationWorker.IsZoomerFixation(false);
            currentState             = SystemState.Wait;
            SystemFlags.currentState = SystemState.Wait;
            zoomer.Refresh();

            fixationWorker = new FixationDetection();
        }
Пример #6
0
        public StateManager(Form1 Toolbar, ShortcutKeyWorker shortCutKeyWorker, FormsEyeXHost EyeXHost)
        {
            eyeXHost = EyeXHost;
            toolbar  = Toolbar;

            SystemFlags.currentState = SystemState.Wait;

            fixationWorker = new FixationDetection(eyeXHost);

            scrollWorker = new ScrollControl(200, 5, 50, 20, eyeXHost);

            SystemFlags.currentState = SystemState.Wait;

            SystemFlags.hasSelectedButtonColourBeenReset = true;

            zoomer = new ZoomLens(fixationWorker, eyeXHost);

            Console.WriteLine(scrollWorker.deadZoneRect.LeftBound + "," + scrollWorker.deadZoneRect.RightBound + "," + scrollWorker.deadZoneRect.TopBound + "," + scrollWorker.deadZoneRect.BottomBound);
            corner = new Corner();

            this.shortCutKeyWorker = shortCutKeyWorker;

            Run();
        }
Пример #7
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;
            }
        }