private void ComputeCompleted(object sender, AsyncCompletedEventArgs<Empty> e) { _calibrationForm.Close(); if(e.Error != null) { _calibrationResult = null; } else { _calibrationResult = _tracker.GetCalibration(); } }
public static Image GetCalibrationImage(TobiiCalibration calibration) { // Create image to draw to Bitmap bitmap = new Bitmap(250, 250, PixelFormat.Format32bppArgb); Graphics graphicsDevice = Graphics.FromImage(bitmap); graphicsDevice.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; foreach(CalibrationPlotItem plotItem in calibration.Plot) { using(Pen pen = new Pen(Color.DarkGray)) { // Draw calibration points Rectangle r = GetCalibrationCircleBounds(new PointF(plotItem.TrueX, plotItem.TrueY), circleRadius); graphicsDevice.DrawEllipse(pen,r); // Draw bounds pen.Color = Color.LightGray; Rectangle canvasBounds = GetCanvasBounds(); graphicsDevice.DrawRectangle(pen,canvasBounds); // Draw errors if (plotItem.ValidityLeft == 1) { pen.Color = Color.Red; Point p1 = PixelPointFromNormalizedPoint(new PointF(plotItem.TrueX, plotItem.TrueY)); Point p2 = PixelPointFromNormalizedPoint(new PointF(plotItem.MapLeftX, plotItem.MapLeftY)); graphicsDevice.DrawLine(pen, p1, p2); } if (plotItem.ValidityRight == 1) { pen.Color = Color.Lime; Point p1 = PixelPointFromNormalizedPoint(new PointF(plotItem.TrueX, plotItem.TrueY)); Point p2 = PixelPointFromNormalizedPoint(new PointF(plotItem.MapRightX, plotItem.MapRightY)); graphicsDevice.DrawLine(pen, p1, p2); } } } return bitmap; }
private void AbortCalibration() { _calibrationResult = null; _sleepTimer.Stop(); _calibrationForm.Close(); }
private void StartNextOrFinish() { if (_calibrationForm.InvokeRequired) { _calibrationForm.Invoke(new Action(StartNextOrFinish)); return; } if(_calibrationPoints.Count > 0) { var point = _calibrationPoints.Dequeue(); _calibrationForm.DrawCalibrationPoint(point,Color.Yellow); _sleepTimer.Start(); } else { _sleepTimer.Stop(); // Use the async version of ComputeCalibration since // this call takes some time _calibrationForm.Close(); try { _tracker.ComputeCalibration(); _calibrationResult = _tracker.GetCalibration(); } catch { _calibrationResult = null; } //!!_tracker.ComputeCalibrationAsync(ComputeCompleted); } }