/// <summary> /// Reads supported white balance preset values from Parameter.Device and populates /// ArrayParameter.Options accordingly. Sets the SelectedOption as well. /// /// White balace preset auto value is set by setting the value in PhotoCaptureDevice API to /// null, therefore the separate handling for option "Auto". /// </summary> protected override void PopulateOptions() { ArrayParameterOption option = new ArrayParameterOption(null, "Auto"); ArrayParameterOption selectedOption = option; Options.Add(option); IReadOnlyList <object> supportedValues = PhotoCaptureDevice.GetSupportedPropertyValues(Device.SensorLocation, PropertyId); object value = Device.GetProperty(PropertyId); foreach (dynamic i in supportedValues) { WhiteBalancePreset wbp = (WhiteBalancePreset)i; option = new ArrayParameterOption(wbp, wbp.EnumerationToParameterName <WhiteBalancePreset>()); Options.Add(option); if (i.Equals(value)) { selectedOption = option; } } SelectedOption = selectedOption; }
/// <summary> /// Reads supported ISO values from Parameter.Device and populates /// ArrayParameter.Options accordingly. Sets the SelectedOption as well. /// /// ISO auto value is set by setting the value in PhotoCaptureDevice API to /// null, therefore the separate handling for option "Auto". /// </summary> protected override void PopulateOptions() { ArrayParameterOption option = new ArrayParameterOption(null, "Auto", "Assets/Icons/overlay.iso.auto.png"); ArrayParameterOption selectedOption = option; Options.Add(option); CameraCapturePropertyRange range = PhotoCaptureDevice.GetSupportedPropertyRange(Device.SensorLocation, PropertyId); object value = Device.GetProperty(PropertyId); UInt32[] standardValues = { 100, 200, 400, 800, 1600, 3200 }; UInt32 min = (UInt32)range.Min; UInt32 max = (UInt32)range.Max; foreach (UInt32 i in standardValues) { if (i >= min && i <= max) { option = new ArrayParameterOption(i, "ISO " + i.ToString(), "Assets/Icons/overlay.iso." + i.ToString() + ".png"); Options.Add(option); if (i.Equals(value)) { selectedOption = option; } } } SelectedOption = selectedOption; }
/// <summary> /// Handles setting the given option as currently active one. /// </summary> /// <param name="option">Option to set as current value</param> protected async override void SetOption(ArrayParameterOption option) { if (Modifiable) { Modifiable = false; await Device.SetCaptureResolutionAsync((Windows.Foundation.Size) option.Value); Modifiable = true; } }
/// <summary> /// Reads supported exposure time values from Parameter.Device and populates /// ArrayParameter.Options accordingly. Sets the SelectedOption as well. /// /// Exposure time auto value is set by setting the value in PhotoCaptureDevice API to /// null, therefore the separate handling for option "Auto". /// </summary> protected override void PopulateOptions() { ArrayParameterOption option = new ArrayParameterOption(null, "Auto", "Assets/Icons/overlay.exposuretime.auto.png"); ArrayParameterOption selectedOption = option; Options.Add(option); CameraCapturePropertyRange range = PhotoCaptureDevice.GetSupportedPropertyRange(Device.SensorLocation, KnownCameraPhotoProperties.ExposureTime); object value = Device.GetProperty(PropertyId); // UInt32[] standardValues = { /* 16000, 8000, 4000,*/ 2000, 1000, 500, 250, 125, 60, 30, 15, 8, 4, 2 }; UInt32[] standardValues = { 16666, 16000, 8000, 4000, 2000, 1000, 500, 250, 125, 60, 30, 15, 8, 4, 2 }; UInt32 min = (UInt32)range.Min; UInt32 max = (UInt32)range.Max; System.Diagnostics.Debug.WriteLine(String.Format("Exposure time range (min {0}, max {1})", min, max)); foreach (UInt32 i in standardValues) { UInt32 usecs = 1000000 / i; if (usecs >= min && usecs <= max) { option = new ArrayParameterOption(usecs, "1 / " + i.ToString() + " s", "Assets/Icons/overlay.exposuretime." + i.ToString() + ".png"); Options.Add(option); if (selectedOption == null && usecs.Equals(value)) { selectedOption = option; } } } // Expsoure times of 1 second and over are possible in some devices. UInt32 microseconds = 1000000; // second in microseconds while (microseconds <= max) { UInt32 usecs = microseconds / 1000000; option = new ArrayParameterOption(microseconds, usecs.ToString() + " s", "Assets/Icons/overlay.exposuretime." + usecs.ToString() + "s.png"); Options.Add(option); if (selectedOption == null && usecs.Equals(value)) { selectedOption = option; } microseconds *= 2; } SelectedOption = selectedOption; }
/// <summary> /// Handles setting the given option as currently active one. /// </summary> /// <param name="option">Option to set as current value</param> protected async override void SetOption(ArrayParameterOption option) { if (Modifiable) { Modifiable = false; try { await Device.SetCaptureResolutionAsync((Windows.Foundation.Size) option.Value); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("CaptureResolutionParameter::SetOption Exception: " + e.Message); } Modifiable = true; } }
/// <summary> /// Reads supported autofocus range values from Parameter.Device and populates /// ArrayParameter.Options accordingly. Sets the SelectedOption as well. /// </summary> protected override void PopulateOptions() { IReadOnlyList <object> supportedValues = PhotoCaptureDevice.GetSupportedPropertyValues(Device.SensorLocation, PropertyId); object value = Device.GetProperty(PropertyId); foreach (dynamic i in supportedValues) { AutoFocusRange afr = (AutoFocusRange)i; ArrayParameterOption option = new ArrayParameterOption(afr, afr.EnumerationToParameterName <AutoFocusRange>()); Options.Add(option); if (i.Equals(value)) { SelectedOption = option; } } }
/// <summary> /// Reads supported flash mode values from Parameter.Device and populates /// ArrayParameter.Options accordingly. Sets the SelectedOption as well. /// </summary> protected override void PopulateOptions() { IReadOnlyList <object> supportedValues = PhotoCaptureDevice.GetSupportedPropertyValues(Device.SensorLocation, PropertyId); object value = Device.GetProperty(PropertyId); foreach (dynamic i in supportedValues) { FlashState fm = (FlashState)i; ArrayParameterOption option = new ArrayParameterOption(fm, fm.EnumerationToParameterName <FlashState>(), "Assets/Icons/overlay.flashmode." + fm.ToString().ToLower() + ".png"); Options.Add(option); if (i.Equals(value)) { SelectedOption = option; } } }
/// <summary> /// Reads supported capture resolutions from Parameter.Device and populates /// ArrayParameter.Options accordingly. Sets the SelectedOption as well. /// </summary> protected override void PopulateOptions() { IReadOnlyList <Windows.Foundation.Size> supportedValues = PhotoCaptureDevice.GetAvailableCaptureResolutions(Device.SensorLocation); Windows.Foundation.Size value = Device.CaptureResolution; ArrayParameterOption option = null; foreach (Windows.Foundation.Size i in supportedValues) { option = new ArrayParameterOption(i, i.Width + " x " + i.Height); Options.Add(option); if (i.Equals(value)) { SelectedOption = option; } } }
/// <summary> /// Reads supported capture resolutions from Parameter.Device and populates /// ArrayParameter.Options accordingly. Sets the SelectedOption as well. /// </summary> protected override void PopulateOptions() { IReadOnlyList <Windows.Foundation.Size> supportedValues = PhotoCaptureDevice.GetAvailableCaptureResolutions(Device.SensorLocation); Windows.Foundation.Size value = Device.CaptureResolution; ArrayParameterOption option = null; foreach (Windows.Foundation.Size i in supportedValues) { option = new ArrayParameterOption(i, i.Width + " x " + i.Height); Options.Add(option); if (i.Equals(value)) { SelectedOption = option; } } // The phone does support these resolutions, though it isn't given by the above? Aha: // http://developer.nokia.com/resources/library/Lumia/imaging/working-with-high-resolution-photos/capturing-high-resolution-photos.html var deviceName = DeviceStatus.DeviceName; if (deviceName.Contains("RM-875") || deviceName.Contains("RM-876") || deviceName.Contains("RM-877")) { Windows.Foundation.Size[] unofficialValues = { new Windows.Foundation.Size(7712, 4352), new Windows.Foundation.Size(7136, 5360) }; foreach (Windows.Foundation.Size i in unofficialValues) { option = new ArrayParameterOption(i, i.Width + " x " + i.Height); Options.Add(option); if (i.Equals(value)) { SelectedOption = option; } } } }
/// <summary> /// Handles setting the given option as currently active one. /// </summary> /// <param name="option">Option to set as current value</param> protected override void SetOption(ArrayParameterOption option) { Device.SetProperty(PropertyId, option.Value); }