/// <summary>
        ///   Raises <see cref="TheEyeTribeSettingsDialog" /> to change the settings
        ///   for this interface.
        /// </summary>
        public override void ChangeSettings()
        {
            var dlg = new TheEyeTribeSettingsDialog {
                TheEyeTribeSettings = this.theEyeTribeSettings
            };

            switch (dlg.ShowDialog())
            {
            case DialogResult.OK:
                var oldServerStartParams = this.theEyeTribeSettings.ServerStartParams;
                this.theEyeTribeSettings = dlg.TheEyeTribeSettings;
                this.SerializeSettings(this.theEyeTribeSettings, this.SettingsFile);

                if (this.theEyeTribeSettings.ServerStartParams != oldServerStartParams)
                {
                    // Need to restart the eye tribe server if it is running
                    if (IOHelpers.IsProcessOpen("EyeTribe"))
                    {
                        this.KillEyeTribeProcess();

                        // Now restart
                        this.StartEyeTribeProcess();
                    }
                }

                break;
            }
        }
Exemple #2
0
        ///////////////////////////////////////////////////////////////////////////////
        // Public methods                                                            //
        ///////////////////////////////////////////////////////////////////////////////
        #region PUBLICMETHODS

        /// <summary>
        /// Checks if the alea tracker is available in the system.
        /// </summary>
        /// <param name="errorMessage">Out. A <see cref="String"/> with an error message.</param>
        /// <returns><strong>True</strong>, if Alea tracker with intelligaze
        /// is available in the system, otherwise <strong>false</strong></returns>
        public static TrackerStatus IsAvailable(out string errorMessage)
        {
            // Check intelligaze process
            if (!IOHelpers.IsProcessOpen("IntelliGaze"))
            {
                const string FILENAME = "Intelligaze.exe";

                // Intelligaze not open. Try to open
                string fullpath = GetIntelligazePath();

                if (fullpath.Length == 0 || !new FileInfo(fullpath + "\\" + FILENAME).Exists)
                {
                    errorMessage = "Can't find Intelligaze folder. Maybe Intelligaze is not installed or installation is corrupted." + Environment.NewLine + "Please reinstall Intelligaze.";
                    return(TrackerStatus.NotAvailable);
                }
            }

            // search ActiveX Control
            Type statusControlType = Type.GetTypeFromProgID("ALEA.HeadDisplayCtrl", false);

            if (statusControlType == null)
            {
                errorMessage = "The Alea ActiveX Control is not registered. Please reinstall Intelligaze.";
                return(TrackerStatus.NotAvailable);
            }

            // do some further registry checks
            string aleaCLSID = '{' + statusControlType.GUID.ToString().ToLower() + '}';

            RegistryKey clsid = Registry.ClassesRoot.OpenSubKey("CLSID");

            string[] clsIDs = clsid.GetSubKeyNames();

            for (int i = 0; i < clsIDs.Length; i++)
            {
                if (clsIDs[i].ToLower() == aleaCLSID)
                {
                    errorMessage = "Intelligaze found.";
                    return(TrackerStatus.Available);
                }
            }

            errorMessage = "The Alea ActiveX Control is not registered. Please reinstall Intelligaze.";
            return(TrackerStatus.NotAvailable);
        }
        ///////////////////////////////////////////////////////////////////////////////
        // Methods                                                            //
        ///////////////////////////////////////////////////////////////////////////////
        #region METHODS

        /// <summary>
        /// Checks if the mirametrix tracker is available in the system.
        /// </summary>
        /// <param name="errorMessage">Out. A <see cref="String"/> with an error message.</param>
        /// <returns><strong>True</strong>, if Mirametrix tracker
        /// is available in the system, otherwise <strong>false</strong></returns>
        public static TrackerStatus IsAvailable(out string errorMessage)
        {
            // Check Mirametrix process
            if (!IOHelpers.IsProcessOpen("tracker"))
            {
                if (!IOHelpers.IsApplicationInstalled("Mirametrix"))
                {
                    errorMessage = "Can't find Mirametrix S2 Eye Tracker on this computer. Maybe Mirametrix S2 Eye Tracker is not installed or installation is corrupted." + Environment.NewLine + "Please reinstall Mirametrix S2 Eye Tracker.";
                    return(TrackerStatus.NotAvailable);
                }

                errorMessage = "Warning : Mirametrix S2 Eye tracker does not seem to be connected on this computer. Please connect Mirametrix S2 Eye tracker.";
                return(TrackerStatus.NotAvailable);
            }

            errorMessage = "Mirametrix S2 installed on this computer.";
            return(TrackerStatus.Available);
        }
