private void Window_Closed(object sender, EventArgs e) { this._isRecording = false; //Close Mouse and Eye Timer Thread.Sleep(100); if (_MouseGazeTimer != null) { _MouseGazeTimer.Dispose(); } //Close URL ReadWriter Thread.Sleep(100); if (_URLReadWriteThread != null) { _URLReadWriteThread.Abort(); } //Close EyeTribeUC Thread.Sleep(100); if (_EyeDeviceUC != null) { if (_EyeDeviceUC.hasFixation()) { _EyeDeviceUC.OnFixationEvent -= OnGazeFixationEvent; } this._EyeDeviceUC.Dispose(); this._EyeDeviceUC = null; } }
/********************* Eye Device ***************************/ private void cb_eyeDevice_SelectionChanged(object sender, SelectionChangedEventArgs e) { //Get Eye Device Type string text = (sender as System.Windows.Controls.ComboBox).SelectedIndex.ToString(); this._EyeDeviceType = (EyeDeviceType)Enum.Parse(typeof(EyeDeviceType), text); //Close eye device if (_EyeDeviceUC != null) { if (_EyeDeviceUC.hasFixation()) { _EyeDeviceUC.OnFixationEvent -= OnGazeFixationEvent; } this._EyeDeviceUC.Dispose(); this._EyeDeviceUC = null; } //Do if (this._EyeDeviceType == EyeDeviceType.None) { this.g_eyedevice.Children.Clear(); if (this.Height > 291) { this.Height = this.Height - 260; } this.bt_start.IsEnabled = true; } else { //new eye device _EyeDeviceUC = new EyeDevice(_EyeDeviceType); if (_EyeDeviceUC.hasFixation()) { _EyeDeviceUC.OnFixationEvent += OnGazeFixationEvent; } this.bt_start.IsEnabled = false; if (this.Height <= 291) { this.Height = this.Height + 260; } this.g_eyedevice.Children.Clear(); this.g_eyedevice.Children.Add(_EyeDeviceUC); } }