
| Language: | .NET C#/Visual Basic |
| Version: | 3.0.3 |
| Released on: | April 7, 2005 |
| Author: | IC Imaging Control Support Department |
| Requirements: | IC Imaging Control >2.1 Camera, converter or grabber with WDM Stream Class drivers. |
| |

IC Imaging Control offers a number of easy-to-use methods to save the current settings of a video capture device to a file and to subsequently restore them. These methods are:
With the button "Device...", the user accesses the built-in dialog to select a video capture device, while the button "Properties..." allows its settings to be adjusted.
When the button "Save Settings..." is clicked , the program first checks whether the video capture device is valid (.DeviceValid). Then, CommonDialog1.ShowSave opens the Windows dialog to save a file. When .SaveDeviceStateToFile is called, IC Imaging Control writes the current parameters to the selected file:
[C#] private void btnSaveSettings_Click(object sender, System.EventArgs e) { if( icImagingControl1.DeviceValid ) { SaveFileDialog dlg = new SaveFileDialog(); dlg.AddExtension = true; dlg.DefaultExt = "xml"; dlg.Filter = "Configuration Files (*.cfg)|*.cfg||"; dlg.OverwritePrompt = true; dlg.RestoreDirectory = true; dlg.Title = "Save Settings"; if( dlg.ShowDialog() == DialogResult.OK ) { icImagingControl1.SaveDeviceStateToFile( dlg.FileName ); } } }
When the button "Restore Settings..." is clicked, the program first stops the current image data stream (.LiveStop). Then, CommonDialog1.ShowOpen opens the Windows dialog to open a file. When .LoadDeviceStateFromFile is called, IC Imaging Control reads the parameters from the selected file and tries to open and configure the video capture device, whose properties have previously been written to file. If .LoadDeviceStateFromFile fails, an exception is thrown, thus .LoadDeviceStateFromFile should be encapsulated in a try ... catch block. Finally, .LiveStart restarts the image data stream based on the new parameters.
[C#] private void btnRestoreSettings_Click(object sender, System.EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Configuration Files (*.cfg)|*.cfg||"; dlg.RestoreDirectory = true; dlg.Title = "Restore Settings"; if( dlg.ShowDialog() == DialogResult.OK ) { try { icImagingControl1.LoadDeviceStateFromFile( dlg.FileName, true ); icImagingControl1.LiveStart(); } catch( TIS.Imaging.ICException ex) { MessageBox.Show(ex.Message,"Failed to Open Device",MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
Disclaimer
The source code that appears in the IC Imaging Control Source Code Library is indented for educational purposes only. The Imaging Source Europe GmbH, the manufacturer of IC Imaging Control, does not assume any kind of warranty expressed or implied, resulting from the use of the content of this page.