←Select platform

SetPropertiesEvent Event

Summary
Occurs while setting each property inside the WiaProperties structure after calling the SetProperties method.

Syntax
C#
C++/CLI
Python
public event EventHandler<WiaSetPropertiesEventArgs> SetPropertiesEvent 
public: 
event EventHandler<WiaSetPropertiesEventArgs^>^ SetPropertiesEvent 
def SetPropertiesEvent(sender,e): # sender: WiaSession e: WiaSetPropertiesEventArgs 
Event Data

The event handler receives an argument of type WiaSetPropertiesEventArgs containing data related to this event. The following WiaSetPropertiesEventArgs properties provide information specific to this event.

PropertyDescription
Error Gets the returned error code for each property being set.
PropertyId Gets the property ID for the property being set.
Stop Enables or disables firing the SetPropertiesEvent event.
Value Gets the property value for the property being set.
ValueType Gets the type of the property being set.
Remarks

This event will be called while setting each property inside the WiaProperties structure after calling the SetProperties method to provide the user with information about the return error, the property Id, the property value and property variable type and also gives the ability to abort the properties setting process.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Wia; 
 
 
WiaSession wiaSession; 
       
public void GetRootItemExample(IntPtr parent) 
{ 
   if (!WiaSession.IsAvailable(WiaVersion.Version1)) 
   { 
      Console.WriteLine("WIA version 1.0 not installed."); 
      return; 
   } 
   wiaSession = new WiaSession(); 
   wiaSession.Startup(WiaVersion.Version1); 
 
   DialogResult res = wiaSession.SelectDeviceDlg(parent, WiaDeviceType.Default, WiaSelectSourceFlags.NoDefault); 
   if (res != DialogResult.OK) 
   { 
      Console.WriteLine("Error selecting WIA device."); 
      wiaSession.Shutdown(); 
      return; 
   } 
 
   object rootItem = wiaSession.GetRootItem(null); 
   if (rootItem != null) 
   { 
      wiaSession.EnumItemsEvent += new EventHandler<WiaEnumItemsEventArgs>(wiaSession_EnumItemsEvent); 
 
      wiaSession.EnumChildItems(rootItem); 
 
      wiaSession.EnumItemsEvent -= new EventHandler<WiaEnumItemsEventArgs>(wiaSession_EnumItemsEvent); 
   } 
 
   wiaSession.Shutdown(); 
} 
 
void wiaSession_EnumItemsEvent(object sender, WiaEnumItemsEventArgs e) 
{ 
   if (e.Item != null) 
   { 
      WiaDataTransferProperties dataTransfer = WiaDataTransferProperties.Empty; 
      WiaImageEffectsProperties imageEffects = WiaImageEffectsProperties.Empty; 
 
      WiaProperties properties = wiaSession.GetProperties(e.Item); 
 
      dataTransfer.ImageDataType = WiaImageDataType.Grayscale; 
      imageEffects.Brightness = 250; 
 
      properties.DataTransfer = dataTransfer; 
      properties.ImageEffects = imageEffects; 
      properties.ScanningMode = WiaScanningModeFlags.Feeder;   // set scanning source to Feeder 
      properties.MaximumNumberOfPages = 0;                     // scan all pages in feeder 
      properties.ImageType = WiaImageType.Grayscale; 
      properties.Orientation = WiaOrientation.Portrait; 
 
      WiaImageResolutionProperties imageResolution = properties.ImageResolution; 
      imageResolution.BitsPerPixel = 8; 
      imageResolution.HorizontalResolution = 600; 
      imageResolution.VerticalResolution = 600; 
      properties.ImageResolution = imageResolution; 
 
      wiaSession.SetPropertiesEvent += new EventHandler<WiaSetPropertiesEventArgs>(wiaSession_SetPropertiesEvent); 
 
      wiaSession.SetProperties(e.Item, properties); 
 
      wiaSession.SetPropertiesEvent -= new EventHandler<WiaSetPropertiesEventArgs>(wiaSession_SetPropertiesEvent); 
 
      wiaSession.FreeItem(e.Item); 
   } 
} 
 
void wiaSession_SetPropertiesEvent(object sender, WiaSetPropertiesEventArgs e) 
{ 
   if (e.Error <= 0) 
   { 
      Console.WriteLine("Failed to set the below property:\n\tProperty Id: {0}\n\tProperty Value: {1}\n\tError: {2}\n\n", e.PropertyId.ToString(), e.Value.ToString(), e.Error.ToString()); 
   } 
} 
Requirements

Target Platforms

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

Leadtools.Wia Assembly

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