コード例 #1
0
        /// <summary>
        ///   Pulls the eye tribe settings.
        /// </summary>
        /// <returns>The settings modified by this control</returns>
        private TheEyeTribeSetting PullTheEyeTribeSettings()
        {
            var newSetting = new TheEyeTribeSetting();

            if (this.rdb9PtsCalib.Checked)
            {
                newSetting.CalibrationPointCount = TheEyeTribeCalibrationPoints.Nine;
            }
            else if (this.rdb12PtsCalib.Checked)
            {
                newSetting.CalibrationPointCount = TheEyeTribeCalibrationPoints.Twelve;
            }
            else if (this.rdb16PtsCalib.Checked)
            {
                newSetting.CalibrationPointCount = TheEyeTribeCalibrationPoints.Sixteen;
            }

            newSetting.PointDisplayTime = (int)this.nudDisplayTime.Value;

            newSetting.ServerIPAddress            = this.txbServerAddress.Text;
            newSetting.ServerPort                 = int.Parse(this.txbPort.Text);
            newSetting.CalibrationPointColor      = this.clbPointColor.CurrentColor;
            newSetting.DisplayHelp                = this.chbDisplayHelp.Checked;
            newSetting.CalibrationBackgroundColor = this.clbBackColor.CurrentColor;
            newSetting.DeviceIndex                = this.cbbDeviceIndex.SelectedIndex;
            newSetting.Framerate = this.cbbFramerate.SelectedIndex == 0 ? 30 : 60;

            return(newSetting);
        }
コード例 #2
0
    /// <summary>
    ///   Pulls the eye tribe settings.
    /// </summary>
    /// <returns>The settings modified by this control</returns>
    private TheEyeTribeSetting PullTheEyeTribeSettings()
    {
      var newSetting = new TheEyeTribeSetting();
      if (this.rdb9PtsCalib.Checked)
      {
        newSetting.CalibrationPointCount = TheEyeTribeCalibrationPoints.Nine;
      }
      else if (this.rdb12PtsCalib.Checked)
      {
        newSetting.CalibrationPointCount = TheEyeTribeCalibrationPoints.Twelve;
      }
      else if (this.rdb16PtsCalib.Checked)
      {
        newSetting.CalibrationPointCount = TheEyeTribeCalibrationPoints.Sixteen;
      }

      newSetting.PointDisplayTime = (int)this.nudDisplayTime.Value;

      newSetting.ServerIPAddress = this.txbServerAddress.Text;
      newSetting.ServerPort = int.Parse(this.txbPort.Text);
      newSetting.CalibrationPointColor = this.clbPointColor.CurrentColor;
      newSetting.DisplayHelp = this.chbDisplayHelp.Checked;
      newSetting.CalibrationBackgroundColor = this.clbBackColor.CurrentColor;
      newSetting.DeviceIndex = this.cbbDeviceIndex.SelectedIndex;
      newSetting.Framerate = this.cbbFramerate.SelectedIndex == 0 ? 30 : 60;

      return newSetting;
    }
コード例 #3
0
        /// <summary>
        /// Updates the forms UI with the new settings from the
        ///   <see cref="TheEyeTribeSetting"/> member.
        /// </summary>
        /// <param name="setting">
        /// The setting to be shown by this control
        /// </param>
        private void PushTheEyeTribeSettings(TheEyeTribeSetting setting)
        {
            switch (setting.CalibrationPointCount)
            {
            case TheEyeTribeCalibrationPoints.Nine:
                this.rdb9PtsCalib.Checked = true;
                break;

            case TheEyeTribeCalibrationPoints.Twelve:
                this.rdb12PtsCalib.Checked = true;
                break;

            case TheEyeTribeCalibrationPoints.Sixteen:
                this.rdb16PtsCalib.Checked = true;
                break;

            default:
                this.rdb9PtsCalib.Checked = true;
                break;
            }

            this.nudDisplayTime.Value = setting.PointDisplayTime;

            this.txbServerAddress.Text        = setting.ServerIPAddress;
            this.txbPort.Text                 = setting.ServerPort.ToString(CultureInfo.InvariantCulture);
            this.clbPointColor.CurrentColor   = setting.CalibrationPointColor;
            this.chbDisplayHelp.Checked       = setting.DisplayHelp;
            this.clbBackColor.CurrentColor    = setting.CalibrationBackgroundColor;
            this.cbbDeviceIndex.SelectedIndex = setting.DeviceIndex;
            this.cbbFramerate.SelectedIndex   = setting.Framerate == 30 ? 0 : 1;
        }
