Esempio n. 1
0
        /// <summary>
        /// Sets the name of the owner of the camera.
        /// </summary>
        /// <param name="name">The new name of the owner of the camera, that is to be set.</param>
        /// <exception cref="CameraException">
        /// If the camera configuration is not supported by the camera, then a <see cref="CameraException"/> exception is thrown.
        /// </exception>
        public async Task SetOwnerNameAsync(string name)
        {
            // Gets the owner name camera configuration
            CameraConfiguration ownerNameCameraConfiguration = await this.GetConfigurationAsync(CameraConfigurations.OwnerName);

            // Sets the new name of the owner of the camera
            try
            {
                await ownerNameCameraConfiguration.SetValueAsync(name);
            }
            catch (CameraException exception)
            {
                throw new CameraException("The camera configuration for the owner name is not supported by this camera.", exception);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Sets the aperture of the camera.
        /// </summary>
        /// <param name="aperture">The aperture to which the camera is to be set.</param>
        /// <exception cref="CameraException">
        /// If the camera configuration is not supported by the camera, then a <see cref="CameraException"/> exception is thrown.
        /// </exception>
        public async Task SetApertureAsync(double aperture)
        {
            // Gets the aperture camera configuration
            CameraConfiguration apertureCameraConfiguration = await this.GetConfigurationAsync(CameraConfigurations.Aperture);

            // Tries to set the new aperture, if an exception is thrown, then the aperture is not supported by the camera
            try
            {
                await apertureCameraConfiguration.SetValueAsync(aperture.ToString(CultureInfo.InvariantCulture));
            }
            catch (CameraException exception)
            {
                throw new CameraException(string.Format(CultureInfo.InvariantCulture, "Either the aperture configuration is not supported by the camera or the aperture of {0} is not supported by the camera.", aperture), exception);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Sets the shutter speed of the camera.
        /// </summary>
        /// <param name="shutterSpeed">The shutter speed to which the camera is to be set.</param>
        /// <exception cref="CameraException">
        /// If the camera configuration is not supported by the camera, then a <see cref="CameraException"/> exception is thrown.
        /// </exception>
        public async Task SetShutterSpeedAsync(ShutterSpeed shutterSpeed)
        {
            // Gets the shutter speed camera configuration
            CameraConfiguration shutterSpeedCameraConfiguration = await this.GetConfigurationAsync(CameraConfigurations.ShutterSpeed);

            // Tries to set the shutter speed
            try
            {
                await shutterSpeedCameraConfiguration.SetValueAsync(shutterSpeed.TextualRepresentation);
            }
            catch (CameraException exception)
            {
                throw new CameraException("The camera configuration for the shutter speed is not supported by this camera.", exception);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Sets the ISO speed of the camera.
        /// </summary>
        /// <param name="isoSpeed">
        /// The ISO speed to which the camera is to be set. An ISO speed of 0 sets the camera to an Auto ISO speed, which means that the camera
        /// determines the correct ISO speed for the current lighting conditions
        /// </param>
        /// <exception cref="CameraException">
        /// If the camera configuration is not supported by the camera, then a <see cref="CameraException"/> exception is thrown.
        /// </exception>
        public async Task SetIsoSpeedAsync(int isoSpeed)
        {
            // Gets the ISO speed camera configuration
            CameraConfiguration isoSpeedCameraConfiguration = await this.GetConfigurationAsync(CameraConfigurations.IsoSpeed);

            // Tries to set the new ISO speed, if an exception is thrown, then the ISO speed is not supported by the camera
            try
            {
                await isoSpeedCameraConfiguration.SetValueAsync(isoSpeed == 0? "Auto" : isoSpeed.ToString(CultureInfo.InvariantCulture));
            }
            catch (CameraException exception)
            {
                throw new CameraException(string.Format(CultureInfo.InvariantCulture, "Either the ISO speed configuration is not supported by the camera or the ISO speed of {0} is not supported by the camera.", isoSpeed == 0 ? "Auto" : isoSpeed.ToString(CultureInfo.InvariantCulture)), exception);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Sets the shutter speed of the camera.
        /// </summary>
        /// <param name="shutterSpeed">
        /// The shutter speed to which the camera is to be set. A shutter speed of <c>TimeSpan.MaxValue</c> sets the camera to a Bulb shutter
        /// speed, which means that the camera exposes the image for as long as the release is pressed.
        /// </param>
        /// <exception cref="CameraException">
        /// If the camera configuration is not supported by the camera, then a <see cref="CameraException"/> exception is thrown.
        /// </exception>
        public async Task SetShutterSpeedAsync(TimeSpan shutterSpeed)
        {
            // Gets the shutter speed camera configuration
            CameraConfiguration shutterSpeedCameraConfiguration = await this.GetConfigurationAsync(CameraConfigurations.ShutterSpeed);

            // Gets all the choices and converts them to TimeSpans, which is needed to determine the correct value for the shutter speed to set
            try
            {
                // Gets all supported shutter speeds
                IEnumerable <ShutterSpeed> supportedShutterSpeeds = await this.GetSupportedShutterSpeedsAsync();

                // Chooses the correct shutter speed value from the available choices and sets it, if the shutter speed could not be detected,
                // then an exception is thrown
                if (!supportedShutterSpeeds.Any(speed => speed.Speed == shutterSpeed))
                {
                    throw new CameraException(string.Format(CultureInfo.InvariantCulture, "The shutter speed {0} is not supported by the camera.", shutterSpeed));
                }
                await shutterSpeedCameraConfiguration.SetValueAsync(supportedShutterSpeeds.FirstOrDefault(speed => speed.Speed == shutterSpeed).TextualRepresentation);
            }
            catch (CameraException exception)
            {
                throw new CameraException("The camera configuration for the shutter speed is not supported by this camera.", exception);
            }
        }