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

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

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

            return(clientSettings);
        }
Beispiel #2
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 alea tracker settings.
            if (File.Exists(this.SettingsFile))
            {
                this.settings = this.DeserializeSettings(this.SettingsFile);
            }
            else
            {
                this.settings = new GazetrackerIPClientSetting();
                this.SerializeSettings(this.settings, this.SettingsFile);
            }

            this.lastTime = 0;
            this.presentationScreenSize = Document.ActiveDocument.PresentationSize;
            this.launchButton.Click    += this.LaunchButtonClick;
            this.statusUpdateTimer      = new Timer {
                Interval = 100
            };
            this.statusUpdateTimer.Tick += this.StatusUpdateTimerTick;
            this.statusUpdateTimer.Start();
            this.clientStatus.Reset();

            ThreadSafe.EnableDisableButton(this.ConnectButton, false);
        }
Beispiel #3
0
        /// <summary>
        /// Raises GTApplication SettingsWindow to change the settings
        /// for this interface.
        /// </summary>
        public override void ChangeSettings()
        {
            var dlg = new GazetrackerIPClientSettingsDialog {
                GazetrackerIPClientSetting = this.Settings
            };

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                this.settings = dlg.GazetrackerIPClientSetting;
                this.SerializeSettings(this.Settings, this.SettingsFile);

                if (this.client != null)
                {
                    this.client.IPAddress   = IPAddress.Parse(this.settings.GazeDataServerIPAddress);
                    this.client.PortReceive = this.settings.GazeDataServerPort;
                    this.client.PortSend    = this.settings.CommandServerPort;
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Serializes the <see cref="GazetrackerIPClientSetting"/> into the given file in a xml structure.
        /// </summary>
        /// <param name="clientSettings">The <see cref="GazetrackerIPClientSetting"/> object to serialize.</param>
        /// <param name="filePath">Full file path to the xml settings file.</param>
        private void SerializeSettings(GazetrackerIPClientSetting clientSettings, string filePath)
        {
            // Create an instance of the XmlSerializer class;
            // specify the type of object to serialize
            var serializer = new XmlSerializer(typeof(GazetrackerIPClientSetting));

            // Serialize the GazetrackerIPSetting, and close the TextWriter.
            try
            {
                TextWriter writer = new StreamWriter(filePath, false);
                serializer.Serialize(writer, clientSettings);
                writer.Close();
            }
            catch (Exception ex)
            {
                InformationDialog.Show(
                    "Error occured",
                    "Serialization of GazetrackerIPClientSetting failed with the following message: " + Environment.NewLine + ex.Message,
                    false,
                    MessageBoxIcon.Error);
            }
        }
    /// <summary>
    /// Serializes the <see cref="GazetrackerIPClientSetting"/> into the given file in a xml structure.
    /// </summary>
    /// <param name="clientSettings">The <see cref="GazetrackerIPClientSetting"/> object to serialize.</param>
    /// <param name="filePath">Full file path to the xml settings file.</param>
    private void SerializeSettings(GazetrackerIPClientSetting clientSettings, string filePath)
    {
      // Create an instance of the XmlSerializer class;
      // specify the type of object to serialize 
      var serializer = new XmlSerializer(typeof(GazetrackerIPClientSetting));

      // Serialize the GazetrackerIPSetting, and close the TextWriter.
      try
      {
        TextWriter writer = new StreamWriter(filePath, false);
        serializer.Serialize(writer, clientSettings);
        writer.Close();
      }
      catch (Exception ex)
      {
        InformationDialog.Show(
          "Error occured",
          "Serialization of GazetrackerIPClientSetting failed with the following message: " + Environment.NewLine + ex.Message,
          false,
          MessageBoxIcon.Error);
      }
    }
    /// <summary>
    /// Deserializes the <see cref="GazetrackerIPClientSetting"/> from the given xml file.
    /// </summary>
    /// <param name="filePath">Full file path to the xml settings file.</param>
    /// <returns>A <see cref="GazetrackerIPClientSetting"/> object.</returns>
    private GazetrackerIPClientSetting DeserializeSettings(string filePath)
    {
      var clientSettings = new GazetrackerIPClientSetting();

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

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

      return clientSettings;
    }
    /// <summary>
    /// Sets up calibration procedure and the tracking client
    /// and wires the events. Reads settings from file.
    /// </summary>
    protected override sealed void Initialize()
    {
      // Load alea tracker settings.
      if (File.Exists(this.SettingsFile))
      {
        this.settings = this.DeserializeSettings(this.SettingsFile);
      }
      else
      {
        this.settings = new GazetrackerIPClientSetting();
        this.SerializeSettings(this.settings, this.SettingsFile);
      }

      this.lastTime = 0;
      this.presentationScreenSize = Document.ActiveDocument.PresentationSize;
      this.launchButton.Click += this.LaunchButtonClick;
      this.statusUpdateTimer = new Timer { Interval = 100 };
      this.statusUpdateTimer.Tick += this.StatusUpdateTimerTick;
      this.statusUpdateTimer.Start();
      this.clientStatus.Reset();

      ThreadSafe.EnableDisableButton(this.ConnectButton, false);
    }
    /// <summary>
    /// Raises GTApplication SettingsWindow to change the settings
    /// for this interface.
    /// </summary>
    public override void ChangeSettings()
    {
      var dlg = new GazetrackerIPClientSettingsDialog { GazetrackerIPClientSetting = this.Settings };

      if (dlg.ShowDialog() == DialogResult.OK)
      {
        this.settings = dlg.GazetrackerIPClientSetting;
        this.SerializeSettings(this.Settings, this.SettingsFile);

        if (this.client != null)
        {
          this.client.IPAddress = IPAddress.Parse(this.settings.GazeDataServerIPAddress);
          this.client.PortReceive = this.settings.GazeDataServerPort;
          this.client.PortSend = this.settings.CommandServerPort;
        }
      }
    }