コード例 #4
0
        /// <summary>
        /// Deserializes the <see cref="TheEyeTribeSetting"/> from the given xml file.
        /// </summary>
        /// <param name="filePath">
        /// Full file path to the xml settings file.
        /// </param>
        /// <returns>
        /// A <see cref="TheEyeTribeSetting"/> object.
        /// </returns>
        private TheEyeTribeSetting DeserializeSettings(string filePath)
        {
            var settings = new TheEyeTribeSetting();

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

            // 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, FileAccess.Read);

                // Use the Deserialize method to restore the object's state with
                // data from the XML document.
                settings = (TheEyeTribeSetting)serializer.Deserialize(fs);
                fs.Close();
            }
            catch (Exception ex)
            {
                InformationDialog.Show(
                    "Error occured",
                    "Deserialization of TheEyeTribeSettings failed with the following message: " + Environment.NewLine + ex.Message,
                    false,
                    MessageBoxIcon.Error);
            }

            return(settings);
        }
コード例 #5
0
        /// <summary>
        ///   Raises <see cref="TheEyeTribeSettingsDialog" /> to change the settings
        ///   for this interface.
        /// </summary>
        public override void ChangeSettings()
        {
            var dlg = new TheEyeTribeSettingsDialog {
                TheEyeTribeSettings = this.theEyeTribeSettings
            };

            switch (dlg.ShowDialog())
            {
            case DialogResult.OK:
                var oldServerStartParams = this.theEyeTribeSettings.ServerStartParams;
                this.theEyeTribeSettings = dlg.TheEyeTribeSettings;
                this.SerializeSettings(this.theEyeTribeSettings, this.SettingsFile);

                if (this.theEyeTribeSettings.ServerStartParams != oldServerStartParams)
                {
                    // Need to restart the eye tribe server if it is running
                    if (IOHelpers.IsProcessOpen("EyeTribe"))
                    {
                        this.KillEyeTribeProcess();

                        // Now restart
                        this.StartEyeTribeProcess();
                    }
                }

                break;
            }
        }
コード例 #6
0
        /// <summary>
        ///   Sets up calibration procedure and the tracking client
        ///   and wires the events. Reads settings from file.
        /// </summary>
        protected override sealed void Initialize()
        {
            // Load theEyeTribe tracker settings and write the config file for the eye tribe server
            if (File.Exists(this.SettingsFile))
            {
                this.theEyeTribeSettings = this.DeserializeSettings(this.SettingsFile);
            }
            else
            {
                this.theEyeTribeSettings = new TheEyeTribeSetting();
                this.SerializeSettings(this.theEyeTribeSettings, this.SettingsFile);
            }

            base.Initialize();
        }
コード例 #7
0
        /// <summary>
        /// Serializes the <see cref="TheEyeTribeSetting"/> into the given file in a xml structure.
        /// </summary>
        /// <param name="settings">
        /// The <see cref="TheEyeTribeSetting"/> object to serialize.
        /// </param>
        /// <param name="filePath">
        /// Full file path to the xml settings file.
        /// </param>
        private void SerializeSettings(TheEyeTribeSetting settings, string filePath)
        {
            // Create an instance of the XmlSerializer class;
            // specify the type of object to serialize
            var serializer = new XmlSerializer(typeof(TheEyeTribeSetting));

            // Serialize the TheEyeTribeSetting, and close the TextWriter.
            try
            {
                TextWriter writer = new StreamWriter(filePath, false);
                serializer.Serialize(writer, settings);
                writer.Close();
            }
            catch (Exception ex)
            {
                InformationDialog.Show(
                    "Error occured",
                    "Serialization of TheEyeTribeSettings failed with the following message: " + Environment.NewLine + ex.Message,
                    false,
                    MessageBoxIcon.Error);
            }
        }
コード例 #8
0
ファイル: TheEyeTribeTracker.cs プロジェクト: DeSciL/Ogama
    /// <summary>
    /// Serializes the <see cref="TheEyeTribeSetting"/> into the given file in a xml structure.
    /// </summary>
    /// <param name="settings">
    /// The <see cref="TheEyeTribeSetting"/> object to serialize.
    /// </param>
    /// <param name="filePath">
    /// Full file path to the xml settings file.
    /// </param>
    private void SerializeSettings(TheEyeTribeSetting settings, string filePath)
    {
      // Create an instance of the XmlSerializer class;
      // specify the type of object to serialize 
      var serializer = new XmlSerializer(typeof(TheEyeTribeSetting));

      // Serialize the TheEyeTribeSetting, and close the TextWriter.
      try
      {
        TextWriter writer = new StreamWriter(filePath, false);
        serializer.Serialize(writer, settings);
        writer.Close();
      }
      catch (Exception ex)
      {
        InformationDialog.Show(
          "Error occured",
          "Serialization of TheEyeTribeSettings failed with the following message: " + Environment.NewLine + ex.Message,
          false,
          MessageBoxIcon.Error);
      }
    }
