Example #1
0
        ///////////////////////////////////////////////////////////////////////////////
        // Methods and Eventhandling for Background tasks                            //
        ///////////////////////////////////////////////////////////////////////////////
        #region BACKGROUNDWORKER
        #endregion //BACKGROUNDWORKER

        ///////////////////////////////////////////////////////////////////////////////
        // Methods for doing main class job                                          //
        ///////////////////////////////////////////////////////////////////////////////
        #region PRIVATEMETHODS

        /// <summary>
        /// Deserializes the <see cref="SMISetting"/> from the given xml file.
        /// </summary>
        /// <param name="filePath">Full file path to the xml settings file.</param>
        /// <returns>A <see cref="SMISetting"/> object.</returns>
        private SMISetting DeserializeSettings(string filePath)
        {
            var settings = new SMISetting();

            // Create an instance of the XmlSerializer class;
            // specify the type of object to be deserialized
            var serializer = new XmlSerializer(typeof(SMISetting));

            // * If the XML document has been altered with unknown
            // nodes or attributes, handle them with the
            // UnknownNode and UnknownAttribute events.*/
            serializer.UnknownNode      += this.SerializerUnknownNode;
            serializer.UnknownAttribute += this.SerializerUnknownAttribute;

            try
            {
                // A FileStream is needed to read the XML document.
                var fs = new FileStream(filePath, FileMode.Open);

                // Use the Deserialize method to restore the object's state with
                // data from the XML document.
                settings = (SMISetting)serializer.Deserialize(fs);
                fs.Close();
            }
            catch (Exception ex)
            {
                string message = "Deserialization of SMISettings failed with the following message: " +
                                 Environment.NewLine + ex.Message;
                ExceptionMethods.ProcessErrorMessage(message);
            }

            return(settings);
        }
Example #2
0
        /// <summary>
        /// Raises <see cref="SMISettingsDlg"/> to change the settings
        /// for this interface.
        /// </summary>
        public override void ChangeSettings()
        {
            var dlg = new SMISettingsDlg {
                SMISettings = this.smiSettings
            };

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                this.smiSettings = dlg.SMISettings;
                this.SerializeSettings(this.smiSettings, this.SettingsFile);
            }
        }
Example #3
0
        /// <summary>
        /// Serializes the <see cref="SMISetting"/> into the given file in a xml structure.
        /// </summary>
        /// <param name="settings">The <see cref="SMISetting"/> object to serialize.</param>
        /// <param name="filePath">Full file path to the xml settings file.</param>
        private void SerializeSettings(SMISetting settings, string filePath)
        {
            // Create an instance of the XmlSerializer class;
            // specify the type of object to serialize
            var serializer = new XmlSerializer(typeof(SMISetting));

            // Serialize the SMISetting, and close the TextWriter.
            try
            {
                TextWriter writer = new StreamWriter(filePath, false);
                serializer.Serialize(writer, settings);
                writer.Close();
            }
            catch (Exception ex)
            {
                string message = "Serialization of SMISettings failed with the following message: " +
                                 Environment.NewLine + ex.Message;
                ExceptionMethods.ProcessErrorMessage(message);
            }
        }
Example #4
0
        /// <summary>
        /// Sets up calibration procedure and the tracking client
        /// and wires the events. Reads settings from file.
        /// </summary>
        protected override sealed void Initialize()
        {
            this.CalibrationFinished += this.SMIInterfaceCalibrationFinished;

            // Set up the SMI client object and it's events
            this.smiClient.GazeDataChanged     += this.SMIClientGazeDataChanged;
            this.smiClient.CalibrationFinished += this.SMIClientCalibrationFinished;

            // Load SMI tracker settings.
            if (File.Exists(this.SettingsFile))
            {
                this.smiSettings = this.DeserializeSettings(this.SettingsFile);
            }
            else
            {
                this.smiSettings = new SMISetting();
                this.SerializeSettings(this.smiSettings, this.SettingsFile);
            }

            // Set tracker settings.
            this.smiClient.Settings = this.smiSettings;
        }
