/// <summary> /// Starts calibration. /// </summary> /// <param name="isRecalibrating"> /// whether to use recalibration or not. /// </param> /// <returns> /// <strong>True</strong> if calibration succeded, otherwise /// <strong>false</strong>. /// </returns> public override bool Calibrate(bool isRecalibrating) { try { // Should hide TrackStatusDlg if (this.dlgTrackStatus != null) { this.ShowOnSecondaryScreenButton.BackColor = Color.Transparent; this.ShowOnSecondaryScreenButton.Text = "Show on presentation screen"; this.dlgTrackStatus.Close(); } var pointCount = 9; switch (this.theEyeTribeSettings.CalibrationPointCount) { case TheEyeTribeCalibrationPoints.Nine: pointCount = 9; break; case TheEyeTribeCalibrationPoints.Twelve: pointCount = 12; break; case TheEyeTribeCalibrationPoints.Sixteen: pointCount = 16; break; } // Start a new calibration procedure var calRunner = new CalibrationRunner( PresentationScreen.GetPresentationScreen(), PresentationScreen.GetPresentationBounds().Size, pointCount); calRunner.BackgroundColor = new System.Windows.Media.SolidColorBrush(ToMediaColor(this.theEyeTribeSettings.CalibrationBackgroundColor)); calRunner.HelpVisibility = this.theEyeTribeSettings.DisplayHelp ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; calRunner.PointColor = new System.Windows.Media.SolidColorBrush(ToMediaColor(this.theEyeTribeSettings.CalibrationPointColor)); calRunner.PointRecordingTime = this.theEyeTribeSettings.PointDisplayTime; calRunner.Start(); // blocks until complete calRunner.OnResult += calRunner_OnResult; } catch (Exception ex) { InformationDialog.Show( "Calibration failed", "TheEyeTribe calibration failed with the following message: " + Environment.NewLine + ex.Message, false, MessageBoxIcon.Error); this.CleanUp(); return(false); } return(true); }
/// <summary> /// Connects this instance to the haytham server. /// </summary> /// <returns> /// Returns true if successful. /// </returns> public bool Connect() { this.TcpClient = new TcpClient(); try { this.TcpClient.Connect(this.ServerIPAddress, 50000); this.Stream = this.TcpClient.GetStream(); this.Writer = new BinaryWriter(this.Stream); this.Reader = new BinaryReader(this.Stream); // send name and type this.Writer.Write("Monitor"); // type this.Writer.Write("Ogama"); // name this.ClientName = this.Reader.ReadString(); // get approved name this.presentationScreenSize = Document.ActiveDocument.PresentationSize; if (this.TcpClient.Connected) { // Send "Status_Gaze" -> false to not receive default gaze data this.Writer.Write("Status_Gaze"); this.Writer.Write("False"); // Send "Status_Commands" -> true to receive commands, especially calibration finished message this.Writer.Write("Status_Commands"); this.Writer.Write("True"); // Send "Status_Eye" -> true to receive complete gaze data this.Writer.Write("Status_Eye"); this.Writer.Write("True"); // Send "Size" with values to set tracking size this.Writer.Write("Size"); this.Writer.Write(this.presentationScreenSize.Width); this.Writer.Write(this.presentationScreenSize.Height); this.Writer.Write("PresentationScreen"); this.Writer.Write(PresentationScreen.GetPresentationScreen().Primary); // start a new thread for receiving messages this.inputoutputThread = new Thread(this.ListenThread); this.isRunning = true; this.inputoutputThread.Start(); } } catch (Exception) { return(false); } return(true); }