/// <summary>
 /// Set the defaults
 /// </summary>
 /// <param name="sender">Object sending the event</param>
 /// <param name="e">Event arguments</param>
 private void ResetCameraDefaultsButtonClick(object sender, RoutedEventArgs e)
 {
     this.reconSensorSettings = new ReconstructionSensorSettings();
     this.UpdateSettings(
         this.reconSensorSettings.UseSensor,
         this.reconSensorSettings.NearMode,
         this.reconSensorSettings.MirrorDepth,
         this.reconSensorSettings.CaptureColor,
         this.reconSensorSettings.MinDepthClip,
         this.reconSensorSettings.MaxDepthClip,
         this.reconSensorSettings.AngleX,
         this.reconSensorSettings.AngleY,
         this.reconSensorSettings.AngleZ,
         this.reconSensorSettings.AxisDistance);
 }
        /// <summary>
        /// Load the Reconstruction Sensor settings from an .xml file
        /// </summary>
        /// <returns>Returns true if successful, false otherwise.</returns>
        public bool LoadSettings()
        {
            bool       successfulLoad = false;
            FileStream myFileStream   = null;

            // Try to Load settings
            try
            {
                string sensorName = this.ParseKinectId();

                if (!string.IsNullOrEmpty(sensorName))
                {
                    XmlSerializer mySerializer = new XmlSerializer(typeof(ReconstructionSensorSettings));
                    myFileStream = new FileStream(sensorName + ".xml", FileMode.Open);
                    ReconstructionSensorSettings reconSensorSettings = (ReconstructionSensorSettings)mySerializer.Deserialize(myFileStream);

                    if (reconSensorSettings != null)
                    {
                        // Set these manually to update the UI
                        // This will then update the transformation from the new UI settings
                        this.reconstructionSensorControl.UpdateSettings(
                            reconSensorSettings.UseSensor,
                            reconSensorSettings.NearMode,
                            reconSensorSettings.MirrorDepth,
                            reconSensorSettings.CaptureColor,
                            reconSensorSettings.MinDepthClip,
                            reconSensorSettings.MaxDepthClip,
                            reconSensorSettings.AngleX,
                            reconSensorSettings.AngleY,
                            reconSensorSettings.AngleZ,
                            reconSensorSettings.AxisDistance);

                        successfulLoad = true;
                    }
                }
            }
            catch (ArgumentException)
            {
                // Fail silently
            }
            catch (FileNotFoundException)
            {
                // Fail silently
            }
            catch (DirectoryNotFoundException)
            {
                // Fail silently
            }
            catch (PathTooLongException)
            {
                // Fail silently
            }
            catch (UnauthorizedAccessException)
            {
                // Fail silently
            }
            catch (IOException)
            {
                // Fail silently
            }
            finally
            {
                if (null != myFileStream)
                {
                    // This will close the settings file, if open.
                    myFileStream.Dispose();
                }
            }

            return(successfulLoad);
        }