Example #5
0
        /// <summary>
        ///   This method generates a new SMISetting out of the
        ///   options choosen in the UI.
        /// </summary>
        /// <returns>
        ///   A <see cref="SMISetting" /> containing the values of the
        ///   dialog.
        /// </returns>
        private SMISetting GenerateSMISettings()
        {
            var newSetting = new SMISetting
            {
                SMIServerAddress     = this.txbiViewXAddress.Text,
                SMIServerPort        = Convert.ToInt32(this.txbiViewXPort.Text),
                OGAMAServerPort      = Convert.ToInt32(this.txbOGAMAPort.Text),
                CalibPointColor      = this.clbSMIPointColor.CurrentColor,
                CalibBackgroundColor = this.clbSMIBackColor.CurrentColor
            };

            if (this.rdbSMISizeLarge.Checked)
            {
                newSetting.CalibPointSize = CalibrationPointSize.Large;
            }
            else if (this.rdbSMISizeMedium.Checked)
            {
                newSetting.CalibPointSize = CalibrationPointSize.Medium;
            }
            else if (this.rdbSMISizeSmall.Checked)
            {
                newSetting.CalibPointSize = CalibrationPointSize.Small;
            }

            if (this.rdbSMIEyeBoth.Checked)
            {
                newSetting.AvailableEye = AvailableEye.Both;
            }
            else if (this.rdbSMIEyeLeft.Checked)
            {
                newSetting.AvailableEye = AvailableEye.Left;
            }
            else if (this.rdbSMIEyeRight.Checked)
            {
                newSetting.AvailableEye = AvailableEye.Right;
            }

            return(newSetting);
        }
Example #6
0
        /// <summary>
        /// Updates the forms UI with the new settings from the
        ///   <see cref="SMISetting"/> member.
        /// </summary>
        /// <param name="setting">
        /// A <see cref="SMISetting"/> with the settings
        ///   to apply.
        /// </param>
        private void SetupUIWithNewSettings(SMISetting setting)
        {
            switch (setting.CalibPointSize)
            {
            case CalibrationPointSize.Small:
                this.rdbSMISizeSmall.Checked = true;
                break;

            default:
            case CalibrationPointSize.Medium:
                this.rdbSMISizeMedium.Checked = true;
                break;

            case CalibrationPointSize.Large:
                this.rdbSMISizeLarge.Checked = true;
                break;
            }

            this.txbiViewXAddress.Text         = setting.SMIServerAddress;
            this.txbiViewXPort.Text            = setting.SMIServerPort.ToString();
            this.txbOGAMAPort.Text             = setting.OGAMAServerPort.ToString();
            this.clbSMIBackColor.CurrentColor  = setting.CalibBackgroundColor;
            this.clbSMIPointColor.CurrentColor = setting.CalibPointColor;
        }
Example #7
0
    /// <summary>
    /// Serializes the <see cref="SMISetting"/> into the given file in a xml structure.
    /// </summary>
    /// <param name="settings">The <see cref="SMISetting"/> object to serialize.</param>
    /// <param name="filePath">Full file path to the xml settings file.</param>
    private void SerializeSettings(SMISetting settings, string filePath)
    {
      // Create an instance of the XmlSerializer class;
      // specify the type of object to serialize 
      var serializer = new XmlSerializer(typeof(SMISetting));

      // Serialize the SMISetting, and close the TextWriter.
      try
      {
        TextWriter writer = new StreamWriter(filePath, false);
        serializer.Serialize(writer, settings);
        writer.Close();
      }
      catch (Exception ex)
      {
        string message = "Serialization of SMISettings failed with the following message: " +
          Environment.NewLine + ex.Message;
        ExceptionMethods.ProcessErrorMessage(message);
      }
    }
Example #8
0
    ///////////////////////////////////////////////////////////////////////////////
    // Methods and Eventhandling for Background tasks                            //
    ///////////////////////////////////////////////////////////////////////////////
    #region BACKGROUNDWORKER
    #endregion //BACKGROUNDWORKER

    ///////////////////////////////////////////////////////////////////////////////
    // Methods for doing main class job                                          //
    ///////////////////////////////////////////////////////////////////////////////
    #region PRIVATEMETHODS

    /// <summary>
    /// Deserializes the <see cref="SMISetting"/> from the given xml file.
    /// </summary>
    /// <param name="filePath">Full file path to the xml settings file.</param>
    /// <returns>A <see cref="SMISetting"/> object.</returns>
    private SMISetting DeserializeSettings(string filePath)
    {
      var settings = new SMISetting();

      // Create an instance of the XmlSerializer class;
      // specify the type of object to be deserialized 
      var serializer = new XmlSerializer(typeof(SMISetting));

      // * If the XML document has been altered with unknown 
      // nodes or attributes, handle them with the 
      // UnknownNode and UnknownAttribute events.*/
      serializer.UnknownNode += this.SerializerUnknownNode;
      serializer.UnknownAttribute += this.SerializerUnknownAttribute;

      try
      {
        // A FileStream is needed to read the XML document.
        var fs = new FileStream(filePath, FileMode.Open);

        // Use the Deserialize method to restore the object's state with
        // data from the XML document. 
        settings = (SMISetting)serializer.Deserialize(fs);
        fs.Close();
      }
      catch (Exception ex)
      {
        string message = "Deserialization of SMISettings failed with the following message: " +
          Environment.NewLine + ex.Message;
        ExceptionMethods.ProcessErrorMessage(message);
      }

      return settings;
    }
