コード例 #1
0
        private void HandleEsc(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                NativeMethods.MagShowSystemCursor(true);
                mMainForm.FullScreenMouse_Button.Enabled        = true;
                mMainForm.FullscreenMaginfierEye_Button.Enabled = true;
                mMainForm.MaginfierEye_Button.Enabled           = true;
                mMainForm.MagniferUsingMouse_button.Enabled     = true;
                mMainForm.Evaluation_button.Enabled             = true;

                mMainForm.button_BackToMain.Hide();
                this.Close();
                mg.Dispose();
            }
        }
コード例 #2
0
        private void HandleEsc(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                NativeMethods.MagShowSystemCursor(true);
                this.Close();
                mg.Dispose();

                // mMainForm.Show();
            }
        }
        private void CheckForKeys()
        {
            while (checkForKeys)
            {
                //sleeping for while, this will reduce load on cpu
                Thread.Sleep(10);

                foreach (Keys key in Enum.GetValues(typeof(Keys)))
                {
                    // if key is pressed
                    if (((GetAsyncKeyState(key) & (1 << 15)) != 0))
                    {
                        // zoom in
                        if (key == Keys.Add)
                        {
                            BeginInvoke(new MethodInvoker(delegate
                            {
                                if (mConfiguration.ZoomFactor < 10f)
                                {
                                    mConfiguration.ZoomFactor++;
                                    mMainForm.label_ZoomFaktor.Text = mConfiguration.ZoomFactor.ToString();
                                }
                            }));
                            Thread.Sleep(500);
                        }

                        // zoom out
                        if (key == Keys.Subtract)
                        {
                            BeginInvoke(new MethodInvoker(delegate
                            {
                                if (mConfiguration.ZoomFactor > 1f)
                                {
                                    mConfiguration.ZoomFactor--;
                                    mMainForm.label_ZoomFaktor.Text = mConfiguration.ZoomFactor.ToString();
                                }
                            }));
                            Thread.Sleep(500);
                        }

                        // toggle fullscreen
                        if (key == Keys.Multiply)
                        {
                            if (IsNormal)
                            {
                                IsNormal = false;
                                BeginInvoke(new MethodInvoker(delegate
                                {
                                    WindowState = FormWindowState.Maximized;
                                }));
                                Thread.Sleep(500);
                            }
                            else
                            {
                                IsNormal = true;
                                BeginInvoke(new MethodInvoker(delegate
                                {
                                    WindowState = FormWindowState.Normal;
                                }));
                                Thread.Sleep(500);
                            }
                        }

                        if (key == Keys.F2)
                        {
                            if (wAIOn == false)
                            {
                                // checkForKeys = false;
                                wAIOn = true;

                                BeginInvoke(new MethodInvoker(delegate
                                {
                                    WhereAmI wAI = new WhereAmI(wWhereAmIPoint, mConfiguration);
                                    wAI.Show();

                                    temp = mConfiguration.ZoomFactor;
                                    mConfiguration.ZoomFactor = 1;

                                    if (mConfiguration.invertColors == true)
                                    {
                                        mConfiguration.invertColors = false;
                                        tempString = "invertColors";
                                    }

                                    else if (mConfiguration.normal == true)
                                    {
                                        mConfiguration.normal = false;
                                        tempString            = "normal";
                                    }

                                    else if (mConfiguration.achromatomaly == true)
                                    {
                                        mConfiguration.achromatomaly = false;
                                        tempString = "achromatomaly";
                                    }

                                    else if (mConfiguration.achromatopsia == true)
                                    {
                                        mConfiguration.achromatopsia = false;
                                        tempString = "achromatopsia";
                                    }
                                    else if (mConfiguration.deuteranopia == true)
                                    {
                                        mConfiguration.deuteranopia = false;
                                        tempString = "deuteranopia";
                                    }
                                    else if (mConfiguration.deuteranomaly == true)
                                    {
                                        mConfiguration.deuteranomaly = false;
                                        tempString = "deuteranomaly";
                                    }
                                    else if (mConfiguration.protanomaly == true)
                                    {
                                        mConfiguration.protanomaly = false;
                                        tempString = "protanomaly";
                                    }
                                    else if (mConfiguration.protanopia == true)
                                    {
                                        mConfiguration.protanopia = false;
                                        tempString = "protanopia";
                                    }
                                    else if (mConfiguration.tritanomaly == true)
                                    {
                                        mConfiguration.tritanomaly = false;
                                        tempString = "tritanomaly";
                                    }
                                    else if (mConfiguration.tritanopia == true)
                                    {
                                        mConfiguration.tritanopia = false;
                                        tempString = "tritanopia";
                                    }

                                    mConfiguration.normal = true;
                                }));

                                Thread.Sleep(500);
                            }
                            else if (wAIOn == true)
                            {
                                wAIOn = false;

                                BeginInvoke(new MethodInvoker(delegate
                                {
                                    List <Form> forms = new List <Form>();

                                    foreach (Form f in Application.OpenForms)
                                    {
                                        if (f.Name == "WhereAmI")
                                        {
                                            forms.Add(f);
                                        }
                                    }

                                    // Now let's close opened myForm instances from aother thread
                                    if (forms.Count > 0)
                                    {
                                        foreach (Form f in forms)
                                        {
                                            f.Close();
                                        }
                                    }

                                    mConfiguration.normal     = false;
                                    mConfiguration.ZoomFactor = temp;

                                    if (tempString == "invertColors")
                                    {
                                        mConfiguration.invertColors = true;
                                    }

                                    else if (tempString == "normal")
                                    {
                                        mConfiguration.normal = true;
                                    }

                                    else if (tempString == "achromatomaly")
                                    {
                                        mConfiguration.achromatomaly = true;
                                    }

                                    else if (tempString == "achromatopsia")
                                    {
                                        mConfiguration.achromatopsia = true;
                                    }
                                    else if (tempString == "deuteranopia")
                                    {
                                        mConfiguration.deuteranopia = true;
                                    }
                                    else if (tempString == "deuteranomaly")
                                    {
                                        mConfiguration.deuteranomaly = true;
                                    }
                                    else if (tempString == "protanomaly")
                                    {
                                        mConfiguration.protanomaly = true;
                                    }
                                    else if (tempString == "protanopia")
                                    {
                                        mConfiguration.protanopia = true;
                                    }
                                    else if (tempString == "tritanomaly")
                                    {
                                        mConfiguration.tritanomaly = true;
                                    }
                                    else if (tempString == "tritanopia")
                                    {
                                        mConfiguration.tritanopia = true;
                                    }
                                }));

                                Thread.Sleep(500);
                            }
                        }

                        if (key == Keys.F3)
                        {
                            BeginInvoke(new MethodInvoker(delegate
                            {
                                mMainForm.Location    = Cursor.Position;
                                mMainForm.WindowState = FormWindowState.Normal;
                            }));

                            Thread.Sleep(500);
                        }


                        // exit form
                        if (key == Keys.Escape)
                        {
                            BeginInvoke(new MethodInvoker(delegate
                            {
                                NativeMethods.MagShowSystemCursor(true);
                                mMainForm.FullScreenMouse_Button.Enabled        = true;
                                mMainForm.FullscreenMaginfierEye_Button.Enabled = true;
                                mMainForm.MaginfierEye_Button.Enabled           = true;
                                mMainForm.MagniferUsingMouse_button.Enabled     = true;
                                mMainForm.Evaluation_button.Enabled             = true;

                                checkForKeys = false;
                                mMainForm.button_BackToMain.Hide();
                                this.Close();
                                mg.Dispose();
                            }));
                            Thread.Sleep(500);
                        }
                    }
                }
            }
        }
