private void tracker_OnTrackerError(string message)
 {
   msgWindow = new MessageWindow { Text = message };
   msgWindow.Show();
 }
 private void ShowMessageNoCamera()
 {
   msgWindow = new MessageWindow();
   msgWindow.Text = "The GazeTracker was unable to connect a camera. \n" +
                    "Make sure that the device is connected and that the device drivers are installed. " +
                    "Verified configurations can be found in our forum located at http://forum.gazegroup.org";
   msgWindow.Show();
   ErrorLogger.WriteLine("Fatal error on startup, could not connect to a camera.");
   msgWindow.Closed += new EventHandler(msgWindowNoCamera_Closed);
 }
    private void StartStop(object sender, RoutedEventArgs e)
    {
      if (Tracker.Instance.Calibration.IsCalibrated == false)
      {
        msgWindow = new MessageWindow("You need to calibrate before starting");
        msgWindow.Show();
        return;
      }
    
      // Starting
      if (!isRunning)
      {
        #region EyeMouse

        // Start eye mouse (register listner for gazedata events)
        if (Settings.Instance.Processing.EyeMouseEnabled)
        {
            if (Settings.Instance.Processing.EyeMouseSmooth)
                Tracker.Instance.GazeDataSmoothed.GazeDataChanged += mouseDriver.Move;
            else
                Tracker.Instance.GazeDataRaw.GazeDataChanged += mouseDriver.Move;
        }

        #endregion

        #region Crosshair

        if (Settings.Instance.Processing.EyeCrosshairEnabled)
        {
          crosshairDriver.Show();

          if (Settings.Instance.Processing.EyeMouseSmooth)
            Tracker.Instance.GazeDataSmoothed.GazeDataChanged += crosshairDriver.Move;
          else
            Tracker.Instance.GazeDataRaw.GazeDataChanged += crosshairDriver.Move;
        }

        #endregion

        #region TCPIP Server

        // Start UDP data server (if enabled)
        Tracker.Instance.Server.IsEnabled = GTSettings.Settings.Instance.Network.UDPServerEnabled;

        // Start logging (if enabled)
        Tracker.Instance.LogData.IsEnabled = GTSettings.Settings.Instance.FileSettings.LoggingEnabled;

        #endregion

        //if(Settings.Instance.Processing.EyeMouseEnabled)
        //    BtnStartStop.ActivationMethod = "Dwell";

        isRunning = true;
      }

          // Stopping
      else
      {
        #region EyeMouse

        // Stop eye mouse (unregister events)
        if (Settings.Instance.Processing.EyeMouseEnabled)
        {
          if (Settings.Instance.Processing.EyeMouseSmooth)
            Tracker.Instance.GazeDataSmoothed.GazeDataChanged -= mouseDriver.Move;
          else
            Tracker.Instance.GazeDataRaw.GazeDataChanged -= mouseDriver.Move;
        }

        #endregion

        #region Crosshair

        if (Settings.Instance.Processing.EyeCrosshairEnabled)
        {
          if (Settings.Instance.Processing.EyeMouseSmooth)
            Tracker.Instance.GazeDataSmoothed.GazeDataChanged -= crosshairDriver.Move;
          else
            Tracker.Instance.GazeDataRaw.GazeDataChanged -= crosshairDriver.Move;

          crosshairDriver.Hide();
        }

        #endregion

        #region TCPIP Server

        // Stop UDP data server (if enabled)
        if (Tracker.Instance.Server.IsEnabled)
          Tracker.Instance.Server.IsEnabled = false;

        if (Tracker.Instance.LogData.IsEnabled)
          Tracker.Instance.LogData.IsEnabled = false; // Will stop and close filestream

        #endregion

        //if(Settings.Instance.Processing.EyeMouseEnabled)
        //    BtnStartStop.ActivationMethod = "Mouse";

        isRunning = false;
      }
    }