KeyDownEventHandler Delegate

Summary
Represents the method that will handle an event that has received KeyDownEventArgs data.
Syntax
C#
C++/CLI
public delegate void KeyDownEventHandler( 
   object sender, 
   KeyDownEventArgs e 
) 
public delegate void KeyDownEventHandler(  
   Object^ sender, 
   KeyDownEventArgs^ e 
) 

Parameters

sender
The source of the event.

e
A KeyDownEventArgs object that contains the event data.

Remarks

Represents the method that will handle an event that has received KeyDownEventArgs data. When the KeyDownEvent event is raised in a toolkit object, any subscribed event handlers in your code will be called. See the Microsoft documentation on .NET Events and Delegates for more information about .NET delegates and events.

Example
C#
using Leadtools; 
using Leadtools.MediaFoundation; 
using LeadtoolsMediaFoundationExamples.Fixtures; 
 
 
public bool _result = false; 
public bool _exit = false; 
public CaptureCtrlForm _form = new CaptureCtrlForm(); 
 
public void KeyPressesExample() 
{ 
   CaptureCtrl capturectrl = _form.CaptureCtrl; 
   string outFile = Path.Combine(LEAD_VARS.MediaDir, "CaptureCtrl_KeyPressesExample.avi"); 
 
   try 
   { 
      // set a video device, use the name of your device here 
      if (capturectrl.VideoDevices["Analog"] == null) 
         throw new Exception("No Analog capture device available"); 
 
      capturectrl.VideoDevices["Analog"].Selected = true; 
 
      // set an audio device, use the name of your device here 
      capturectrl.AudioDevices["USB"].Selected = true; 
 
      // enable preview 
      capturectrl.Preview = true; 
 
      // set the target output file 
      capturectrl.TargetFile = outFile; 
 
      // subscribe to the key events 
      capturectrl.KeyDown += KeyDown_Helper; 
      capturectrl.KeyUp += KeyUp_Helper; 
      capturectrl.KeyPress += KeyPress_Helper; 
 
      // capture it now! 
      capturectrl.StartCapture(CaptureMode.AutoFramesAndAudio); 
   } 
   catch (Exception) 
   { 
      _result = false; 
   } 
 
   // we'll loop on the state and pump messages for this example. 
   // but you should not need to if running from a Windows Forms application. 
   while (_exit == false) 
      Application.DoEvents(); 
 
   // clean up event handlers 
   capturectrl.KeyDown -= KeyDown_Helper; 
   capturectrl.KeyUp -= KeyUp_Helper; 
   capturectrl.KeyPress -= KeyPress_Helper; 
} 
 
void KeyPress_Helper(object sender, Leadtools.MediaFoundation.KeyPressEventArgs e) 
{ 
   switch ((char)e.keyAscii) 
   { 
      case 'p': 
         // toggle preview mode 
         _form.CaptureCtrl.TogglePreview(); 
         break; 
      case 'f': 
         // toggle full screen mode 
         _form.CaptureCtrl.ToggleFullScreenMode(); 
         break; 
      case 's': 
         // stop the capture and exit 
         _form.CaptureCtrl.StopCapture(); 
         _exit = true; 
         break; 
   } 
 
   // set result 
   _result = true; 
} 
 
void KeyUp_Helper(object sender, KeyUpEventArgs e) 
{ 
   // set result 
   _result = true; 
} 
 
public void KeyDown_Helper(object sender, KeyDownEventArgs e) 
{ 
   // set result 
   _result = true; 
} 
 
static class LEAD_VARS 
{ 
   public const string MediaDir = @"C:\LEADTOOLS22\Media"; 
} 
Requirements

Target Platforms

See Also

Reference

KeyDownEventHandler Members

Leadtools.MediaFoundation Namespace

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.