Example #9
0
    /// <summary>
    /// Sets up calibration procedure and the tracking client
    /// and wires the events. Reads settings from file.
    /// </summary>
    protected override sealed void Initialize()
    {
      this.CalibrationFinished += this.SMIInterfaceCalibrationFinished;

      // Set up the SMI client object and it's events
      this.smiClient.GazeDataChanged += this.SMIClientGazeDataChanged;
      this.smiClient.CalibrationFinished += this.SMIClientCalibrationFinished;

      // Load SMI tracker settings.
      if (File.Exists(this.SettingsFile))
      {
        this.smiSettings = this.DeserializeSettings(this.SettingsFile);
      }
      else
      {
        this.smiSettings = new SMISetting();
        this.SerializeSettings(this.smiSettings, this.SettingsFile);
      }

      // Set tracker settings.
      this.smiClient.Settings = this.smiSettings;
    }
Example #10
0
 /// <summary>
 /// Raises <see cref="SMISettingsDlg"/> to change the settings
 /// for this interface.
 /// </summary>
 public override void ChangeSettings()
 {
   var dlg = new SMISettingsDlg { SMISettings = this.smiSettings };
   if (dlg.ShowDialog() == DialogResult.OK)
   {
     this.smiSettings = dlg.SMISettings;
     this.SerializeSettings(this.smiSettings, this.SettingsFile);
   }
 }
Example #11
0
    /// <summary>
    /// Updates the forms UI with the new settings from the
    ///   <see cref="SMISetting"/> member.
    /// </summary>
    /// <param name="setting">
    /// A <see cref="SMISetting"/> with the settings
    ///   to apply.
    /// </param>
    private void SetupUIWithNewSettings(SMISetting setting)
    {
      switch (setting.CalibPointSize)
      {
        case CalibrationPointSize.Small:
          this.rdbSMISizeSmall.Checked = true;
          break;
        default:
        case CalibrationPointSize.Medium:
          this.rdbSMISizeMedium.Checked = true;
          break;
        case CalibrationPointSize.Large:
          this.rdbSMISizeLarge.Checked = true;
          break;
      }

      this.txbiViewXAddress.Text = setting.SMIServerAddress;
      this.txbiViewXPort.Text = setting.SMIServerPort.ToString();
      this.txbOGAMAPort.Text = setting.OGAMAServerPort.ToString();
      this.clbSMIBackColor.CurrentColor = setting.CalibBackgroundColor;
      this.clbSMIPointColor.CurrentColor = setting.CalibPointColor;
    }
Example #12
0
    /// <summary>
    ///   This method generates a new SMISetting out of the
    ///   options choosen in the UI.
    /// </summary>
    /// <returns>
    ///   A <see cref="SMISetting" /> containing the values of the
    ///   dialog.
    /// </returns>
    private SMISetting GenerateSMISettings()
    {
      var newSetting = new SMISetting
                         {
                           SMIServerAddress = this.txbiViewXAddress.Text,
                           SMIServerPort = Convert.ToInt32(this.txbiViewXPort.Text),
                           OGAMAServerPort = Convert.ToInt32(this.txbOGAMAPort.Text),
                           CalibPointColor = this.clbSMIPointColor.CurrentColor,
                           CalibBackgroundColor = this.clbSMIBackColor.CurrentColor
                         };

      if (this.rdbSMISizeLarge.Checked)
      {
        newSetting.CalibPointSize = CalibrationPointSize.Large;
      }
      else if (this.rdbSMISizeMedium.Checked)
      {
        newSetting.CalibPointSize = CalibrationPointSize.Medium;
      }
      else if (this.rdbSMISizeSmall.Checked)
      {
        newSetting.CalibPointSize = CalibrationPointSize.Small;
      }

      if (this.rdbSMIEyeBoth.Checked)
      {
        newSetting.AvailableEye = AvailableEye.Both;
      }
      else if (this.rdbSMIEyeLeft.Checked)
      {
        newSetting.AvailableEye = AvailableEye.Left;
      }
      else if (this.rdbSMIEyeRight.Checked)
      {
        newSetting.AvailableEye = AvailableEye.Right;
      }

      return newSetting;
    }