private void InitComponent(EyeDeviceType eyeDeviceType)
        {
            //Set Variables
            _eyeDeviceType = eyeDeviceType;
            if (_eyeDeviceType == EyeDeviceType.None)
            {
                return;
            }
            else if (_eyeDeviceType == EyeDeviceType.EyeTribe)
            {
                _eyeDeviceEyeTribe = new EyeDevice_EyeTribe();
            }
            else if (_eyeDeviceType == EyeDeviceType.Tobii)
            {
                _eyeDeviceTobii = new EyeDevice_Tobii();
            }

            //Set Button
            this.bt_connect.Background   = System.Windows.Media.Brushes.OrangeRed;
            this.bt_calibrate.IsEnabled  = false;
            this.bt_accept.IsEnabled     = false;
            this.bt_accept.Visibility    = System.Windows.Visibility.Hidden;
            this.lb_calibrationQ.Content = "Calibration Quality:";
            if (!hasFixation())
            {
                this.g_gdthreshold.Visibility = System.Windows.Visibility.Hidden;
            }

            this.g_eyeTraceBox.Children.Clear();
            switch (_eyeDeviceType)
            {
            case EyeDeviceType.EyeTribe:
                if (_eyeDeviceEyeTribe != null)
                {
                    this.g_eyeTraceBox.Children.Add(_eyeDeviceEyeTribe.GetGazeStatusBox());
                    _eyeDeviceEyeTribe.CalibrateOnResult += new EyeDevice_EyeTribe.CalibrateEventHandler(OnCalibrateResult);
                }
                break;

            case EyeDeviceType.Tobii:
                if (_eyeDeviceTobii != null)
                {
                    this.g_eyeTraceBox.Children.Add(_eyeDeviceTobii.GetGazeStatusBox());
                    _eyeDeviceTobii.OnFixation += new EyeDevice_Tobii.FixationEventHandler(OnFixation);
                }
                break;

            default:
                break;
            }
        }
        /*********************  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);
            }
        }
        public EyeDevice(EyeDeviceType eyeDeviceType)
        {
            InitializeComponent();

            InitComponent(eyeDeviceType);
        }
        public MainWindow()
        {
            InitializeComponent();

            this._isRecording = false;
            this._frameCount  = 0;
            this._width       = SystemInformation.VirtualScreen.Width;
            this._height      = SystemInformation.VirtualScreen.Height;
            this._stopWatch   = new Stopwatch();
            this._screenArea  = Rectangle.Empty;

            this.bt_Save.IsEnabled = false;
            this._writer           = new VideoFileWriter();

            _screenNames = new List <string>();
            _screenNames.Add(@"Select ALL");
            foreach (var screen in Screen.AllScreens)
            {
                _screenNames.Add(screen.DeviceName);
            }
            this.cb_screenSelector.ItemsSource   = _screenNames;
            this.cb_screenSelector.SelectedIndex = 0;

            // Codec ComboBox
            this.cb_VideoCodec.ItemsSource   = Enum.GetValues(typeof(VideoCodec));
            this.cb_VideoCodec.SelectedIndex = 0;

            // BitRate 2000kbit/s 2000000 1000000
            this.cb_BitRate.ItemsSource   = Enum.GetValues(typeof(BitRate));
            this.cb_BitRate.SelectedIndex = 5;

            // Eye Device Selection
            this.cb_eyeDevice.ItemsSource   = Enum.GetValues(typeof(EyeDeviceType));
            this.cb_eyeDevice.SelectedIndex = 0;
            _EyeDeviceType = EyeDeviceType.None;

            //URL ReadWriter
            _URLReadWriteThread = new Thread(URLReadWriter);

            // Mouse and Eye Timer
            this._MouseGazeTimer          = new System.Timers.Timer();
            this._MouseGazeTimer.Elapsed += new ElapsedEventHandler(OnMouseGazeTimedEvent);

            //Lock DB data
            _MKEventLock  = new object();
            _URLEventLock = new object();
            _RawdataLock  = new object();
            //DB Event ID
            _MKEventID  = 0;
            _URLEventID = 0;
            _RawdataID  = 1;
            //_FirstRaw = true;
            _FixationID = 0;
            //FPS and Video time(ms)
            _FPS       = 10;
            _VideoTime = 0;
            //Get data
            _isGettingData = false;
            //Get URL data
            _URLData  = new string[] { null, null };
            _getURL   = false;
            _isNewURL = false;
            //_WebPos = new System.Windows.Point();
            _WebPos           = null;
            _WebPosTemp       = null;
            _isNewStartScroll = false;
            _isNextURLSave    = false;
            _WinPos           = null;

            Console.SetOut(TextWriter.Null);
        }