Codec Property Page Short source code snippet that illustrates how to modify the properties of a codec using IC Imaging Control.
Language: | .NET C#/Visual Basic
Version: | 3.3
Author: | IC Imaging Control Support Department
Requirements: |
Software: | IC Imaging Control 3.3, Visual Studio™ 2010
Hardware: | Camera, converter or grabber with WDM Stream Class drivers.
Download C# sample | Codec Property Page - C#

First of all, a listbox and button are dragged onto the form. These are labeled lstCodecs and btnShowPropertyPage respectively. The listbox will be used to list all available codecs and the button will be used to show the property page of the currently selected codec.

The sample application fills the list lstCodecs with the names of all codecs that are installed on the computer (see dialog on the right). The collection .AviCompressors is used for this task. This collection contains all available AVI codecs. It is simply passed to the listbox's lstCodecs property DataSource. Thus, the data in the listbox lstCodecs will contain all information about the currently available codecs.

    C#

    private void Form1_Load(object sender, System.EventArgs e)
    {
        lstCodecs.DataSource = icImagingControl1.AviCompressors;
    }

When the user clicks on one of the listed codecs, the event list box's handler calls the corresponding AviCompressor object and checks whether it provides a property page, by querying AviCompressor.PropertyPageAvailable. If AviCompressor.PropertyPageAvailable returns true, the button btnShowPropertyPage is enabled. Otherwise, it is disabled.

    C#

    private void lstCodecs_SelectedIndexChanged(object sender, System.EventArgs e)
    {
        AviCompressor codec = lstCodecs.SelectedItem as AviCompressor;

        if( codec != null )
        {
            btnShowPropertyPage.Enabled = codec.PropertyPageAvailable;
        }
    }

By clicking on the button btnShowPropertyPage, the user can open a dialog to modify the properties of the selected codec. The method AviCompressor.ShowPropertyPage() is called in the button event handler. This method shows the codec's property dialog.

    C#

    private void btnShowPropertyPage_Click(object sender, System.EventArgs e)
    {
        AviCompressor codec = lstCodecs.SelectedItem as AviCompressor;

        if( codec != null )
        {
            codec.ShowPropertyPage();
        }
    }