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

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

            // 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 = (TobiiSetting)serializer.Deserialize(fs);
                fs.Close();
            }
            catch (Exception ex)
            {
                InformationDialog.Show(
                    "Error occured",
                    "Deserialization of TobiiSettings failed with the following message: " + Environment.NewLine + ex.Message,
                    false,
                    MessageBoxIcon.Error);
            }

            return(settings);
        }
Example #2
0
        ///////////////////////////////////////////////////////////////////////////////
        // Defining Constants                                                        //
        ///////////////////////////////////////////////////////////////////////////////
        #region CONSTANTS
        #endregion //CONSTANTS

        ///////////////////////////////////////////////////////////////////////////////
        // Defining Variables, Enumerations, Events                                  //
        ///////////////////////////////////////////////////////////////////////////////
        #region FIELDS

        /////// <summary>
        /////// Saves the current active <see cref="TobiiSetting"/> to use.
        /////// </summary>
        ////private TobiiSetting tobiiSettings;

        /////// <summary>
        /////// Saves whether this dialog is connected to the tracker.
        /////// </summary>
        ////private bool isConnected;

        #endregion //FIELDS

        ///////////////////////////////////////////////////////////////////////////////
        // Construction and Initializing methods                                     //
        ///////////////////////////////////////////////////////////////////////////////
        #region CONSTRUCTION

        /// <summary>
        /// Initializes a new instance of the TobiiTrackStatus class.
        /// </summary>
        /// <param name="setting">A <see cref="TobiiSetting"/> to use for
        /// connection.</param>
        public TobiiTrackStatus(TobiiSetting setting)
        {
            this.InitializeComponent();

            // this.tobiiSettings = setting;
            // this.Connect();
        }
Example #3
0
    ///////////////////////////////////////////////////////////////////////////////
    // Defining Constants                                                        //
    ///////////////////////////////////////////////////////////////////////////////
    #region CONSTANTS
    #endregion //CONSTANTS

    ///////////////////////////////////////////////////////////////////////////////
    // Defining Variables, Enumerations, Events                                  //
    ///////////////////////////////////////////////////////////////////////////////
    #region FIELDS

    /////// <summary>
    /////// Saves the current active <see cref="TobiiSetting"/> to use.
    /////// </summary>
    ////private TobiiSetting tobiiSettings;

    /////// <summary>
    /////// Saves whether this dialog is connected to the tracker.
    /////// </summary>
    ////private bool isConnected;

    #endregion //FIELDS

    ///////////////////////////////////////////////////////////////////////////////
    // Construction and Initializing methods                                     //
    ///////////////////////////////////////////////////////////////////////////////
    #region CONSTRUCTION

    /// <summary>
    /// Initializes a new instance of the TobiiTrackStatus class.
    /// </summary>
    /// <param name="setting">A <see cref="TobiiSetting"/> to use for
    /// connection.</param>
    public TobiiTrackStatus(TobiiSetting setting)
    {
      this.InitializeComponent();

      // this.tobiiSettings = setting;
      // this.Connect();
    }
Example #4
0
        /// <summary>
        ///   Raises <see cref="TobiiSettingsDialog" /> to change the settings
        ///   for this interface.
        /// </summary>
        public override void ChangeSettings()
        {
            var dlg = new TobiiSettingsDialog {
                TobiiSettings = this.tobiiSettings
            };

            switch (dlg.ShowDialog())
            {
            case DialogResult.OK:
                this.tobiiSettings = dlg.TobiiSettings;
                this.UpdateSettings();
                this.SerializeSettings(this.tobiiSettings, this.SettingsFile);
                break;
            }
        }
Example #5
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 tobii tracker settings.
            if (File.Exists(this.SettingsFile))
            {
                this.tobiiSettings = this.DeserializeSettings(this.SettingsFile);
            }
            else
            {
                this.tobiiSettings = new TobiiSetting();
                this.SerializeSettings(this.tobiiSettings, this.SettingsFile);
            }

            this.UpdateSettings();

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

            // Serialize the TobiiSetting, 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 TobiiSettings failed with the following message: " + Environment.NewLine + ex.Message,
                    false,
                    MessageBoxIcon.Error);
            }
        }
Example #7
0
    /// <summary>
    /// Serializes the <see cref="TobiiSetting"/> into the given file in a xml structure.
    /// </summary>
    /// <param name="settings">
    /// The <see cref="TobiiSetting"/> object to serialize.
    /// </param>
    /// <param name="filePath">
    /// Full file path to the xml settings file.
    /// </param>
    private void SerializeSettings(TobiiSetting settings, string filePath)
    {
      // Create an instance of the XmlSerializer class;
      // specify the type of object to serialize 
      var serializer = new XmlSerializer(typeof(TobiiSetting));

      // Serialize the TobiiSetting, 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 TobiiSettings failed with the following message: " + Environment.NewLine + ex.Message, 
          false, 
          MessageBoxIcon.Error);
      }
    }
Example #8
0
    /// <summary>
    /// Deserializes the <see cref="TobiiSetting"/> from the given xml file.
    /// </summary>
    /// <param name="filePath">
    /// Full file path to the xml settings file. 
    /// </param>
    /// <returns>
    /// A <see cref="TobiiSetting"/> object. 
    /// </returns>
    private TobiiSetting DeserializeSettings(string filePath)
    {
      var settings = new TobiiSetting();

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

      // 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 = (TobiiSetting)serializer.Deserialize(fs);
        fs.Close();
      }
      catch (Exception ex)
      {
        InformationDialog.Show(
          "Error occured", 
          "Deserialization of TobiiSettings failed with the following message: " + Environment.NewLine + ex.Message, 
          false, 
          MessageBoxIcon.Error);
      }

      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()
    {
      // Load tobii tracker settings.
      if (File.Exists(this.SettingsFile))
      {
        this.tobiiSettings = this.DeserializeSettings(this.SettingsFile);
      }
      else
      {
        this.tobiiSettings = new TobiiSetting();
        this.SerializeSettings(this.tobiiSettings, this.SettingsFile);
      }

      this.UpdateSettings();

      base.Initialize();
    }
Example #10
0
 /// <summary>
 ///   Raises <see cref="TobiiSettingsDialog" /> to change the settings
 ///   for this interface.
 /// </summary>
 public override void ChangeSettings()
 {
   var dlg = new TobiiSettingsDialog { TobiiSettings = this.tobiiSettings };
   switch (dlg.ShowDialog())
   {
     case DialogResult.OK:
       this.tobiiSettings = dlg.TobiiSettings;
       this.UpdateSettings();
       this.SerializeSettings(this.tobiiSettings, this.SettingsFile);
       break;
   }
 }