Example #1
0
        /// <summary>
        /// Retrieves the current ISO speed of the camera.
        /// </summary>
        /// <exception cref="CameraException">
        /// If the camera configuration is not supported by the camera, then a <see cref="CameraException"/> exception is thrown.
        /// </exception>
        /// <returns>Returns the current ISO speed of the camera. If the ISO speed is set to Auto, then 0 is returned.</returns>
        public async Task <int> GetIsoSpeedAsync()
        {
            // Gets the ISO speed camera configuration
            CameraConfiguration isoSpeedCameraConfiguration = await this.GetConfigurationAsync(CameraConfigurations.IsoSpeed);

            // Retrieves the current ISO speed of the camera
            try
            {
                // Retrieves the textual representation of the ISO speed
                string currentIsoSpeedTextualRepresentation = await isoSpeedCameraConfiguration.GetValueAsync();

                // Checks if the ISO speed is set to Auto, if so then 0 is returned, otherwise the ISO speed is converted to an integer and returned
                if (currentIsoSpeedTextualRepresentation.ToUpperInvariant() == "AUTO")
                {
                    return(IsoSpeeds.Auto);
                }
                else
                {
                    return(int.Parse(currentIsoSpeedTextualRepresentation, CultureInfo.InvariantCulture));
                }
            }
            catch (CameraException exception)
            {
                throw new CameraException("The camera configuration for the ISO speed is not supported by this camera.", exception);
            }
        }
Example #2
0
        /// <summary>
        /// Retrieves the battery level of the camera.
        /// </summary>
        /// <exception cref="CameraException">
        /// If the camera configuration is not supported by the camera, then a <see cref="CameraException"/> exception is thrown.
        /// </exception>
        /// <returns>Returns the battery level of the camera.</returns>
        public async Task <string> GetBatteryLevelAsync()
        {
            // Gets the battery level camera configuration
            CameraConfiguration batteryLevelCameraConfiguration = await this.GetConfigurationAsync(CameraConfigurations.BatteryLevel);

            // Retrieves the battery level of the camera and returns it
            try
            {
                return(await batteryLevelCameraConfiguration.GetValueAsync());
            }
            catch (CameraException exception)
            {
                throw new CameraException("The camera configuration for the battery level is not supported by this camera.", exception);
            }
        }
Example #3
0
        /// <summary>
        /// Retrieves the name of the lens of the camera.
        /// </summary>
        /// <exception cref="CameraException">
        /// If the camera configuration is not supported by the camera, then a <see cref="CameraException"/> exception is thrown.
        /// </exception>
        /// <returns>Returns the name of the lens of the camera.</returns>
        public async Task <string> GetLensNameAsync()
        {
            // Gets the lens name camera configuration
            CameraConfiguration lensNameCameraConfiguration = await this.GetConfigurationAsync(CameraConfigurations.LensName);

            // Retrieves the name of the lens of the camera and returns it
            try
            {
                return(await lensNameCameraConfiguration.GetValueAsync());
            }
            catch (CameraException exception)
            {
                throw new CameraException("The camera configuration for the lens name is not supported by this camera.", exception);
            }
        }
Example #4
0
        /// <summary>
        /// Retrieves the name of the manufacturer of the camera.
        /// </summary>
        /// <exception cref="CameraException">
        /// If the camera configuration is not supported by the camera, then a <see cref="CameraException"/> exception is thrown.
        /// </exception>
        /// <returns>Returns the name of the manufacturer of the camera.</returns>
        public async Task <string> GetManufacturerAsync()
        {
            // Gets the manufacturer camera configuration
            CameraConfiguration manufacturerCameraConfiguration = await this.GetConfigurationAsync(CameraConfigurations.Manufacturer);

            // Retrieves the manufacturer and returns it
            try
            {
                return(await manufacturerCameraConfiguration.GetValueAsync());
            }
            catch (CameraException exception)
            {
                throw new CameraException("The camera configuration for the camera manufacturer is not supported by this camera.", exception);
            }
        }
Example #5
0
        /// <summary>
        /// Retrieves the current aperture of the camera.
        /// </summary>
        /// <exception cref="CameraException">
        /// If the camera configuration is not supported by the camera, then a <see cref="CameraException"/> exception is thrown.
        /// </exception>
        /// <returns>Returns the current aperture of the camera.</returns>
        public async Task <double> GetApertureAsync()
        {
            // Gets the aperture camera configuration
            CameraConfiguration apertureCameraConfiguration = await this.GetConfigurationAsync(CameraConfigurations.Aperture);

            // Retrieves the current aperture of the camera
            try
            {
                // Retrieves and parses the aperture and returns it
                string currentApertureTextualRepresentation = await apertureCameraConfiguration.GetValueAsync();

                return(double.Parse(currentApertureTextualRepresentation, CultureInfo.InvariantCulture));
            }
            catch (CameraException exception)
            {
                throw new CameraException("The camera configuration for the aperture is not supported by this camera.", exception);
            }
        }
Example #6
0
        /// <summary>
        /// Gets the current shutter speed of the camera.
        /// </summary>
        /// <exception cref="CameraException">
        /// If the camera configuration is not supported by the camera or the shutter speed could not be retrieved properly, then a
        /// <see cref="CameraException"/> exception is thrown.
        /// </exception>
        /// <returns>Returns the current shutter speed of the camera.</returns>
        public async Task <ShutterSpeed> GetShutterSpeedAsync()
        {
            // Gets the shutter speed camera configuration
            CameraConfiguration shutterSpeedCameraConfiguration = await this.GetConfigurationAsync(CameraConfigurations.ShutterSpeed);

            // Retrieves the current shutter speed of the camera
            try
            {
                // Gets the textual representation of the shutter speed
                string currentShutterSpeedTextualRepresentation = await shutterSpeedCameraConfiguration.GetValueAsync();

                // Converts the textual representation of the shutter speed into a shutter speed object and returns it
                return(new ShutterSpeed(currentShutterSpeedTextualRepresentation));
            }
            catch (CameraException exception)
            {
                throw new CameraException("The camera configuration for the shutter speed is not supported by this camera.", exception);
            }
        }