private void UpdateWindowPosition(SynchroGazerSetting setting)
        {
            Process p = null;

            try
            {
                p = Process.GetProcessById(_targetProcessId);
            }
            catch (ArgumentException)
            {
                //終了済みプロセス指定すると起きる -> そのままガードで弾いて無視
            }

            if (p == null)
            {
                return;
            }

            IntPtr hWnd = p.MainWindowHandle;

            if (hWnd == IntPtr.Zero)
            {
                return;
            }

            //NOTE: ほんとうはディスプレイ番号とかも設定から引っ張ってこないとダメか?
            var screen =
                (setting.ScreenNumber > 0 &&
                 setting.ScreenNumber <= Screen.AllScreens.Length) ?
                Screen.AllScreens[setting.ScreenNumber - 1] :
                Screen.PrimaryScreen;
            var screenBound = screen.WorkingArea;

            int width = 400 * setting.WindowSizeRate / 100;

            switch (setting.Location)
            {
            case CharacterLocations.Left:
                MoveWindow(hWnd, screenBound.Left, screenBound.Bottom - width, width, width, false);
                break;

            case CharacterLocations.Right:
                MoveWindow(hWnd, screenBound.Right - width, screenBound.Bottom - width, width, width, false);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        private static MouseActionTypes GetMouseActionTypeFrom(
            BlinkActionTypes blinkAction,
            GazeActionTypes gazeAction,
            SynchroGazerSetting setting
            )
        {
            //ガード: Wink以外禁止してるとき
            if (setting.AllowOnlyWink && blinkAction == BlinkActionTypes.Blink)
            {
                return(MouseActionTypes.None);
            }

            //中央クリックは問答無用で中央クリックにマッピング(これでいいのかという話もあるが)
            if (gazeAction == GazeActionTypes.CenterClick)
            {
                return(MouseActionTypes.CenterClick);
            }

            //シングル or ダブルクリック -> 反転設定をチェックしつつ。

            if (gazeAction == GazeActionTypes.SingleClick)
            {
                switch (blinkAction)
                {
                case BlinkActionTypes.Blink:
                    return(MouseActionTypes.LeftSingleClick);

                case BlinkActionTypes.LeftEyeClosedBlink:
                    return((setting.IsReverseMode) ?
                           MouseActionTypes.RightSingleClick :
                           MouseActionTypes.LeftSingleClick);

                case BlinkActionTypes.RightEyeClosedBlink:
                    return((setting.IsReverseMode) ?
                           MouseActionTypes.LeftSingleClick :
                           MouseActionTypes.RightSingleClick);
                }
            }

            if (gazeAction == GazeActionTypes.DoubleClick)
            {
                switch (blinkAction)
                {
                case BlinkActionTypes.Blink:
                    return(MouseActionTypes.LeftDoubleClick);

                case BlinkActionTypes.LeftEyeClosedBlink:
                    return((setting.IsReverseMode) ?
                           MouseActionTypes.RightDoubleClick :
                           MouseActionTypes.LeftDoubleClick);

                case BlinkActionTypes.RightEyeClosedBlink:
                    return((setting.IsReverseMode) ?
                           MouseActionTypes.LeftDoubleClick :
                           MouseActionTypes.RightDoubleClick);
                }
            }

            //ここには来ないはず
            return(MouseActionTypes.None);
        }