For connecting -
private void btnCalibrate_Click(object sender, EventArgs e)
{
if (sf == null)
{
cf = new CalibrationForm();
cf.Show();
}
if (cf.IsDisposed)
{
cf = new CalibrationForm();
cf.Show();
}
cursorControl = false;
calibrationState = 1;
doCalibration();
}
public void doCalibration(){
if (cf == null)
return;
int x = 0;
int y = 0;
int size = 25;
Pen p = new Pen(Color.Blue);
switch (calibrationState)
{
case 1:
x = (int)(screenWidth * calibrationMargin);
y = (int)(screenHeight * calibrationMargin);
cf.showCalibration(x, y, size, p);
dstX[calibrationState - 1] = x;
dstY[calibrationState - 1] = y;
break;
case 2:
x = screenWidth - (int)(screenWidth * calibrationMargin);
y = (int)(screenHeight * calibrationMargin);
cf.showCalibration(x, y, size, p);
dstX[calibrationState - 1] = x;
dstY[calibrationState - 1] = y;
break;
case 3:
x = (int)(screenWidth * calibrationMargin);
y = screenHeight -(int)(screenHeight * calibrationMargin);
cf.showCalibration(x, y, size, p);
dstX[calibrationState - 1] = x;
dstY[calibrationState - 1] = y;
break;
case 4:
x = screenWidth - (int)(screenWidth * calibrationMargin);
y = screenHeight -(int)(screenHeight * calibrationMargin);
cf.showCalibration(x, y, size, p);
dstX[calibrationState - 1] = x;
dstY[calibrationState - 1] = y;
break;
case 5:
//compute warp
warper.setDestination(dstX[0], dstY[0], dstX[1], dstY[1], dstX[2], dstY[2], dstX[3], dstY[3]);
warper.setSource(srcX[0], srcY[0], srcX[1], srcY[1], srcX[2], srcY[2], srcX[3], srcY[3]);
warper.computeWarp();
BeginInvoke((MethodInvoker)delegate() { cf.Close();});
cf = null;
calibrationState = 0;
cursorControl = true;
BeginInvoke((MethodInvoker)delegate() { cbCursorControl.Checked = cursorControl; });
// saveCalibrationData();
UpdateTrackingUtilization();
break;
default:
break;
}
}
I'd use Johnny Lees app, it works great and is open src.