public void OnAreaSizeChange(StringEventArgs e)
 {
     if (this.AreaSizeChange != null)
     {
         this.AreaSizeChange(this, e);
     }
 }
 public void OnParamChange(StringEventArgs e)
 {
     if (this.ParamChange != null)
     {
         this.ParamChange(this, e);
     }
 }
示例#3
0
        private void OnCalibrationAreaSizeChange(object sender, GTCommons.Events.StringEventArgs e)
        {
            char[]   seperator   = { ' ' };
            string[] size        = e.Param.Split(seperator, 2);
            int      widthParam  = Convert.ToInt32(size[0]);
            int      heightParam = Convert.ToInt32(size[1]);

            GTSettings.Settings.Instance.Calibration.AreaWidth  = widthParam;
            GTSettings.Settings.Instance.Calibration.AreaHeight = heightParam;
        }
 private void OnConnectionChanged(object sender, StringEventArgs e)
 {
     if ((e.Param).Equals("True"))
     {
         UiInvoke(() => TextBlockConsole.Text += "Eye Tracker connesso \n");
         UiInvoke(() => ButtonConnect.Content = "Disconnetti");
         UiInvoke(() => ButtonSetup.IsEnabled = false);
     }
     else
     {
         UiInvoke(() => TextBlockConsole.Text += "Eye Tracker disconnesso \n");
         UiInvoke(() => ButtonConnect.Content = "Connetti");
         UiInvoke(() => ButtonSetup.IsEnabled = true);
     }
 }
示例#5
0
文件: Client.cs 项目: DeSciL/Ogama
    ///////////////////////////////////////////////////////////////////////////////
    // Inherited methods                                                         //
    ///////////////////////////////////////////////////////////////////////////////
    #region OVERRIDES
    #endregion //OVERRIDES

    ///////////////////////////////////////////////////////////////////////////////
    // Eventhandler                                                              //
    ///////////////////////////////////////////////////////////////////////////////
    #region EVENTHANDLER

    /// <summary>
    /// Raises the <see cref="ErrorOccured"/> event.
    /// </summary>
    /// <param name="e">A <see cref="StringEventArgs"/> with the event data.</param>.
    private void OnErrorOccured(StringEventArgs e)
    {
      if (this.ErrorOccured != null)
      {
        this.ErrorOccured(this, e);
      }
    }
示例#6
0
 // Gestione eventi GazeTrackerClient
 private void OnErrorOccured(object sender, StringEventArgs e)
 {
     var message = e.Param;
     Exception ex = new Exception(message);
     NotifyError(ex);
 }
示例#7
0
 private void OnDisconnect(UserContext context)
 {
     connected = false;
     StringEventArgs message = new StringEventArgs(connected.ToString());
     ConnectionChange(this, message);
 }
示例#8
0
 private void OnCalibrationParamChange(object sender, GTCommons.Events.StringEventArgs e)
 {
     GTSettings.Settings.Instance.Calibration.ExtractParametersFromString(e.Param);
 }
 /// <summary>
 /// The event handler for the error occured event of the gazetracker client.
 /// Displays the error message.
 /// </summary>
 /// <param name="sender">The source of the event</param>
 /// <param name="e">A StringEventArgs with the error message.</param>
 private void ClientErrorOccured(object sender, StringEventArgs e)
 {
   this.DisplayMessage(e.Param);
 }