コード例 #4
0
        private void CheckForKeys()
        {
            //controlKey = false;
            //iKey = false;

            while (checkForKeys)
            {
                //sleeping for while, this will reduce load on cpu
                Thread.Sleep(10);
                foreach (Keys key in Enum.GetValues(typeof(Keys)))
                {
                    // if key is pressed
                    if (((GetAsyncKeyState(key) & (1 << 15)) != 0))
                    {
                        // zoom in
                        if (key == Keys.F6)
                        {
                            BeginInvoke(new MethodInvoker(delegate
                            {
                                if (mConfiguration.ZoomFactor < 10f)
                                {
                                    mConfiguration.ZoomFactor++;
                                    mMainForm.label_ZoomFaktor.Text = mConfiguration.ZoomFactor.ToString();
                                }
                            }));
                            Thread.Sleep(500);
                        }

                        // zoom out
                        if (key == Keys.F5)
                        {
                            BeginInvoke(new MethodInvoker(delegate
                            {
                                if (mConfiguration.ZoomFactor > 1f)
                                {
                                    mConfiguration.ZoomFactor--;
                                    mMainForm.label_ZoomFaktor.Text = mConfiguration.ZoomFactor.ToString();
                                }
                            }));
                            Thread.Sleep(500);
                        }



                        // toggle fullscreen
                        if (key == Keys.Multiply)
                        {
                            if (IsNormal)
                            {
                                IsNormal = false;
                                BeginInvoke(new MethodInvoker(delegate
                                {
                                    WindowState = FormWindowState.Maximized;
                                }));
                                Thread.Sleep(500);
                            }
                            else
                            {
                                IsNormal = true;
                                BeginInvoke(new MethodInvoker(delegate
                                {
                                    WindowState = FormWindowState.Normal;
                                }));
                                Thread.Sleep(500);
                            }
                        }

                        if (key == Keys.F2)
                        {
                            if (wAIOn == false)
                            {
                                // checkForKeys = false;


                                // WhereAmI wAI = new WhereAmI(wWhereAmIPoint, mConfiguration);
                                // wAI.Show();

                                BeginInvoke(new MethodInvoker(delegate
                                {
                                    temp = mConfiguration.ZoomFactor;
                                    mConfiguration.ZoomFactor = 1;

                                    if (mConfiguration.invertColors == true)
                                    {
                                        mConfiguration.invertColors = false;
                                        tempString = "invertColors";
                                    }

                                    else if (mConfiguration.normal == true)
                                    {
                                        mConfiguration.normal = false;
                                        tempString            = "normal";
                                    }

                                    else if (mConfiguration.achromatomaly == true)
                                    {
                                        mConfiguration.achromatomaly = false;
                                        tempString = "achromatomaly";
                                    }

                                    else if (mConfiguration.achromatopsia == true)
                                    {
                                        mConfiguration.achromatopsia = false;
                                        tempString = "achromatopsia";
                                    }
                                    else if (mConfiguration.deuteranopia == true)
                                    {
                                        mConfiguration.deuteranopia = false;
                                        tempString = "deuteranopia";
                                    }
                                    else if (mConfiguration.deuteranomaly == true)
                                    {
                                        mConfiguration.deuteranomaly = false;
                                        tempString = "deuteranomaly";
                                    }
                                    else if (mConfiguration.protanomaly == true)
                                    {
                                        mConfiguration.protanomaly = false;
                                        tempString = "protanomaly";
                                    }
                                    else if (mConfiguration.protanopia == true)
                                    {
                                        mConfiguration.protanopia = false;
                                        tempString = "protanopia";
                                    }
                                    else if (mConfiguration.tritanomaly == true)
                                    {
                                        mConfiguration.tritanomaly = false;
                                        tempString = "tritanomaly";
                                    }
                                    else if (mConfiguration.tritanopia == true)
                                    {
                                        mConfiguration.tritanopia = false;
                                        tempString = "tritanopia";
                                    }

                                    mConfiguration.normal = true;
                                }));

                                Thread.Sleep(500);
                                wAIOn = true;
                            }
                            else if (wAIOn == true)
                            {
                                wAIOn = false;

                                BeginInvoke(new MethodInvoker(delegate
                                {
                                    List <Form> forms = new List <Form>();

                                    foreach (Form f in Application.OpenForms)
                                    {
                                        if (f.Name == "WhereAmI")
                                        {
                                            forms.Add(f);
                                        }
                                    }

                                    // Now let's close opened myForm instances from aother thread
                                    if (forms.Count > 0)
                                    {
                                        foreach (Form f in forms)
                                        {
                                            f.Close();
                                        }
                                    }


                                    mConfiguration.normal     = false;
                                    mConfiguration.ZoomFactor = temp;

                                    if (tempString == "invertColors")
                                    {
                                        mConfiguration.invertColors = true;
                                    }

                                    else if (tempString == "normal")
                                    {
                                        mConfiguration.normal = true;
                                    }

                                    else if (tempString == "achromatomaly")
                                    {
                                        mConfiguration.achromatomaly = true;
                                    }

                                    else if (tempString == "achromatopsia")
                                    {
                                        mConfiguration.achromatopsia = true;
                                    }
                                    else if (tempString == "deuteranopia")
                                    {
                                        mConfiguration.deuteranopia = true;
                                    }
                                    else if (tempString == "deuteranomaly")
                                    {
                                        mConfiguration.deuteranomaly = true;
                                    }
                                    else if (tempString == "protanomaly")
                                    {
                                        mConfiguration.protanomaly = true;
                                    }
                                    else if (tempString == "protanopia")
                                    {
                                        mConfiguration.protanopia = true;
                                    }
                                    else if (tempString == "tritanomaly")
                                    {
                                        mConfiguration.tritanomaly = true;
                                    }
                                    else if (tempString == "tritanopia")
                                    {
                                        mConfiguration.tritanopia = true;
                                    }
                                }));

                                Thread.Sleep(500);
                            }
                        }

                        if (key == Keys.F3)
                        {
                            BeginInvoke(new MethodInvoker(delegate
                            {
                                mMainForm.Location = Cursor.Position;



                                NativeMethods.SetWindowPos(mMainForm.Handle, 0, 0, 0, 0, 0, 0x0002 | 0x0001);
                                NativeMethods.ShowWindow(mMainForm.Handle, 5);
                                NativeMethods.SetForegroundWindow(mMainForm.Handle);
                                NativeMethods.SetFocus(mMainForm.Handle);

                                mMainForm.Left = (int)Cursor.Position.X - mMainForm.Width / 2;
                                mMainForm.Top  = (int)Cursor.Position.Y - mMainForm.Height / 2;

                                if (mMainForm.Left < 0)
                                {
                                    mMainForm.Left = 0;
                                }
                                if (mMainForm.Left > Screen.PrimaryScreen.Bounds.Width - mMainForm.Width)
                                {
                                    mMainForm.Left = Screen.PrimaryScreen.Bounds.Width - mMainForm.Width;
                                }


                                if (mMainForm.Top < 0)
                                {
                                    mMainForm.Top = 0;
                                }
                                if (mMainForm.Top > Screen.PrimaryScreen.Bounds.Height - mMainForm.Height)
                                {
                                    mMainForm.Top = Screen.PrimaryScreen.Bounds.Height - mMainForm.Height;
                                }


                                mMainForm.WindowState = FormWindowState.Normal;
                            }));

                            Thread.Sleep(500);
                        }

                        // exit form
                        if (key == Keys.Escape)
                        {
                            BeginInvoke(new MethodInvoker(delegate
                            {
                                NativeMethods.MagShowSystemCursor(true);

                                mMainForm.TobiiCalibration_button.Enabled       = true;
                                mMainForm.FullScreenMouse_Button.Enabled        = true;
                                mMainForm.FullscreenMaginfierEye_Button.Enabled = true;
                                mMainForm.MaginfierEye_Button.Enabled           = true;
                                mMainForm.MagniferUsingMouse_button.Enabled     = true;
                                mMainForm.Evaluation_button.Enabled             = true;

                                checkForKeys = false;
                                this.Close();
                                mg.Dispose();
                            }));
                            Thread.Sleep(500);
                        }


                        //invert colors
                        if (key == Keys.F9)
                        {
                            if (mConfiguration.invertColors == true)
                            {
                                BeginInvoke(new MethodInvoker(delegate
                                {
                                    mConfiguration.normal        = true;
                                    mConfiguration.invertColors  = false;
                                    mConfiguration.achromatomaly = false;
                                    mConfiguration.achromatopsia = false;
                                    mConfiguration.deuteranopia  = false;
                                    mConfiguration.deuteranomaly = false;
                                    mConfiguration.protanomaly   = false;
                                    mConfiguration.protanopia    = false;
                                    mConfiguration.tritanomaly   = false;
                                    mConfiguration.tritanopia    = false;
                                }));
                                Thread.Sleep(500);
                            }

                            else if (mConfiguration.invertColors == false)
                            {
                                BeginInvoke(new MethodInvoker(delegate
                                {
                                    mConfiguration.normal        = false;
                                    mConfiguration.invertColors  = true;
                                    mConfiguration.achromatomaly = false;
                                    mConfiguration.achromatopsia = false;
                                    mConfiguration.deuteranopia  = false;
                                    mConfiguration.deuteranomaly = false;
                                    mConfiguration.protanomaly   = false;
                                    mConfiguration.protanopia    = false;
                                    mConfiguration.tritanomaly   = false;
                                    mConfiguration.tritanopia    = false;
                                }));
                                Thread.Sleep(500);
                            }
                        }


                        //Windows Magnification Size
                        if (key == Keys.F8)
                        {
                            if (Screen.PrimaryScreen.Bounds.Height - mConfiguration.MagnifierHeight >= 10 && Screen.PrimaryScreen.Bounds.Width - mConfiguration.MagnifierWidth >= 10)
                            {
                                if (mConfiguration.MagnifierHeight <= (Screen.PrimaryScreen.Bounds.Height / 10) * 9 && mConfiguration.MagnifierWidth <= Screen.PrimaryScreen.Bounds.Width - 30)
                                {
                                    BeginInvoke(new MethodInvoker(delegate
                                    {
                                        mConfiguration.MagnifierHeight += 10;
                                        mConfiguration.MagnifierWidth  += 10;
                                    }));
                                    Thread.Sleep(500);
                                }
                            }
                        }


                        if (key == Keys.F7)
                        {
                            if (mConfiguration.MagnifierHeight > (Screen.PrimaryScreen.Bounds.Height / 10) && mConfiguration.MagnifierWidth > (Screen.PrimaryScreen.Bounds.Width / 10))
                            {
                                if (mConfiguration.MagnifierHeight > Screen.PrimaryScreen.Bounds.Height / 9 && mConfiguration.MagnifierWidth != Screen.PrimaryScreen.Bounds.Width / 9)
                                {
                                    BeginInvoke(new MethodInvoker(delegate
                                    {
                                        mConfiguration.MagnifierHeight -= 10;
                                        mConfiguration.MagnifierWidth  -= 10;
                                    }));
                                    Thread.Sleep(500);
                                }
                            }
                        }

                        /*if (key == Keys.F11)
                         * {
                         *  foreach (Form f in Application.OpenForms)
                         *      if (f.Name == "ConfigurationForm")
                         *      {
                         *          Console.WriteLine(f.Location);
                         *          Thread.Sleep(500);
                         *
                         *          BeginInvoke(new MethodInvoker(delegate
                         *          {
                         *              Cursor.Position = f.Location;
                         *          }));
                         *
                         *      }
                         *
                         *
                         *
                         * }*/
                    }
                }
            }
        }