Modify Device Properties This source code snippet illustrates how video capture device properties can be modified.
The window of the resulting application looks as follows: IC Imaging Control offers the VCDSimpleProperty class to adjust video capture device settings: C# private VCDSimpleProperty vcdProp = null; VB.NET Private VCDProp As TIS.Imaging.VCDHelpers.VCDSimpleProperty The instance of VCDSimpleProperty class is created by Form1_load: C# vcdProp = new VCDSimpleProperty( icImagingControl1.VCDPropertyItems ); VB.NET VCDProp = TIS.Imaging.VCDHelpers.VCDSimpleModule.GetSimplePropertyContainer(ICImagingControl1.VCDPropertyItems) First of all, the program checks whether the device provides an automatic mode for the parameter "Brightness". If it does not, the dialog's checkbox Auto (chkBrightnessAuto.Enabled = False) is deactivated. If it does, the program explicitly switches it off (VCDProp.Automation(VCDID_Brightness = False): C# if( !vcdProp.AutoAvailable( VCDIDs.VCDID_Brightness ) ) { chkBrightnessAuto.Enabled = false; } else { vcdProp.Automation[VCDIDs.VCDID_Brightness] = false; } VB.NET If Not VCDProp.AutoAvailable(VCDIDs.VCDID_Brightness) Then BrightnessAutoCheckBox.Enabled = False Else VCDProp.Automation(VCDIDs.VCDID_Brightness) = False End If Secondly, the program checks whether the device allows the parameter "Brightness" to be manually adjusted. If it does not, the dialog's slider Brightness (sldBrightness.Enabled = False ) is deactivated. If it does, the program determines the smallest and highest value provided by the device (VCDProp.RangeMin and VCDProp.RangeMax) and the current value (VCDProp.RangeValue). The program then uses these values to initialize sldBrightness and lblBrightnessValue: C# if( !vcdProp.Available( VCDIDs.VCDID_Brightness ) ) { sldBrightness.Enabled = false; } else { sldBrightness.Minimum = vcdProp.RangeMin(VCDIDs.VCDID_Brightness); sldBrightness.Maximum = vcdProp.RangeMax(VCDIDs.VCDID_Brightness); sldBrightness.Value = vcdProp.RangeValue[VCDIDs.VCDID_Brightness]; sldBrightness.TickFrequency = (sldBrightness.Maximum - sldBrightness.Minimum) / 10; lblBrightnessValue.Text = sldBrightness.Value.ToString(); } VB.NET If Not VCDProp.Available(VCDIDs.VCDID_Brightness) Then BrightnessTrackBar.Enabled = False Else BrightnessTrackBar.Enabled = True BrightnessTrackBar.Minimum = VCDProp.RangeMin(VCDIDs.VCDID_Brightness) BrightnessTrackBar.Maximum = VCDProp.RangeMax(VCDIDs.VCDID_Brightness) BrightnessTrackBar.Value = VCDProp.RangeValue(VCDIDs.VCDID_Brightness) BrightnessTrackBar.TickFrequency = (BrightnessTrackBar.Maximum - BrightnessTrackBar.Minimum) / 10 BrightnessValueLabel.Text = BrightnessTrackBar.Value End If When the user modifies the slider's position of sldBrightness, the program writes the new "Brightness" value into the device (VCDProp.RangeValue(VCDID_Brightness)) and displays it in the dialog ( lblBrightnessValue): C# private void sldBrightness_Scroll(object sender, System.EventArgs e) { vcdProp.RangeValue[VCDIDs.VCDID_Brightness] = sldBrightness.Value; lblBrightnessValue.Text = sldBrightness.Value.ToString(); } VB.NET Private Sub BrightnessTrackBar_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BrightnessTrackBar.Scroll VCDProp.RangeValue(VCDIDs.VCDID_Brightness) = BrightnessTrackBar.Value BrightnessValueLabel.Text = VCDProp.RangeValue(VCDIDs.VCDID_Brightness) End Sub When the user clicks the check box Auto (chkBrightnessAuto ) to activate the automatic mode, the program enables this mode of the device (VCDProp.Automation(VCDID_Brightness) = True) and deactivates the slider (sldBrightness.Enabled = False): C# private void chkBrightnessAuto_CheckedChanged(object sender, System.EventArgs e) { vcdProp.Automation[VCDIDs.VCDID_Brightness] = chkBrightnessAuto.Checked; sldBrightness.Enabled = !chkBrightnessAuto.Checked; } VB.NET Private Sub BrightnessAutoCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BrightnessAutoCheckBox.CheckedChanged VCDProp.Automation(VCDIDs.VCDID_Brightness) = BrightnessAutoCheckBox.Checked BrightnessTrackBar.Enabled = Not BrightnessAutoCheckBox.Checked End Sub The adjustment of other device settings follows the above scheme. There is a list of settings offered by IC Imaging Control in the User's Guide. |