Esempio n. 1
0
        void ContinueCalibration(PointF position)
        {
            switch (CalibrationState.State)
            {
            case 1:
                src[CalibrationState.State - 1] = position;
                CalibrationState.TargetPoint.X  = ScreenSize.Width - (int)(ScreenSize.Width * CALIBRATION_MARGIN);
                CalibrationState.TargetPoint.Y  = (int)(ScreenSize.Height * CALIBRATION_MARGIN);
                dst[CalibrationState.State]     = CalibrationState.TargetPoint;
                CalibrationState.State++;
                if (CalibrationStateChanged != null)
                {
                    CalibrationStateChanged(this, new EventArgs <CalibrationStateInfo>(CalibrationState));
                }
                break;

            case 2:
                src[CalibrationState.State - 1] = position;
                CalibrationState.TargetPoint.X  = (int)(ScreenSize.Width * CALIBRATION_MARGIN);
                CalibrationState.TargetPoint.Y  = ScreenSize.Height - (int)(ScreenSize.Height * CALIBRATION_MARGIN);
                dst[CalibrationState.State]     = CalibrationState.TargetPoint;
                CalibrationState.State++;
                if (CalibrationStateChanged != null)
                {
                    CalibrationStateChanged(this, new EventArgs <CalibrationStateInfo>(CalibrationState));
                }
                break;

            case 3:
                src[CalibrationState.State - 1] = position;
                CalibrationState.TargetPoint.X  = ScreenSize.Width - (int)(ScreenSize.Width * CALIBRATION_MARGIN);
                CalibrationState.TargetPoint.Y  = ScreenSize.Height - (int)(ScreenSize.Height * CALIBRATION_MARGIN);
                dst[CalibrationState.State]     = CalibrationState.TargetPoint;
                CalibrationState.State++;
                if (CalibrationStateChanged != null)
                {
                    CalibrationStateChanged(this, new EventArgs <CalibrationStateInfo>(CalibrationState));
                }
                break;

            case 4:
                src[CalibrationState.State - 1] = position;
                warper.setDestination(dst[0], dst[1], dst[2], dst[3]);
                warper.setSource(src[0], src[1], src[2], src[3]);
                warper.computeWarp();
                SaveConfig();
                CalibrationState.State = 0;
                if (CalibrationStateChanged != null)
                {
                    CalibrationStateChanged(this, new EventArgs <CalibrationStateInfo>(CalibrationState));
                }
                CursorEnabled = PrevCursorEnabled;
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
        public void loadCalibrationData()
        {
            // create reader & open file
            try
            {
                TextReader tr = new StreamReader("calibration.dat");
                for (int i = 0; i < 4; i++)
                {
                    srcX[i] = float.Parse(tr.ReadLine());
                    srcY[i] = float.Parse(tr.ReadLine());
                }
                smoothingAmount = int.Parse(tr.ReadLine());

                // close the stream
                tr.Close();
            }
            catch (Exception x)
            {
                Console.WriteLine(x.ToString());
                //no prexsting calibration
                return;
            }

            warper.setDestination(screenWidth * calibrationMargin,
                                  screenHeight * calibrationMargin,
                                  screenWidth * (1.0f - calibrationMargin),
                                  screenHeight * calibrationMargin,
                                  screenWidth * calibrationMargin,
                                  screenHeight * (1.0f - calibrationMargin),
                                  screenWidth * (1.0f - calibrationMargin),
                                  screenHeight * (1.0f - calibrationMargin));
            warper.setSource(srcX[0], srcY[0], srcX[1], srcY[1], srcX[2], srcY[2], srcX[3], srcY[3]);

            warper.computeWarp();

            setSmoothing(smoothingAmount);

            cursorControl = true;
            BeginInvoke((MethodInvoker) delegate() { cbCursorControl.Checked = cursorControl; });

            UpdateTrackingUtilization();
        }