示例#10
0
    /// <summary>
    /// Process received message from the tracker
    /// </summary>
    /// <param name="messageEventArgs">Message to process</param>
    protected void ProcessReceivedMessage(StringEventArgs messageEventArgs)
    {
      // CANDO : Separate this method in submethods for each process depending on received message
      try
      {
        if (this.RecordModule.InvokeRequired)
        {
          this.RecordModule.BeginInvoke(new ProcessMessageReceivedDelegate(this.ProcessReceivedMessage), new object[] { messageEventArgs });
        }
        else
        {
          string grossMessage = messageEventArgs.Param;
          int endIdex = grossMessage.IndexOf("\r\n");
          if (endIdex != -1)
          {
            string availableMessage = grossMessage.Substring(0, endIdex);
            XmlDocument doc = new XmlDocument();
            doc.InnerXml = availableMessage;
            XmlElement root = doc.DocumentElement;
            string attribute;

            if (root != null)
            {
              if (root.Name == "ACK")
              {
                attribute = root.GetAttribute("ID");
                if (attribute == "CALIBRATE_RESULT_SUMMARY")
                {
                  this.memCalibrationResult.Text = root.GetAttribute("AVE_ERROR");
                  if (this.memSettings.HideCalibWindow)
                  {
                    this.memNetworkManager.SendMessage("<SET ID=\"CALIBRATE_SHOW\" STATE=\"0\" />\r\n");
                  }
                }
                else if (attribute == "SCREEN_SELECTED")
                {
                  if (root.GetAttribute("VALUE") == "0")
                  {
                    Properties.Settings.Default.PresentationScreenMonitor = "Primary";
                  }
                  else if (root.GetAttribute("VALUE") == "1")
                  {
                    Properties.Settings.Default.PresentationScreenMonitor = "Secondary";
                  }
                }
                else if (attribute == "SCREEN_SIZE")
                {
                  int screenWith;
                  if (int.TryParse(root.GetAttribute("WIDTH"), out screenWith))
                  {
                    int screenHeight;
                    if (int.TryParse(root.GetAttribute("HEIGHT"), out screenHeight))
                    {
                      if (screenHeight != Document.ActiveDocument.PresentationSize.Height
                        || screenWith != Document.ActiveDocument.PresentationSize.Width)
                      {
                        // Send correct size to tracker
                        string screenSizeString =
                          string.Format(
                            "<SET ID=\"SCREEN_SIZE\" WIDTH=\"{0}\" HEIGHT=\"{1}\"/>\r\n",
                            Document.ActiveDocument.PresentationSize.Width,
                            Document.ActiveDocument.PresentationSize.Height);
                        this.memNetworkManager.SendMessage(screenSizeString);
                      }
                    }
                  }
                }
                else if (attribute == "TIME_TICK_FREQUENCY")
                {
                  // REPLY: <ACK ID="TIME_TICK_FREQUENCY" FREQ="2405480000" />
                  ulong readedTickFrequency;
                  if (ulong.TryParse(root.GetAttribute("FREQ"), out readedTickFrequency))
                  {
                    this.tickFrequency = readedTickFrequency;
                  }
                }
              }
              else if (root.Name == "CAL")
              {
                attribute = root.GetAttribute("ID");
                if (attribute == "CALIB_RESULT")
                {
                  // TODO : Hide calibration result screen after calibration
                  this.memIsCalibrating = false;
                  this.memNetworkManager.SendMessage("<GET ID=\"CALIBRATE_RESULT_SUMMARY\" />\r\n");
                  this.ShowCalibPlot();
                }
              }
              else if (root.Name == "REC")
              {
                // TODO : Optimize data send to Ogama by verifying if they are valid
                var newGazeData = new GazeData();

                //// Get gazeTimestamp in milliseconds.
                ////newGazeData.Time = this.memTimeOfRecordingStart.ElapsedMilliseconds;

                // Get time stamp in ticks
                attribute = root.GetAttribute("TIME_TICK");
                var timeInTicks = double.Parse(attribute, CultureInfo.InvariantCulture);

                // Convert to milliseconds
                newGazeData.Time = (long)(timeInTicks / (this.tickFrequency / 1000.0));

                // Calculate values between 0..1
                attribute = root.GetAttribute("BPOGX");
                newGazeData.GazePosX = float.Parse(attribute, CultureInfo.InvariantCulture);
                attribute = root.GetAttribute("BPOGY");
                newGazeData.GazePosY = float.Parse(attribute, CultureInfo.InvariantCulture);

                // Set pupil diameter
                attribute = root.GetAttribute("LPD");
                newGazeData.PupilDiaX = float.Parse(attribute, CultureInfo.InvariantCulture);
                attribute = root.GetAttribute("RPD");
                newGazeData.PupilDiaY = float.Parse(attribute, CultureInfo.InvariantCulture);
                this.OnGazeDataChanged(new GazeDataChangedEventArgs(newGazeData));

                // Values needed by the trackstatus windows
                attribute = root.GetAttribute("LPS");
                float lED = float.Parse(attribute, CultureInfo.InvariantCulture);
                attribute = root.GetAttribute("RPS");
                float rED = float.Parse(attribute, CultureInfo.InvariantCulture);
                float averageRD = (lED + rED) / 2;
                if (this.memDlgTrackStatus != null)
                {
                  this.memDlgTrackStatus.UpdateStatus((float)newGazeData.GazePosX, (float)newGazeData.GazePosY, averageRD);
                }
              }
            }
          }
        }
      }
      catch (Exception e)
      {
        string message = "Exception catched in ProcessReceivedMessage(...) Method : " +
            Environment.NewLine + e.Message;
        ExceptionMethods.ProcessErrorMessage(message);
      }
    }