LEADTOOLS Multimedia (Leadtools.Multimedia assembly) Send comments on this topic. | Back to Introduction | Help Version 17.0.3.22
Selected Property
See Also 
Leadtools.Multimedia Namespace > TargetDevice Class : Selected Property



Indicates whether the device is currently selected.

Syntax

Visual Basic (Declaration) 
Public Property Selected As Boolean
Visual Basic (Usage)Copy Code
Dim instance As TargetDevice
Dim value As Boolean
 
instance.Selected = value
 
value = instance.Selected
C# 
public bool Selected {get; set;}
C++/CLI 
public:
property bool Selected {
   bool get();
   void set (    bool value);
}

Property Value

true if the device is currently selected; false, otherwise.

Example

Visual BasicCopy Code
Public _result As Boolean = False
Public _form As ConvertCtrlForm = New ConvertCtrlForm()
Public Sub TargetDevicesExample()
  Dim inputName, inputFriendlyName As String
  Dim selectedCamera As Integer

  ' reference the convert control
  Dim convertctrl As ConvertCtrl = _form.ConvertCtrl

  Try
     ' get the target devices object
     Dim devices As TargetDevices = convertctrl.TargetDevices

     ' select an input by name if possible
     If devices("Microsoft DV Camera") Is Nothing Then
       Throw New Exception("No MS DV Camera device available!")
     End If

     devices("Microsoft DV Camera").Selected = True

     ' get the full friendly name of the device 
     Dim friendlyName As String = devices("Microsoft DV Camera").FriendlyName

     ' get the selected index of the currently selected target device
     ' (the MS DV camera above)
     selectedCamera = devices.Selection

     ' now enumerate all the target devices,
     ' looking for an audio device and select it
     For Each td As TargetDevice In devices
       ' get the inputs properties
       inputName = td.Name
       inputFriendlyName = td.FriendlyName

       ' if we found a target audio device
       If inputFriendlyName.Contains("Audio") Then
         ' select it and break
         td.Selected = True
         Exit For
       End If
     Next td

     ' set the result to what we expect
     _result = (selectedCamera <> devices.Selection)

  Catch e1 As Exception
     _result = False
  End Try
End Sub
C#Copy Code
public bool _result = false;
public ConvertCtrlForm _form = new ConvertCtrlForm();
public void TargetDevicesExample()
{
   string inputName, inputFriendlyName;
   int selectedCamera;

   // reference the convert control
   ConvertCtrl convertctrl = _form.ConvertCtrl;

   try
   {
      // get the target devices object
      TargetDevices devices = convertctrl.TargetDevices;

      // select an input by name if possible
      if (devices["Microsoft DV Camera"] == null)
         throw new Exception("No MS DV Camera device available!");

      devices["Microsoft DV Camera"].Selected = true;

      // get the full friendly name of the device 
      string friendlyName = devices["Microsoft DV Camera"].FriendlyName;

      // get the selected index of the currently selected target device
      // (the MS DV camera above)
      selectedCamera = devices.Selection;

      // now enumerate all the target devices,
      // looking for an audio device and select it
      foreach (TargetDevice td in devices)
      {
         // get the inputs properties
         inputName = td.Name;
         inputFriendlyName = td.FriendlyName;

         // if we found a target audio device
         if (inputFriendlyName.Contains("Audio"))
         {
            // select it and break
            td.Selected = true;
            break;
         }
      }

      // set the result to what we expect
      _result = (selectedCamera != devices.Selection);

   }
   catch (Exception)
   {
      _result = false;
   }
}

Remarks

Indicates whether the device is currently selected. Assignment can raise an error exception. For more information, refer to the Error Codes.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also