コード例 #9
0
ファイル: TheEyeTribeTracker.cs プロジェクト: DeSciL/Ogama
    /// <summary>
    /// Deserializes the <see cref="TheEyeTribeSetting"/> from the given xml file.
    /// </summary>
    /// <param name="filePath">
    /// Full file path to the xml settings file. 
    /// </param>
    /// <returns>
    /// A <see cref="TheEyeTribeSetting"/> object. 
    /// </returns>
    private TheEyeTribeSetting DeserializeSettings(string filePath)
    {
      var settings = new TheEyeTribeSetting();

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

      // 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, FileAccess.Read);

        // Use the Deserialize method to restore the object's state with
        // data from the XML document.
        settings = (TheEyeTribeSetting)serializer.Deserialize(fs);
        fs.Close();
      }
      catch (Exception ex)
      {
        InformationDialog.Show(
          "Error occured",
          "Deserialization of TheEyeTribeSettings failed with the following message: " + Environment.NewLine + ex.Message,
          false,
          MessageBoxIcon.Error);
      }

      return settings;
    }
コード例 #10
0
ファイル: TheEyeTribeTracker.cs プロジェクト: DeSciL/Ogama
    /// <summary>
    ///   Sets up calibration procedure and the tracking client
    ///   and wires the events. Reads settings from file.
    /// </summary>
    protected override sealed void Initialize()
    {
      // Load theEyeTribe tracker settings and write the config file for the eye tribe server
      if (File.Exists(this.SettingsFile))
      {
        this.theEyeTribeSettings = this.DeserializeSettings(this.SettingsFile);
      }
      else
      {
        this.theEyeTribeSettings = new TheEyeTribeSetting();
        this.SerializeSettings(this.theEyeTribeSettings, this.SettingsFile);
      }

      base.Initialize();
    }
コード例 #11
0
ファイル: TheEyeTribeTracker.cs プロジェクト: DeSciL/Ogama
    /// <summary>
    ///   Raises <see cref="TheEyeTribeSettingsDialog" /> to change the settings
    ///   for this interface.
    /// </summary>
    public override void ChangeSettings()
    {
      var dlg = new TheEyeTribeSettingsDialog { TheEyeTribeSettings = this.theEyeTribeSettings };
      switch (dlg.ShowDialog())
      {
        case DialogResult.OK:
          var oldServerStartParams = this.theEyeTribeSettings.ServerStartParams;
          this.theEyeTribeSettings = dlg.TheEyeTribeSettings;
          this.SerializeSettings(this.theEyeTribeSettings, this.SettingsFile);

          if (this.theEyeTribeSettings.ServerStartParams != oldServerStartParams)
          {
            // Need to restart the eye tribe server if it is running
            if (IOHelpers.IsProcessOpen("EyeTribe"))
            {
              this.KillEyeTribeProcess();

              // Now restart 
              this.StartEyeTribeProcess();
            }
          }

          break;
      }
    }
コード例 #12
0
    /// <summary>
    /// Updates the forms UI with the new settings from the
    ///   <see cref="TheEyeTribeSetting"/> member.
    /// </summary>
    /// <param name="setting">
    /// The setting to be shown by this control
    /// </param>
    private void PushTheEyeTribeSettings(TheEyeTribeSetting setting)
    {
      switch (setting.CalibrationPointCount)
      {
        case TheEyeTribeCalibrationPoints.Nine:
          this.rdb9PtsCalib.Checked = true;
          break;
        case TheEyeTribeCalibrationPoints.Twelve:
          this.rdb12PtsCalib.Checked = true;
          break;
        case TheEyeTribeCalibrationPoints.Sixteen:
          this.rdb16PtsCalib.Checked = true;
          break;
        default:
          this.rdb9PtsCalib.Checked = true;
          break;
      }

      this.nudDisplayTime.Value = setting.PointDisplayTime;

      this.txbServerAddress.Text = setting.ServerIPAddress;
      this.txbPort.Text = setting.ServerPort.ToString(CultureInfo.InvariantCulture);
      this.clbPointColor.CurrentColor = setting.CalibrationPointColor;
      this.chbDisplayHelp.Checked = setting.DisplayHelp;
      this.clbBackColor.CurrentColor = setting.CalibrationBackgroundColor;
      this.cbbDeviceIndex.SelectedIndex = setting.DeviceIndex;
      this.cbbFramerate.SelectedIndex = setting.Framerate == 30 ? 0 : 1;
    }