static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            pgmf = new PrecisionGazeMouseForm();

            // Handle the ApplicationExit event to know when the application is exiting.
            Application.ApplicationExit += new EventHandler(OnApplicationExit);

            //Whenever a new version of the application is made, this ensures that user's previous settings are not lost
            Properties.Settings.Default.Upgrade();
            Properties.Settings.Default.Reload();

            //Set process dpi awareness
            SetDpiAwareness(ProcessDPIAwareness.ProcessSystemDPIAware);

            Application.Run(pgmf);
        }
Example #2
0
        private Point limitToScreenBounds(Point p)
        {
            Rectangle screenSize = PrecisionGazeMouseForm.GetScreenSize();
            int       margin     = 10;

            if (p.X < margin)
            {
                p.X = margin;
            }
            if (p.Y < margin)
            {
                p.Y = margin;
            }
            if (p.X >= screenSize.Width - margin)
            {
                p.X = screenSize.Width - margin;
            }
            if (p.Y >= screenSize.Height - margin - 5)
            {
                p.Y = screenSize.Height - margin - 5;
            }

            return(p);
        }
Example #3
0
        private Point getScreenCenter()
        {
            Rectangle screenSize = PrecisionGazeMouseForm.GetScreenSize();

            return(new Point(screenSize.Width / 2, screenSize.Height / 2));
        }
Example #4
0
 public MouseController(PrecisionGazeMouseForm form)
 {
     this.form = form;
 }
        private void gazeButton_Click(object sender, EventArgs e)
        {
            Logger.WriteEvent();

            Button           clickedButton = (Button)sender;
            GAZE_BUTTON_TYPE gb            = GAZE_BUTTON_TYPE.NONE;

            if (clickedButton.Text.Equals(gazeButtonTextStrings[(int)GAZE_BUTTON_TYPE.UP]))
            {
                PrecisionGazeMouseForm.nextClickType = PrecisionGazeMouseForm.NEXTCLICKTYPE.SCROLLUP;
                gb = GAZE_BUTTON_TYPE.UP;
            }
            else if (clickedButton.Text.Equals(gazeButtonTextStrings[(int)GAZE_BUTTON_TYPE.DOWN]))
            {
                PrecisionGazeMouseForm.nextClickType = PrecisionGazeMouseForm.NEXTCLICKTYPE.SCROLLDOWN;
                gb = GAZE_BUTTON_TYPE.DOWN;
            }
            else if (clickedButton.Text.Equals(gazeButtonTextStrings[(int)GAZE_BUTTON_TYPE.LEFTCLICK]))
            {
                PrecisionGazeMouseForm.nextClickType = PrecisionGazeMouseForm.NEXTCLICKTYPE.LEFT;
                gb = GAZE_BUTTON_TYPE.LEFTCLICK;
            }
            else if (clickedButton.Text.Equals(gazeButtonTextStrings[(int)GAZE_BUTTON_TYPE.DOUBLECLICK]))
            {
                PrecisionGazeMouseForm.nextClickType = PrecisionGazeMouseForm.NEXTCLICKTYPE.DOUBLECLICK;
                gb = GAZE_BUTTON_TYPE.DOUBLECLICK;
            }
            else if (clickedButton.Text.Equals(gazeButtonTextStrings[(int)GAZE_BUTTON_TYPE.RIGHTCLICK]))
            {
                PrecisionGazeMouseForm.nextClickType = PrecisionGazeMouseForm.NEXTCLICKTYPE.RIGHT;
                gb = GAZE_BUTTON_TYPE.RIGHTCLICK;
            }
            else if (clickedButton.Text.Equals(gazeButtonTextStrings[(int)GAZE_BUTTON_TYPE.KEYBOARD]))
            {
                long currentTimestamp = PrecisionGazeMouseForm.GetCurrentTimestamp();
                long timestampDiff    = currentTimestamp - keyboardSelectedTimestamp;

                //Want to give at least a second before it can be toggled again so that user has a chance to move their eyes away from the button
                if (timestampDiff > 1000)
                {
                    //We essentially toggle the keyboard
                    if (IpcServerData.showKeyboard == KEYBOARD_SHOWN_STATUS.NOT_SHOWN)
                    {
                        IpcServerData.showKeyboard = KEYBOARD_SHOWN_STATUS.SHOW_BOTTOM;
                        gb = GAZE_BUTTON_TYPE.KEYBOARD;
                    }
                    else //we hide the keyboard since it was already active
                    {
                        IpcServerData.showKeyboard = KEYBOARD_SHOWN_STATUS.NOT_SHOWN;
                        gb = GAZE_BUTTON_TYPE.LEFTCLICK; //maintain left click status
                    }
                    keyboardSelectedTimestamp = currentTimestamp;
                }
            }
            else //default to NONE
            {
                PrecisionGazeMouseForm.nextClickType = PrecisionGazeMouseForm.NEXTCLICKTYPE.NONE;
            }

            Logger.WriteVar(nameof(gb), gb);
            SetActiveGazeButton(gb);
        }
 public UserSettingsForm(PrecisionGazeMouseForm pgmf)
 {
     InitializeComponent();
     this.pgmf = pgmf;
 }