Exemple #4
0
        ///////////////////////////////////////////////////////////////////////////////
        // Methods                                                            //
        ///////////////////////////////////////////////////////////////////////////////
        #region METHODS

        /// <summary>
        /// Checks if the Gazepoint tracker is available in the system.
        /// </summary>
        /// <param name="errorMessage">Out. A <see cref="String"/> with an error message.</param>
        /// <returns><strong>True</strong>, if Gazepoint tracker
        /// is available in the system, otherwise <strong>false</strong></returns>
        public static TrackerStatus IsAvailable(out string errorMessage)
        {
            // Check Gazepoint process
            if (!IOHelpers.IsProcessOpen("Gazepoint"))
            {
                if (!IOHelpers.IsApplicationInstalled("Gazepoint"))
                {
                    errorMessage = "Can't find Gazepoint GP3 Eye Tracker on this computer. Maybe Gazepoint GP3 Eye Tracker is not installed or installation is corrupted." + Environment.NewLine + "Please reinstall Gazepoint GP3 Eye Tracker.";
                    return(TrackerStatus.NotAvailable);
                }

                errorMessage = "Warning: Gazepoint GP3 Eye tracker does not seem to be connected on this computer. Please connect Gazepoint GP3 Eye tracker.";
                return(TrackerStatus.Undetermined);
            }

            errorMessage = "Gazepoint GP3 Eye Tracker found on this computer.";
            return(TrackerStatus.Available);
        }
        /// <summary>
        ///   Connects the tracker.
        /// </summary>
        /// <returns>
        ///   <strong>True</strong> if connection succeded, otherwise
        ///   <strong>false</strong>.
        /// </returns>
        public override bool Connect()
        {
            try
            {
                // Start the eye tribe server
                if (!IOHelpers.IsProcessOpen("EyeTribe"))
                {
                    this.StartEyeTribeProcess();
                }
                else
                {
                    InformationDialog.Show(
                        "EyeTribe server is running",
                        "The eye tribe server is already running, so we connect to this instance. Please note: it may be using a different tracking rate than specified in the settings tab.",
                        false,
                        MessageBoxIcon.Information);
                }

                // Connect client
                if (!GazeManager.Instance.Activate(GazeManager.ApiVersion.VERSION_1_0, GazeManager.ClientMode.Push))
                {
                    throw new Exception("Could not connect to the eye tribe tracker, please start the server manually and try again.");
                }

                //this.eyeTribeTrackStatus.Connect();

                // Register this class for events
                GazeManager.Instance.AddGazeListener(this);
                //GazeManager.Instance.AddTrackerStateListener(this);
            }
            catch (Exception ex)
            {
                var dlg = new ConnectionFailedDialog {
                    ErrorMessage = ex.Message
                };
                dlg.ShowDialog();
                this.CleanUp();
                return(false);
            }

            return(true);
        }
Exemple #6
0
        /// <summary>
        /// Connect to the alea system.
        /// </summary>
        /// <returns><strong>True</strong> if connection succeded, otherwise
        /// <strong>false</strong>.</returns>
        public override bool Connect()
        {
            // Check intelligaze process
            if (!IOHelpers.IsProcessOpen("IntelliGaze"))
            {
                const string FILENAME = "Intelligaze.exe";

                // Intelligaze not open. Try to open
                string fullpath = GetIntelligazePath();

                if (fullpath.Length == 0 || !new FileInfo(fullpath + "\\" + FILENAME).Exists)
                {
                    ConnectionFailedDialog dlg = new ConnectionFailedDialog();
                    dlg.ErrorMessage = "Can't find Intelligaze folder. Maybe Intelligaze is not installed or installation is corrupted." + Environment.NewLine + "Please reinstall Intelligaze.";
                    dlg.ShowDialog();
                    return(false);
                }

                // Start Intelligaze with background param
                Process process = new Process();
                process.StartInfo.WorkingDirectory = fullpath;
                process.StartInfo.FileName         = FILENAME;
                process.StartInfo.Arguments        = "background";
                process.StartInfo.UseShellExecute  = true;
                if (!process.Start())
                {
                    ConnectionFailedDialog dlg = new ConnectionFailedDialog();
                    dlg.ErrorMessage = "Can't start Intelligaze Process.";
                    dlg.ShowDialog();
                    return(false);
                }
            }

            bool     isOpen;
            ApiError result = this.api.IsOpen(out isOpen);

            // API open?
            if (result != ApiError.NoError)
            {
                ConnectionFailedDialog dlg = new ConnectionFailedDialog();
                string errorMessage;
                this.api.GetLastError(out errorMessage);
                if (errorMessage.Length == 0)
                {
                    errorMessage = "Intelligaze Error: Method IsOpen" + Environment.NewLine + result.ToString();
                }

                dlg.ErrorMessage = errorMessage;
                dlg.ShowDialog();
                this.CleanUp();

                return(false);
            }

            if (!isOpen)
            {
                // API is not open ... try to open API
                Stopwatch timeoutStopwatch = new Stopwatch();

                // Timeout is 20 seconds
                timeoutStopwatch.Start();

                do
                {
                    // Try to open API
                    result = this.api.Open("(ogama)=2", this.Settings.ServerAddress, this.Settings.ServerPort, this.Settings.ClientAddress, this.Settings.ClientPort);
                }while (result != ApiError.NoError && timeoutStopwatch.ElapsedMilliseconds < 20000);
                timeoutStopwatch.Stop();

                if (result != ApiError.NoError)
                {
                    ConnectionFailedDialog dlg = new ConnectionFailedDialog();
                    string errorMessage;
                    this.api.GetLastError(out errorMessage);
                    if (errorMessage.Length == 0)
                    {
                        errorMessage = "Intelligaze Error: Can't open API." + Environment.NewLine + "Reason: " + result.ToString();
                    }

                    dlg.ErrorMessage = errorMessage;
                    dlg.ShowDialog();
                    this.CleanUp();

                    return(false);
                }
            }

            // Register Callbacks
            this.api.SetCalibrationDoneCB(Marshal.GetFunctionPointerForDelegate(APICalibrationDone).ToInt32(), IntPtr.Zero);
            this.api.SetRawDataCB(Marshal.GetFunctionPointerForDelegate(APIRawDataReceived).ToInt32(), IntPtr.Zero);

            // enable datastreaming ... important to do it here, otherwise user get mousecursor control
            this.api.DataStreaming(1);

            // hide status window
            this.api.HideStatusWindow();

            return(true);
        }