private void UpdateCameraPropertyRange(CameraPropertyCapabilities propertyCapabilities) { String text; if (IsSelectedCameraPropertySupported && propertyCapabilities.IsGetRangeSupported && propertyCapabilities.IsGetSupported) { CameraPropertyRange range = CurrentCamera.GetCameraPropertyRange(SelectedCameraProperty); text = String.Format("[ {0}, {1} ], step: {2}", range.Minimum, range.Maximum, range.Step); Int32 decimalPlaces; Decimal minimum, maximum, increment; if (IsCameraPropertyValueTypeValue) { minimum = range.Minimum; maximum = range.Maximum; increment = range.Step; decimalPlaces = 0; } else if (IsCameraPropertyValueTypePercentage) { minimum = 0; maximum = 100; increment = 0.01M; decimalPlaces = 2; } else { throw new NotSupportedException(String.Format("Camera property value type '{0}' is not supported.", ( String )cameraPropertyValueTypeSelection.SelectedItem)); } cameraPropertyValueValue.Minimum = minimum; cameraPropertyValueValue.Maximum = maximum; cameraPropertyValueValue.Increment = increment; cameraPropertyValueValue.DecimalPlaces = decimalPlaces; if (CurrentCameraPropertyRanges.ContainsKey(SelectedCameraProperty)) { CurrentCameraPropertyRanges[SelectedCameraProperty] = range; } else { CurrentCameraPropertyRanges.Add(SelectedCameraProperty, range); } CameraPropertyValue value = CurrentCamera.GetCameraProperty(SelectedCameraProperty, IsCameraPropertyValueTypeValue); SuppressCameraPropertyValueValueChangedEvent = true; cameraPropertyValueValue.Value = value.Value; cameraPropertyValueAuto.Checked = value.IsAuto; SuppressCameraPropertyValueValueChangedEvent = false; } else { text = "N/A"; } cameraPropertyRangeValue.Text = text; }
private void cameraPropertyValue_SelectedIndexChanged(Object sender, EventArgs e) { if (CameraPropertyControlInitializationComplete) { IsSelectedCameraPropertySupported = CurrentCamera.IsCameraPropertySupported(SelectedCameraProperty); CameraPropertyCapabilities propertyCapabilities = CurrentCameraPropertyCapabilities[SelectedCameraProperty]; UpdateCameraPropertyRange(propertyCapabilities); cameraPropertyValueAuto.Enabled = cameraPropertyValueValue.Enabled = cameraPropertyValueTypeSelection.Enabled = IsSelectedCameraPropertySupported && propertyCapabilities.IsFullySupported; } }
private void cameraPropertyValueTypeSelection_SelectedIndexChanged(Object sender, EventArgs e) { if (CameraPropertyControlInitializationComplete) { CameraPropertyCapabilities propertyCapabilities = CurrentCameraPropertyCapabilities[SelectedCameraProperty]; CameraPropertyRange range = CurrentCameraPropertyRanges[SelectedCameraProperty]; Decimal previousValue = cameraPropertyValueValue.Value; UpdateCameraPropertyRange(propertyCapabilities); Decimal newValue; if (IsCameraPropertyValueTypeValue) // The previous value was a percentage. { newValue = range.DomainSize * previousValue / 100 + range.Minimum; } else if (IsCameraPropertyValueTypePercentage) // The previous value was a value. { newValue = (previousValue - range.Minimum) * 100 / range.DomainSize; } else { throw new NotSupportedException(String.Format("Camera property value type '{0}' is not supported.", ( String )cameraPropertyValueTypeSelection.SelectedItem)); } newValue = Math.Round(newValue); if (newValue > range.Maximum) { newValue = range.Maximum; } else if (newValue < range.Minimum) { newValue = range.Minimum; } SuppressCameraPropertyValueValueChangedEvent = true; cameraPropertyValueValue.Value = newValue; SuppressCameraPropertyValueValueChangedEvent = false; } }
private void UpdateCameraPropertyRange( CameraPropertyCapabilities propertyCapabilities ) { String text; if( IsSelectedCameraPropertySupported && propertyCapabilities.IsGetRangeSupported && propertyCapabilities.IsGetSupported ) { CameraPropertyRange range = CurrentCamera.GetCameraPropertyRange( SelectedCameraProperty ); text = String.Format( "[ {0}, {1} ], step: {2}", range.Minimum, range.Maximum, range.Step ); Int32 decimalPlaces; Decimal minimum, maximum, increment; if( IsCameraPropertyValueTypeValue ) { minimum = range.Minimum; maximum = range.Maximum; increment = range.Step; decimalPlaces = 0; } else if( IsCameraPropertyValueTypePercentage ) { minimum = 0; maximum = 100; increment = 0.01M; decimalPlaces = 2; } else throw new NotSupportedException( String.Format( "Camera property value type '{0}' is not supported.", ( String ) cameraPropertyValueTypeSelection.SelectedItem ) ); cameraPropertyValueValue.Minimum = minimum; cameraPropertyValueValue.Maximum = maximum; cameraPropertyValueValue.Increment = increment; cameraPropertyValueValue.DecimalPlaces = decimalPlaces; if( CurrentCameraPropertyRanges.ContainsKey( SelectedCameraProperty ) ) CurrentCameraPropertyRanges[ SelectedCameraProperty ] = range; else CurrentCameraPropertyRanges.Add( SelectedCameraProperty, range ); CameraPropertyValue value = CurrentCamera.GetCameraProperty( SelectedCameraProperty, IsCameraPropertyValueTypeValue ); SuppressCameraPropertyValueValueChangedEvent = true; cameraPropertyValueValue.Value = value.Value; cameraPropertyValueAuto.Checked = value.IsAuto; SuppressCameraPropertyValueValueChangedEvent = false; } else text = "N/A"; cameraPropertyRangeValue.Text = text; }