Selection Property

Summary
Gets or sets the zero-based index of the selected VideoFormat item.
Syntax
C#
C++/CLI
public int Selection { get; set; } 
public: 
property int Selection { 
   int get(); 
   void set (    int ); 
} 

Property Value

The zero-based index of the selected item; otherwise -1 if no item is selected.

Remarks

Gets or sets the index of the selected VideoFormat item. Assigning a value to this property could raise an error exception. For more information, refer to the Error Codes.

Example
C#
using Leadtools; 
using Leadtools.MediaFoundation; 
using LeadtoolsMediaFoundationExamples.Fixtures; 
 
 
public CaptureCtrlForm _form = new CaptureCtrlForm(); 
public bool _result = false; 
 
public void VideoFormatExample() 
{ 
   // reference the capture control 
   CaptureCtrl capturectrl = _form.CaptureCtrl; 
 
   int count, compression = 0, bits = 0, width = 0, height = 0; 
   int found, selected = -1; 
 
   // set a video device, use the name of your device here 
   if (capturectrl.VideoDevices["USB"] != null) 
      capturectrl.VideoDevices["USB"].Selected = true; 
 
   // reference the videoformats property 
   VideoFormats videoformats = capturectrl.VideoCaptureFormats; 
 
   try 
   { 
      // get count of available video formats 
      count = videoformats.Count; 
 
      // enumerate formats and select one 
      foreach (VideoFormat vf in videoformats) 
      { 
         // get the properties 
         bits = vf.BitCount; 
         compression = vf.Compression; 
         width = vf.Width; 
         height = vf.Height; 
 
         // select the format if it matches some criteria 
         if (bits == 16 && width == 640 && height == 480) 
         { 
            vf.Selected = true; 
            break; 
         } 
      } 
 
      // get the currently selected format 
      selected = videoformats.Selection; 
 
      // find a format based on subtype name, width and height (YUY2 320 x 240 video) 
      found = videoformats.IndexOf(Constants.MEDIASUBTYPE_YUY2, 320, 240); 
 
      // our found format is not selected, so select it 
      if (found != selected) 
         videoformats.Selection = found; 
 
      // get the new selected format 
      selected = videoformats.Selection; 
 
      // set our result based on what we expect 
      _result = (count > 0 && selected == found); 
   } 
   catch (Exception) 
   { 
      _result = false; 
   } 
} 
Requirements

Target Platforms

Help Version 22.0.2022.12.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.MediaFoundation Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.